Skip to content

Instantly share code, notes, and snippets.

@tomviner
Forked from seb-thomas/updated?
Last active December 13, 2015 21:38
Show Gist options
  • Save tomviner/4978671 to your computer and use it in GitHub Desktop.
Save tomviner/4978671 to your computer and use it in GitHub Desktop.
with console.logs
var YOUR_API_KEY = ''
var dateUpdated = "";
function changeTitle() {
var favi = jQuery('[rel="shortcut icon"]');
var titleDate = jQuery('p.author a').last().attr('title');
var reDate = /(\d+)\/(\d+)\/(\d+)/;
//Swap year and day, convert to Date obj
titleDate = (titleDate).replace(reDate, "$3/$2/$1");
titleDate = new Date(Date.parse(titleDate))
jQuery.get(
location.pathname + '.json',
{key: YOUR_API_KEY},
function(data){
dateUpdated = data.issue.updated_on;
dateUpdated = new Date(Date.parse(dateUpdated));
console.log(dateUpdated.getTime(), dateUpdated);
console.log(titleDate.getTime(), titleDate);
console.log('------------------------------------------------');
if (dateUpdated.getTime() > titleDate.getTime()) {
setTimeout(changeTitle, 3000);
favi.attr('href', 'http://cdn.dustball.com/time_add.png');
}
}
);
}
changeTitle()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment