-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
52 lines (42 loc) · 1.31 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
if (localStorage["install1"] == undefined)
{
chrome.tabs.create({url:'options.html'});
localStorage["install1"] = "true";
}
chrome.browserAction.onClicked.addListener(function() {
abreExtension(localStorage['extElegida']);
});
chrome.tabs.onUpdated.addListener(function(tabId,changeInfo,tab) {
var newTabExt = esTabNewTab(tabId);
if (newTabExt != '')
{
if (tab.url.indexOf('chrome') == -1)
{
quitaTab(tabId);
if (newTabExt.extId && !newTabExt.extEnabled) chrome.management.setEnabled(newTabExt.extId, false);
}
}
})
chrome.tabs.onRemoved.addListener(function(tabId)
{
var newTabExt = esTabNewTab(tabId);
if (newTabExt != '')
{
quitaTab(tabId);
if (newTabExt.extId && !newTabExt.extEnabled) chrome.management.setEnabled(newTabExt.extId, false);
}
});
chrome.management.onInstalled.addListener(function(extinfo){
console.log(extinfo);
if (esExtensionNewtab(extinfo.id))
{
var optionsUrl = chrome.extension.getURL('options.html');
chrome.tabs.query({url: optionsUrl}, function(tabs) {
if (tabs.length) {
chrome.tabs.update(tabs[0].id, {active: true});
} else {
chrome.tabs.create({url: optionsUrl});
}
});
}
});