Skip to content

Instantly share code, notes, and snippets.

@qgustavor
Created July 23, 2015 19:35
Show Gist options
  • Save qgustavor/8315a3152a72d5040bc6 to your computer and use it in GitHub Desktop.
Save qgustavor/8315a3152a72d5040bc6 to your computer and use it in GitHub Desktop.
Quick Reddit Message Alert
var lastMessageId = '';
(function loop(){
$.getJSON('https://www.reddit.com/message/inbox.json',function(result){
var lastId = result.data.children[0].data.id;
if (lastMessageId !== lastId ) {
if (lastMessageId) {
alert('New message received');
} else {
console.log('Listening for new messages');
console.log('Last message id:', lastId);
}
lastMessageId = lastId;
}
setTimeout(loop, 5 * 60e3);
})}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment