-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcrossbrowser.js
48 lines (45 loc) · 999 Bytes
/
crossbrowser.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
function getActiveTabURL(callback)
{
if (typeof chrome !== 'undefined')
{
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
callback(tabs[0].url);
});
}
else
{
//firefox
callback(tabs.activeTab.url);
}
}
function openOptions()
{
if (typeof chrome !== 'undefined')
{
//yay chrome :D
if (typeof chrome.runtime.openOptionsPage == 'function')
{
chrome.runtime.openOptionsPage();
console.log(chrome.runtime.lastError);
}
else
{
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});
}
});
}
}
else
{
console.error("1");
//firefox... :(
//FIXME: hard coded, but don't have access to require() so wahtever
window.open('resource://imagefilter/options.html', '_newtab');
//tabs.open('resource://imagefilter/options.html');
}
}