forked from orbitbot/chrome-extensions-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
27 lines (23 loc) · 778 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
// Copyright (c) 2011 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({number: 1}, function() {
console.log('The number is set to 1.');
});
});
function updateIcon() {
chrome.storage.sync.get('number', function(data) {
var current = data.number;
chrome.browserAction.setIcon({path: 'icon' + current + '.png'});
current++;
if (current > 5)
current = 1;
chrome.storage.sync.set({number: current}, function() {
console.log('The number is set to ' + current);
});
});
};
chrome.browserAction.onClicked.addListener(updateIcon);
updateIcon();