-
Notifications
You must be signed in to change notification settings - Fork 1
/
menu.js
33 lines (28 loc) · 1.19 KB
/
menu.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
var toggleBtn = document.querySelector('#toggle');
var enabled = true;
chrome.storage.local.get({ enabled: true }, function(items) {
enabled = items.enabled;
if(enabled) {
toggleBtn.innerText = 'Disable';
chrome.browserAction.setIcon({ path:"icon128.png" });
} else {
toggleBtn.innerText = 'Enable';
chrome.browserAction.setIcon({ path:"icon128disabled.png" });
}
document.querySelector('#toggle').addEventListener('click', function() {
if (toggleBtn.innerText == 'Enable') {
toggleBtn.innerText = 'Disable';
chrome.storage.local.set({ enabled: true });
chrome.browserAction.setIcon({ path: "icon128.png" }, function() { console.log("saved"); });
chrome.tabs.reload(function() { });
} else {
toggleBtn.innerText = 'Enable';
chrome.storage.local.set({ enabled: false }, function() { console.log("saved"); });
chrome.browserAction.setIcon({ path:"icon128disabled.png" });
chrome.tabs.reload(function() { });
}
});
});
document.querySelector('#settings').addEventListener('click', function() {
chrome.runtime.openOptionsPage();
});