Skip to content

Instantly share code, notes, and snippets.

@azu
Created January 7, 2009 11:56
Show Gist options
  • Save azu/44257 to your computer and use it in GitHub Desktop.
Save azu/44257 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Mylist unwatch count
// @namespace http://web.zgo.jp/
// @include http://www.nicovideo.jp/mylist/*
// ==/UserScript==
(function() {
unsafeWindow.document.watch('title',
function(id, before, after) {
updateFavicon();
return after
});
var favicon = document.evaluate('//head/link[@rel="shortcut icon"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
var canvas = document.createElement('canvas');
var head = document.getElementsByTagName('head')[0];
function updateFavicon() {
var unread = document.evaluate('id("mylists")//tbody//tr', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).snapshotLength;
GM_log(unread);
canvas.width = canvas.height = 16;
with(canvas.getContext('2d')) {
clearRect(0, 0, 16, 16);
mozTextStyle = 22 + (unread.toString().length) * -4 + "px sans-serif";
translate(0, 14);
mozDrawText(unread);
}
favicon.href = canvas.toDataURL();
head.appendChild(favicon);
}
})();
//.user.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment