blob: 4a5b06199acf9e437a34abff3ddbd4a90d1d9ae0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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);
})()
|