-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.html
32 lines (32 loc) · 1013 Bytes
/
background.html
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
<html>
<head>
<script>
var show = {};
chrome.tabs.onUpdated.addListener(function(tabid, changeInfo, tab){
if (tab.url.match(/^http:\/\/news.ycombinator.com\/item/)){
chrome.pageAction.show(tabid);
show[tabid] = false;
}
});
chrome.pageAction.onClicked.addListener(function(tab){
if (show[tab.id] == false){
chrome.tabs.sendRequest(tab.id, {users: true, scores:true});
chrome.tabs.insertCSS(tab.id, {code:
".notvoted .user{display:inline;}" +
".notvoted .score{display:inline;}" +
".notvoted .between{display:inline;}"});
chrome.pageAction.setTitle({tabId:tab.id, title:"Hide all names / points"});
show[tab.id] = true;
} else {
chrome.tabs.sendRequest(tab.id, {users: true, scores:true});
chrome.tabs.insertCSS(tab.id, {code:
".notvoted .user{display:none;}" +
".notvoted .score{display:none;}" +
".notvoted .between{display:none;}"});
chrome.pageAction.setTitle({tabId:tab.id, title:"Show all names / points"});
show[tab.id] = false;
}
});
</script>
</head>
</html>