-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
30 lines (27 loc) · 873 Bytes
/
background.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
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
var toggle = true;
chrome.storage.sync.get("toggle", function (result) {
if (result.toggle != undefined) toggle = result.toggle;
if (toggle){
chrome.browserAction.setIcon({path: "images/on.png"});
}
else{
chrome.browserAction.setIcon({path: "images/off.png"});
}
});
chrome.browserAction.onClicked.addListener(function(tab) {
toggle = !toggle;
console.log('toggle : ' + toggle);
if(toggle){
chrome.browserAction.setIcon({path: "images/on.png"});
}
else{
chrome.browserAction.setIcon({path: "images/off.png"});
}
chrome.storage.sync.set({'toggle': toggle}, function(){
console.log('toggle changed : ' + toggle);
});
});