diff --git a/browserAction/browserAction.js b/browserAction/browserAction.js index e946b00..0a54ba0 100644 --- a/browserAction/browserAction.js +++ b/browserAction/browserAction.js @@ -63,20 +63,20 @@ const actionDefinitions = [ { label: "settings", - icon: browser.extension.getURL("icons/pageAction-showOptions.svg"), + icon: extension.getURL("icons/pageAction-showOptions.svg"), action: function(){ if (browser.runtime && browser.runtime.openOptionsPage){ browser.runtime.openOptionsPage(); } else { - window.open(browser.extension.getURL("options/options.html"), "_blank"); + window.open(extension.getURL("options/options.html"), "_blank"); } window.close(); } }, { label: "faq", - icon: browser.extension.getURL("icons/browserAction-faq.svg"), + icon: extension.getURL("icons/browserAction-faq.svg"), action: function(){ window.open("https://canvasblocker.kkapsner.de/faq/", "_blank"); window.close(); @@ -85,7 +85,7 @@ { label: "test", advanced: true, - icon: browser.extension.getURL("icons/browserAction-test.svg"), + icon: extension.getURL("icons/browserAction-test.svg"), action: function(){ window.open("https://canvasblocker.kkapsner.de/test", "_blank"); window.close(); @@ -93,7 +93,7 @@ }, { label: "review", - icon: browser.extension.getURL("icons/browserAction-review.svg"), + icon: extension.getURL("icons/browserAction-review.svg"), action: function(){ window.open("https://addons.mozilla.org/firefox/addon/canvasblocker/reviews/", "_blank"); window.close(); @@ -101,7 +101,7 @@ }, { label: "reportIssue", - icon: browser.extension.getURL("icons/browserAction-reportIssue.svg"), + icon: extension.getURL("icons/browserAction-reportIssue.svg"), action: function(){ window.open("https://github.com/kkapsner/CanvasBlocker/issues", "_blank"); window.close(); @@ -149,7 +149,7 @@ search.addEventListener("keypress", function(event){ if ([10, 13].indexOf(event.keyCode) !== -1){ - window.open(browser.extension.getURL( + window.open(extension.getURL( "options/options.html" + "?search=" + encodeURIComponent(this.value) diff --git a/lib/extension.js b/lib/extension.js index 38b4e02..bd21d81 100644 --- a/lib/extension.js +++ b/lib/extension.js @@ -72,7 +72,11 @@ return container; }; - scope.extensionID = browserAvailable? browser.extension.getURL(""): "extensionID"; + scope.getURL = function getURL(str){ + return (browser.runtime.getURL? browser.runtime.getURL: browser.extension.getURL)(str); + }; + + scope.extensionID = browserAvailable? scope.getURL(""): "extensionID"; scope.inIncognitoContext = browserAvailable? browser.extension.inIncognitoContext: false; diff --git a/lib/main.js b/lib/main.js index 1c38902..fc3c63b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -10,6 +10,7 @@ const persistentRndStorage = require("./persistentRndStorage"); const notification = require("./notification"); const mobile = require("./mobile"); + const extension = require("./extension"); const registerSettingsContentScript = (function(){ let unregisterSettingsContentScript = function(){}; @@ -161,7 +162,7 @@ !browser.pageAction.openPopup ){ browser.tabs.create({ - url: browser.extension.getURL("options/options.html?notice=" + reason) + url: extension.getURL("options/options.html?notice=" + reason) }); } } @@ -170,7 +171,7 @@ logging.message("CanvasBlocker installed"); openOptions(details.reason); browser.tabs.create({ - url: browser.extension.getURL("options/presets.html?notice=" + details.reason) + url: extension.getURL("options/presets.html?notice=" + details.reason) }); break; case "update": diff --git a/lib/theme.js b/lib/theme.js index 995912f..437fc14 100644 --- a/lib/theme.js +++ b/lib/theme.js @@ -13,9 +13,10 @@ } const settings = require("./settings"); + const extension = require("./extension"); scope.init = function(page){ - const basePath = browser.extension.getURL("themes"); + const basePath = extension.getURL("themes"); const baseLink = document.createElement("link"); baseLink.href = `${basePath}/base/layout.css`; diff --git a/options/options.js b/options/options.js index c156dcb..e0507a9 100644 --- a/options/options.js +++ b/options/options.js @@ -577,7 +577,7 @@ const version = document.createElement("div"); version.className = "version"; - fetch(browser.extension.getURL("manifest.json")).then(function(response){ + fetch(extension.getURL("manifest.json")).then(function(response){ return response.json(); }).then(function(manifest){ version.textContent = "Version " + manifest.version; diff --git a/pageAction/pageAction.js b/pageAction/pageAction.js index ad1b080..18bd555 100644 --- a/pageAction/pageAction.js +++ b/pageAction/pageAction.js @@ -30,7 +30,7 @@ browser.runtime.openOptionsPage(); } else { - window.open(browser.extension.getURL("options/options.html"), "_blank"); + window.open(extension.getURL("options/options.html"), "_blank"); } } }, @@ -152,7 +152,7 @@ isIcon: true, callback: function({domain, urls}){ window.open( - browser.extension.getURL( + extension.getURL( "options/whitelist.html?domain=" + encodeURIComponent(domain) + "&urls=" +