-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackgroundJs.js
33 lines (33 loc) · 898 Bytes
/
backgroundJs.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
chrome.runtime.onMessage.addListener(callback);
function callback(request, sender, sendRsponse) {
console.log("onMessage");
var cmd = request.cmd;
if (cmd == "new page")
{
var day = request.day;
var preday = localStorage["day"];
newTabObj =
{
"url": "http://wenku.baidu.com/task/browse/daily"
}
if (preday == day) {
//alert("yes");
}
else {
//alert("no");
chrome.tabs.create(newTabObj);
localStorage["day"] = day;
}
}
else if(cmd=="close page")
{
var queryInfo=
{
"active": true
}
//chrome.tabs.query(queryInfo,function(tabs){chrome.tabs.remove(tabs[0].id);})
//var numId=new Number(sender.id);
var fromTab=sender.tab;
chrome.tabs.remove(fromTab.id);
}
}