-
-
Save syoichi/954866 to your computer and use it in GitHub Desktop.
Firefox 4.0.1上のGreasemonkey 0.9.3、Scriptish 0.1で動作を確認した。Chrome 11.0.696.60ではfaviconを置き換えられないようで動作せず。
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
// ==UserScript== | |
// @name ldr favicon hack | |
// @namespace http://d.hatena.ne.jp/javascripter/ | |
// @include http://reader.livedoor.com/reader/ | |
// ==/UserScript== | |
document.getElementById('total_unread_count').addEventListener('DOMAttrModified', function () { | |
var canvas = document.createElement('canvas'), | |
ctx = canvas.getContext('2d'), | |
unread = unsafeWindow.subs.model.get_unread_count().toString(), | |
h = document.head, | |
favicon = h.querySelector('[rel*="icon"]'); | |
canvas.width = canvas.height = 16; | |
ctx.font = 22 + unread.length * -4 + 'px sans-serif'; | |
ctx.fillText(unread, 0, 13); | |
favicon.href = canvas.toDataURL(); | |
h.appendChild(favicon); | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment