diff options
author | snaka | 2009-08-28 22:58:57 +0000 |
---|---|---|
committer | snaka | 2009-08-28 22:58:57 +0000 |
commit | bec0695adeaf60e51b37f97647c81adfa03135e0 (patch) | |
tree | 1260ad20e566e589f74644758b760f10a35cbf80 /ego_counter.js | |
parent | 9f691e05aae8b0ad1c4f3fe559b0f2f2c9559ea2 (diff) | |
download | vimperator-plugins-bec0695adeaf60e51b37f97647c81adfa03135e0.tar.bz2 |
Add new plugin for Egoist.
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@35119 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'ego_counter.js')
-rw-r--r-- | ego_counter.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/ego_counter.js b/ego_counter.js new file mode 100644 index 0000000..4a5b061 --- /dev/null +++ b/ego_counter.js @@ -0,0 +1,46 @@ +/* + * $B%9%F!<%?%9%P!<$K$O$F%V?t$rI=<((B + * + * Usage: + * let g:ego_counter_hatenaId = 'Your hatena ID' + * or + * js liberator.globalVariables.ego_counter_hatenaId = 'Your hatena ID' + * + */ +(function() { + + const MY_ID = liberator.globalVariables.ego_counter_hatenaId || ''; + let update = function(color) { + myHatebu.setAttribute( + 'src', + <>http://b.hatena.ne.jp/bc/{color}/http://d.hatena.ne.jp/{MY_ID}/</>.toSource() + ); + }; + + let rotate = (function() { + var current; + var colors = "bl de dg gr pr br rd sp pk te lg lb wh li or".split(" "); + + return function(next) { + if (!next) return current; + + current = colors.shift(); + colors.push(current); + return current; + }; + })(); + + let myHatebu = document.getElementById('status-bar') + .insertBefore(document.createElement('statusbarpanel'), + document.getElementById('security-button') + .nextSibling); + myHatebu.setAttribute('id', 'my-hatebu-count-icon'); + myHatebu.setAttribute('class', 'statusbarpanel-iconic'); + update(rotate(true)); + + setInterval(function() update(rotate(true)), 1000 * 60 * 10); + myHatebu.addEventListener("click", function(event){ + update(rotate(true)); + }, false); + +})() |