-
Notifications
You must be signed in to change notification settings - Fork 10
/
background.js
31 lines (23 loc) · 906 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
31
// 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';
chrome.runtime.onInstalled.addListener(function() {
chrome.storage.sync.set({status: 'on'}, function() { });
});
function updateDarkdocs() {
chrome.storage.sync.get('status', function(data) {
var current = data.status;
if (current == 'off') {
current = 'on';
} else {
current = 'off';
}
chrome.browserAction.setIcon({path: 'icon' + (current == 'off' ? 'off' : '') + '.png'});
chrome.storage.sync.set({ status: current }, function() { });
chrome.tabs.query({ active: true, currentWindow: true }, function(tabs){
chrome.tabs.sendMessage(tabs[0].id, { command: current }, function(response) {});
});
});
};
chrome.browserAction.onClicked.addListener(updateDarkdocs);