diff --git a/src/drivers/webextension/js/driver.js b/src/drivers/webextension/js/driver.js index eeda6b920..77a9b71cd 100644 --- a/src/drivers/webextension/js/driver.js +++ b/src/drivers/webextension/js/driver.js @@ -64,7 +64,7 @@ localStorage['version'] = version; } catch(e) { } - browser.runtime.onMessage.addListener(function(message, sender, sendResponse) { + function newMsg(message, sender, sendResponse) { var hostname, a = document.createElement('a'); @@ -105,7 +105,12 @@ break; } } - }); + } + if (typeof chrome === "undefined") { + browser.runtime.onMessage.addListener(newMsg); + } else { + chrome.runtime.onMessage.addListener(newMsg); + } browser.tabs.query({}).then(function(tabs) { tabs.forEach(function(tab) { diff --git a/src/drivers/webextension/js/popup.js b/src/drivers/webextension/js/popup.js index a5dd2cb61..4293aed21 100644 --- a/src/drivers/webextension/js/popup.js +++ b/src/drivers/webextension/js/popup.js @@ -30,7 +30,7 @@ document.addEventListener('DOMContentLoaded', function() { var appName, confidence, version; 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 ) { detectedApps.innerHTML = ''; @@ -59,7 +59,12 @@ document.addEventListener('DOMContentLoaded', function() { 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); + } }); } };