Skip to content

Instantly share code, notes, and snippets.

@ironmaniiith
Last active October 10, 2016 21:30
Show Gist options
  • Save ironmaniiith/9ce61e592690b4d1f24604a8961b34d0 to your computer and use it in GitHub Desktop.
Save ironmaniiith/9ce61e592690b4d1f24604a8961b34d0 to your computer and use it in GitHub Desktop.
ESPN cricket notification
Notification.requestPermission();
function createNotification(theTitle, theIcon, theBody){
var options = {
icon: theIcon,
body: theBody,
};
var notification = new Notification(theTitle, options);
setTimeout(notification.close.bind(notification), 10000);
}
function findScore(){
var temp = $(".innings-1-score.innings-current").html().trim();
//temp = temp.split(' ')[0].split('/')[1]; Uncomment this for just wicket notification
return temp;
}
currentWicket = findScore();
var myInterval = setInterval(function(){
wicket = findScore();
if(wicket != currentWicket){
currentWicket = wicket;
createNotification($(".innings-1-score.innings-current").html(), 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTLYZYdmOh5gPI5QMQWRaA9zBeb_jKJJA5iCaf0RoUeyMB0-3Yz49AhK5ib');
}
}, 1500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment