Merge pull request #1431 from DaAwesomeP/master

Fix WebExtension in Chrome-based Browsers
main
Elbert Alias 8 years ago committed by GitHub
commit 51b598cd65

5
.gitignore vendored

@ -9,3 +9,8 @@ npm-debug.log
tags tags
!.gitkeep !.gitkeep
Thumbs.db
Desktop.ini
*.DS_Store
._*

@ -64,7 +64,7 @@
localStorage['version'] = version; localStorage['version'] = version;
} catch(e) { } } catch(e) { }
browser.runtime.onMessage.addListener(function(message, sender, sendResponse) { function newMsg(message, sender, sendResponse) {
var var
hostname, hostname,
a = document.createElement('a'); a = document.createElement('a');
@ -105,7 +105,12 @@
break; break;
} }
} }
}); }
if (typeof chrome === "undefined") {
browser.runtime.onMessage.addListener(newMsg);
} else {
chrome.runtime.onMessage.addListener(newMsg);
}
browser.tabs.query({}).then(function(tabs) { browser.tabs.query({}).then(function(tabs) {
tabs.forEach(function(tab) { tabs.forEach(function(tab) {

@ -30,7 +30,7 @@ document.addEventListener('DOMContentLoaded', function() {
var appName, confidence, version; var appName, confidence, version;
browser.tabs.query({ active: true }).then(function(tabs) { browser.tabs.query({ active: true }).then(function(tabs) {
browser.runtime.sendMessage({ id: 'get_apps', tab: tabs[0] }, function(response) { function sendGetApps(response) {
if ( response.tabCache && response.tabCache.count > 0 ) { if ( response.tabCache && response.tabCache.count > 0 ) {
detectedApps.innerHTML = ''; detectedApps.innerHTML = '';
@ -59,7 +59,12 @@ document.addEventListener('DOMContentLoaded', function() {
detectedApps.innerHTML = detectedApps.innerHTML + html; detectedApps.innerHTML = detectedApps.innerHTML + html;
} }
} }
}); }
if (typeof chrome === "undefined") {
browser.runtime.sendMessage({ id: 'get_apps', tab: tabs[0] }, sendGetApps);
} else {
chrome.runtime.sendMessage({ id: 'get_apps', tab: tabs[0] }, sendGetApps);
}
}); });
} }
}; };

@ -36,7 +36,10 @@
"web_accessible_resources": [ "web_accessible_resources": [
"js/inject.js" "js/inject.js"
], ],
"options_page": "options.html", "options_ui": {
"page": "options.html",
"open_in_tab": false
},
"permissions": [ "permissions": [
"tabs", "tabs",
"webRequest", "webRequest",

Loading…
Cancel
Save