-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbackground.js
63 lines (53 loc) · 1.33 KB
/
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
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
// 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.
// Called when the user clicks on the browser action.
var timer = null;
chrome.browserAction.onClicked.addListener(function(tab) {
// chrome.browserAction.getBadgeText({},function(txt){
// if (txt != 'on') {
// switchOn()
// } else {
// switchOff()
// }
// })
});
function switchOn(argument) {
// chrome.tabs.query({
// currentWindow: true
// }, function(tabs) {
// console.log(tabs.length)
// for (var i in tabs) {
// // reload(tabs[i])
// }
// });
chrome.browserAction.setIcon({
path: "icon2.png"
});
chrome.browserAction.setBadgeText({
'text':'on'
})
}
function switchOff(argument) {
clearInterval(timer)
chrome.browserAction.setIcon({
path: "icon.png"
});
chrome.browserAction.setBadgeText({
'text':'off'
})
}
var code = 'window.location.reload();';
function reload(tab) {
var url = tab.url
if (url.indexOf("dev.xxzhushou.cn/versionList.html") == -1) {
return;
}
if (timer) {
clearInterval(timer);
}
timer = setInterval(function(){
console.log('reload')
chrome.tabs.executeScript(tab.id, {code: code});
},30 * 1000)
}