forked from mak08/VRDashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
38 lines (28 loc) · 1 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
// Copyright (c) 2012 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.
var version = "1.0";
chrome.pageAction.onClicked.addListener(function(tab) {
chrome.debugger.attach({tabId:tab.id}, version, onAttach.bind(null, tab.id));
});
function checkForValidUrl(tabId, changeInfo, tabInfo) {
if (tabInfo.url.indexOf('virtualregatta.com') >= 0) {
chrome.pageAction.show(tabId);
}
};
chrome.tabs.onUpdated.addListener(checkForValidUrl);
// mostly useful for development - enable page action after
// ext reload
chrome.tabs.onActivated.addListener(function(activeInfo) {
chrome.tabs.get(activeInfo.tabId, function (tab) {
checkForValidUrl(activeInfo.tabId,null,tab);
});
});
function onAttach(tabId) {
if (chrome.runtime.lastError) {
alert(chrome.runtime.lastError.message);
return;
}
chrome.tabs.create(
{url: "dashboard.html?" + tabId, active: false});
}