1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 12:50:36 +01:00

Do not use browser.extension.getURL

This commit is contained in:
kkapsner 2021-11-01 13:18:38 +01:00
parent 6f5cfc1080
commit 7f154c6cc6
6 changed files with 20 additions and 14 deletions

View File

@ -63,20 +63,20 @@
const actionDefinitions = [ const actionDefinitions = [
{ {
label: "settings", label: "settings",
icon: browser.extension.getURL("icons/pageAction-showOptions.svg"), icon: extension.getURL("icons/pageAction-showOptions.svg"),
action: function(){ action: function(){
if (browser.runtime && browser.runtime.openOptionsPage){ if (browser.runtime && browser.runtime.openOptionsPage){
browser.runtime.openOptionsPage(); browser.runtime.openOptionsPage();
} }
else { else {
window.open(browser.extension.getURL("options/options.html"), "_blank"); window.open(extension.getURL("options/options.html"), "_blank");
} }
window.close(); window.close();
} }
}, },
{ {
label: "faq", label: "faq",
icon: browser.extension.getURL("icons/browserAction-faq.svg"), icon: extension.getURL("icons/browserAction-faq.svg"),
action: function(){ action: function(){
window.open("https://canvasblocker.kkapsner.de/faq/", "_blank"); window.open("https://canvasblocker.kkapsner.de/faq/", "_blank");
window.close(); window.close();
@ -85,7 +85,7 @@
{ {
label: "test", label: "test",
advanced: true, advanced: true,
icon: browser.extension.getURL("icons/browserAction-test.svg"), icon: extension.getURL("icons/browserAction-test.svg"),
action: function(){ action: function(){
window.open("https://canvasblocker.kkapsner.de/test", "_blank"); window.open("https://canvasblocker.kkapsner.de/test", "_blank");
window.close(); window.close();
@ -93,7 +93,7 @@
}, },
{ {
label: "review", label: "review",
icon: browser.extension.getURL("icons/browserAction-review.svg"), icon: extension.getURL("icons/browserAction-review.svg"),
action: function(){ action: function(){
window.open("https://addons.mozilla.org/firefox/addon/canvasblocker/reviews/", "_blank"); window.open("https://addons.mozilla.org/firefox/addon/canvasblocker/reviews/", "_blank");
window.close(); window.close();
@ -101,7 +101,7 @@
}, },
{ {
label: "reportIssue", label: "reportIssue",
icon: browser.extension.getURL("icons/browserAction-reportIssue.svg"), icon: extension.getURL("icons/browserAction-reportIssue.svg"),
action: function(){ action: function(){
window.open("https://github.com/kkapsner/CanvasBlocker/issues", "_blank"); window.open("https://github.com/kkapsner/CanvasBlocker/issues", "_blank");
window.close(); window.close();
@ -149,7 +149,7 @@
search.addEventListener("keypress", function(event){ search.addEventListener("keypress", function(event){
if ([10, 13].indexOf(event.keyCode) !== -1){ if ([10, 13].indexOf(event.keyCode) !== -1){
window.open(browser.extension.getURL( window.open(extension.getURL(
"options/options.html" + "options/options.html" +
"?search=" + "?search=" +
encodeURIComponent(this.value) encodeURIComponent(this.value)

View File

@ -72,7 +72,11 @@
return container; 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; scope.inIncognitoContext = browserAvailable? browser.extension.inIncognitoContext: false;

View File

@ -10,6 +10,7 @@
const persistentRndStorage = require("./persistentRndStorage"); const persistentRndStorage = require("./persistentRndStorage");
const notification = require("./notification"); const notification = require("./notification");
const mobile = require("./mobile"); const mobile = require("./mobile");
const extension = require("./extension");
const registerSettingsContentScript = (function(){ const registerSettingsContentScript = (function(){
let unregisterSettingsContentScript = function(){}; let unregisterSettingsContentScript = function(){};
@ -161,7 +162,7 @@
!browser.pageAction.openPopup !browser.pageAction.openPopup
){ ){
browser.tabs.create({ 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"); logging.message("CanvasBlocker installed");
openOptions(details.reason); openOptions(details.reason);
browser.tabs.create({ browser.tabs.create({
url: browser.extension.getURL("options/presets.html?notice=" + details.reason) url: extension.getURL("options/presets.html?notice=" + details.reason)
}); });
break; break;
case "update": case "update":

View File

@ -13,9 +13,10 @@
} }
const settings = require("./settings"); const settings = require("./settings");
const extension = require("./extension");
scope.init = function(page){ scope.init = function(page){
const basePath = browser.extension.getURL("themes"); const basePath = extension.getURL("themes");
const baseLink = document.createElement("link"); const baseLink = document.createElement("link");
baseLink.href = `${basePath}/base/layout.css`; baseLink.href = `${basePath}/base/layout.css`;

View File

@ -577,7 +577,7 @@
const version = document.createElement("div"); const version = document.createElement("div");
version.className = "version"; version.className = "version";
fetch(browser.extension.getURL("manifest.json")).then(function(response){ fetch(extension.getURL("manifest.json")).then(function(response){
return response.json(); return response.json();
}).then(function(manifest){ }).then(function(manifest){
version.textContent = "Version " + manifest.version; version.textContent = "Version " + manifest.version;

View File

@ -30,7 +30,7 @@
browser.runtime.openOptionsPage(); browser.runtime.openOptionsPage();
} }
else { else {
window.open(browser.extension.getURL("options/options.html"), "_blank"); window.open(extension.getURL("options/options.html"), "_blank");
} }
} }
}, },
@ -152,7 +152,7 @@
isIcon: true, isIcon: true,
callback: function({domain, urls}){ callback: function({domain, urls}){
window.open( window.open(
browser.extension.getURL( extension.getURL(
"options/whitelist.html?domain=" + "options/whitelist.html?domain=" +
encodeURIComponent(domain) + encodeURIComponent(domain) +
"&urls=" + "&urls=" +