-
Notifications
You must be signed in to change notification settings - Fork 54
/
menu-script.js
64 lines (45 loc) · 1.79 KB
/
menu-script.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
58
59
60
61
62
63
64
var api;
if (chrome == undefined) {
api = browser;
} else {
api = chrome;
}
if(!TRACKMENOT) var TRACKMENOT = {};
TRACKMENOT.Menus = function() {
var options = null;
function _cout (msg) { console.log(msg); }
return {
showHelp: function() {
window.open("http://www.cs.nyu.edu/trackmenot/faq.html")
},
toggleOnOff: function() {
options.enabled = !options.enabled
api.storage.local.set({"options_tmn":options});
TRACKMENOT.Menus.onLoadMenu({"options_tmn":options});
},
toggleTabFrame: function() {
options.useTab = !options.useTab
api.storage.local.set({"options_tmn":options});
TRACKMENOT.Menus.onLoadMenu({"options_tmn":options});
},
onLoadMenu: function( items ) {
options = items["options_tmn"];
if ( options.enabled) {
$("#trackmenot-enabled").html('Disable');
$("#trackmenot-img-enabled").attr("src", "images/skin/off_icon.png");
} else {
$("#trackmenot-enabled").html('Enable');
$("#trackmenot-img-enabled").attr("src", "images/skin/on_icon.png");
}
if (options.useTab) $("#trackmenot-menu-useTab").html('<img width="16" height="16" src="images/skin/stealth_icon.png" /> Stealth');
else $("#trackmenot-menu-useTab").html('<img width="16" height="16" src="images/skin/tab_icon.png" /> Tab')
}
}
}();
document.addEventListener('DOMContentLoaded', function () {
$("#trackmenot-menu-useTab").click(TRACKMENOT.Menus.toggleTabFrame);
$("#trackmenot-enabled").click(TRACKMENOT.Menus.toggleOnOff);
$("#trackmenot-menu-win").click(function() { window.open(api.extension.getURL('options.html'));});
$("#trackmenot-menu-help").click(TRACKMENOT.Menus.showHelp)
api.storage.local.get(["options_tmn"],TRACKMENOT.Menus.onLoadMenu)
});