Skip to content

Instantly share code, notes, and snippets.

@seb-thomas
Forked from tomviner/updated?
Last active December 13, 2015 21:38
Show Gist options
  • Select an option

  • Save seb-thomas/4978749 to your computer and use it in GitHub Desktop.

Select an option

Save seb-thomas/4978749 to your computer and use it in GitHub Desktop.
var dateUpdated = "";
var reDate = /(\d+)\/(\d+)\/(\d+)/;
var titleDate = jQuery('p.author a').last().attr('title');
var favi = jQuery('[rel="shortcut icon"]');
//Swap year and day, convert to Date obj
titleDate = (titleDate).replace(reDate, "$3/$2/$1");
titleDate = new Date(titleDate);
function changeTitle() {
jQuery.get(
location.pathname + '.json',
function(data){
dateUpdated = data.issue.updated_on;
dateUpdated = new Date(dateUpdated);
dateUpdated.setSeconds(0);
console.log(dateUpdated.getTime(), dateUpdated, ' Time stamp on server');
console.log(titleDate.getTime(), titleDate);
console.log('------------------------------------------------');
if (dateUpdated.getTime() > titleDate.getTime()) {
//If theres a time diff, change the favicon
favi.attr('href', 'http://cdn.dustball.com/time_add.png');
}else{
//If not, keep checking, dammit!
setTimeout(changeTitle, 30000);
}
}
);
}
changeTitle()
@jaymzcd
Copy link

jaymzcd commented Feb 19, 2013

Set the syntax to javascript!

@seb-thomas
Copy link
Author

I cannot! Don't know why, syntax selector is disabled.
Made another one. Hopefully that fixes the name too
https://gist.github.com/sebastianthomas/4984941#file-gistfile1-js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment