-
-
Save tomviner/4978671 to your computer and use it in GitHub Desktop.
with console.logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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