-
Notifications
You must be signed in to change notification settings - Fork 0
/
github-help.js
57 lines (50 loc) · 1.23 KB
/
github-help.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
50
51
52
53
54
55
56
57
// Global variables for isolated world
var iconActive = false;
function toggle(){
// Show "on" icon when showing the help
if(iconActive == false){
activate();
} else{
deactivate();
}
}
function deactivate(){
iconActive = false;
chrome.tabs.executeScript(null, {file: "assets/jquery-2.1.1.min.js"}, function() {
chrome.tabs.executeScript(null, {file: "deactivate.js"});
chrome.browserAction.setIcon(
{
"path": {
19: "images/icon-19-" + "off" + ".png",
38: "images/icon-38-" + "off" + ".png"
}
}
);
});
}
function activate(){
iconActive = true;
chrome.browserAction.setIcon(
{
"path": {
19: "images/icon-19-" + "on" + ".png",
38: "images/icon-38-" + "on" + ".png"
}
}
);
chrome.tabs.executeScript(null, {file: "assets/jquery-2.1.1.min.js"}, function() {
chrome.tabs.executeScript(null, {file: "activate.js"});
});
}
//////////////////////////////////////
// Tab event bindings
//////////////////////////////////////
chrome.tabs.onUpdated.addListener(function(){
deactivate();
});
chrome.tabs.onRemoved.addListener(function(){
deactivate();
});
chrome.browserAction.onClicked.addListener(function(tab) {
toggle();
});