-
Notifications
You must be signed in to change notification settings - Fork 273
/
launch.js
33 lines (32 loc) · 1.29 KB
/
launch.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
/**
* Make sure migrations don't run on the latest versions.
*/
chrome.runtime.onInstalled.addListener(function(details) {
localStorage.setItem('runtime.event', JSON.stringify(details));
if (details.reason == "install") {
console.info("This is a first install!");
localStorage.setItem('install.notify', chrome.runtime.getManifest().version);
/*
* example: localStorage.setItem('0.54.createtimers', 'done');
*/
} else if (details.reason == "update") {
var thisVersion = chrome.runtime.getManifest().version;
console.info("Updated from " + details.previousVersion + " to " + thisVersion + "!");
if (details.previousVersion != thisVersion) {
localStorage.setItem('install.notify', thisVersion);
}
};
});
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.getAllInWindow(undefined, function(tabs) {
for (var i = 0, tab; tab = tabs[i]; i++) {
if (tab.url.indexOf(chrome.extension.getURL('tab.html')) == 0) {
//console.debug('Found DuckieTV Tab');
chrome.tabs.update(tab.id, {selected: true});
return;
}
}
//console.debug('Could not find DuckieTV tab. Creating one...');
chrome.tabs.create({url: chrome.extension.getURL('tab.html')});
});
});