-
Notifications
You must be signed in to change notification settings - Fork 0
/
ego_counter.js
49 lines (42 loc) · 1.31 KB
/
ego_counter.js
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
47
48
49
/*
* ステータスバーにはてブ数を表示
*
* Usage:
* let g:ego_counter_uri = 'Your site URI'
* or
* js liberator.globalVariables.ego_counter_hatenaId = 'Your site URI'
*
* ex.
* let g:ego_counter_uri = 'http://d.hatena.ne.jp/snaka72'
*
*/
(function() {
const MY_SITE = liberator.globalVariables.ego_counter_uri || '';
let update = function(color) {
myHatebu.setAttribute(
'src',
<>http://b.hatena.ne.jp/bc/{color}/{MY_SITE}/</>.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);
})()