Skip to content

Instantly share code, notes, and snippets.

@tobbez
Created February 19, 2011 00:31
Show Gist options
  • Save tobbez/834670 to your computer and use it in GitHub Desktop.
Save tobbez/834670 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Notifications in title
// @namespace tobbez
// @description Notifications in title
// @include http*://*what.cd/*
// ==/UserScript==
(function () {
var re = /You have (\d+) new torrent notifications/
, orig_title = document.title;
function set_title (doc) {
var res = re.exec(doc);
if (res.length > 1)
document.title = orig_title + ' (' + res[1] + ')';
}
function update_count () {
var xhr = new XMLHttpRequest();
xhr.open('GET', document.location.protocol + '//' + document.location.host,
false);
xhr.send(null);
set_title(xhr.responseText);
}
set_title(document.getElementById('alerts').innerHTML);
setInterval(update_count, 600000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment