1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 04:40:20 +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 = [
{
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)

View File

@ -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;

View File

@ -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":

View File

@ -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`;

View File

@ -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;

View File

@ -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=" +