通过chrome扩展打开网页

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
function Background () {
chrome.runtime.onInstalled.addListener(function (details) {
// only run the following section on install
if (details.reason !== "install") {
return;
}

chrome.tabs.create({
url: "https://webdesktop.net"
});
});
};

var background = new Background();

chrome.omnibox.onInputEntered.addListener(function (text) {
chrome.tabs.query({
'currentWindow': true,
'active' : true
}, function (tabs) {
chrome.tabs.update(tabs[0].id, {
url: "https://webdesktop.net"
});
});
});



chrome.browserAction.onClicked.addListener(function (activeTab) {
chrome.tabs.create({url: "https://webdesktop.net"});
});