Open settings-page in new tab, from toolbar button
This commit is contained in:
parent
a10c4a9d21
commit
2a33fdaec1
|
@ -151,6 +151,11 @@
|
||||||
"description": "Name of button in options-page to save changes."
|
"description": "Name of button in options-page to save changes."
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"optionsPageTitle": {
|
||||||
|
"message": "Shellfox settings",
|
||||||
|
"description": "Title of the settings-page."
|
||||||
|
},
|
||||||
|
|
||||||
"errorPageTitle": {
|
"errorPageTitle": {
|
||||||
"message": "Shellfox error",
|
"message": "Shellfox error",
|
||||||
"description": "Title of the error-page."
|
"description": "Title of the error-page."
|
||||||
|
|
|
@ -151,6 +151,11 @@
|
||||||
"description": "Nomo de butono ĉe agordopaĝo por konservi ŝanĝojn."
|
"description": "Nomo de butono ĉe agordopaĝo por konservi ŝanĝojn."
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"optionsPageTitle": {
|
||||||
|
"message": "Ŝelvulpaj agordoj",
|
||||||
|
"description": "Titolo de agordo-paĝo."
|
||||||
|
},
|
||||||
|
|
||||||
"errorPageTitle": {
|
"errorPageTitle": {
|
||||||
"message": "Ŝelvulpo eraris"
|
"message": "Ŝelvulpo eraris"
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,6 +17,11 @@ function shellfoxFailed() {
|
||||||
port = undefined;
|
port = undefined;
|
||||||
|
|
||||||
// Tell the user about the error…
|
// Tell the user about the error…
|
||||||
|
openNewTab("/html/error.html?error=" + escape(error));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function openNewTab(url) {
|
||||||
browser.tabs.query({"active": true}).then((tabs) => {
|
browser.tabs.query({"active": true}).then((tabs) => {
|
||||||
let openerTab = undefined;
|
let openerTab = undefined;
|
||||||
if (tabs && tabs.length > 0)
|
if (tabs && tabs.length > 0)
|
||||||
|
@ -24,7 +29,7 @@ function shellfoxFailed() {
|
||||||
|
|
||||||
browser.tabs.create({
|
browser.tabs.create({
|
||||||
"active": true,
|
"active": true,
|
||||||
"url": "/html/error.html?error=" + escape(error),
|
"url": url,
|
||||||
"openerTabId": openerTab
|
"openerTabId": openerTab
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -266,6 +271,10 @@ browser.menus.onClicked.addListener((info, tab) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
browser.browserAction.onClicked.addListener(() => {
|
||||||
|
openNewTab("/html/options.html");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// When a download starts, run any applicable download commands.
|
// When a download starts, run any applicable download commands.
|
||||||
browser.downloads.onCreated.addListener((downloadItem) => {
|
browser.downloads.onCreated.addListener((downloadItem) => {
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
/* SPCSS theme by Susam Pal, under the MIT license
|
/* SPCSS theme by Susam Pal, under the MIT license
|
||||||
* https://github.com/susam/spcss */
|
* https://github.com/susam/spcss */
|
||||||
body{color:#333;font-family:helvetica,arial,sans-serif;line-height:1.5;margin:0 auto;max-width:40em;padding:0 1em}h1,h2,h3,h4,h5,h6{margin:1.25em 0 .5em;line-height:1.2}a:link{color:#00e}a:visited{color:#518}a:focus,a:hover{color:#03f}a:active{color:#e00}h1 a:empty:before,h2 a:empty:before,h3 a:empty:before,h4 a:empty:before,h5 a:empty:before,h6 a:empty:before{content:"#"}h1 a:empty,h2 a:empty,h3 a:empty,h4 a:empty,h5 a:empty,h6 a:empty{visibility:hidden;padding-left:.25em}h1:hover a:empty,h2:hover a:empty,h3:hover a:empty,h4:hover a:empty,h5:hover a:empty,h6:hover a:empty{visibility:visible}img{max-width:100%}figure{margin:1em 0;text-align:center}figcaption{font-size:small}code,kbd,pre,samp{color:#009;font-family:monospace,monospace}pre kbd{color:#060}blockquote,pre{background:#eee;padding:.5em}pre{overflow:auto}blockquote{border-left:medium solid #ccc;margin:1em 0}blockquote :first-child{margin-top:0}blockquote :last-child{margin-bottom:0}table{border-collapse:collapse}td,th{border:thin solid #999;padding:.3em .4em;text-align:left}@media (prefers-color-scheme:dark){body{background:#111;color:#bbb}a:link{color:#9bf}a:visited{color:#caf}a:focus,a:hover{color:#9cf}a:active{color:#faa}code,kbd,pre,samp{color:#6cf}pre kbd{color:#9c6}blockquote,pre{background:#000}blockquote{border-color:#333}td,th{border-color:#666}}
|
body{color:#333;font-family:helvetica,arial,sans-serif;line-height:1.5;margin:0 auto;max-width:40em;padding:0 1em}h1,h2,h3,h4,h5,h6{margin:1.25em 0 .5em;line-height:1.2}a:link{color:#00e}a:visited{color:#518}a:focus,a:hover{color:#03f}a:active{color:#e00}h1 a:empty:before,h2 a:empty:before,h3 a:empty:before,h4 a:empty:before,h5 a:empty:before,h6 a:empty:before{content:"#"}h1 a:empty,h2 a:empty,h3 a:empty,h4 a:empty,h5 a:empty,h6 a:empty{visibility:hidden;padding-left:.25em}h1:hover a:empty,h2:hover a:empty,h3:hover a:empty,h4:hover a:empty,h5:hover a:empty,h6:hover a:empty{visibility:visible}img{max-width:100%}figure{margin:1em 0;text-align:center}figcaption{font-size:small}code,kbd,pre,samp{color:#009;font-family:monospace,monospace}pre kbd{color:#060}blockquote,pre{background:#eee;padding:.5em}pre{overflow:auto}blockquote{border-left:medium solid #ccc;margin:1em 0}blockquote :first-child{margin-top:0}blockquote :last-child{margin-bottom:0}table{border-collapse:collapse}td,th{border:thin solid #999;padding:.3em .4em;text-align:left}@media (prefers-color-scheme:dark){body{background:#111;color:#bbb}a:link{color:#9bf}a:visited{color:#caf}a:focus,a:hover{color:#9cf}a:active{color:#faa}code,kbd,pre,samp{color:#6cf}pre kbd{color:#9c6}blockquote,pre{background:#000}blockquote{border-color:#333}td,th{border-color:#666}}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf8">
|
<meta charset="utf8">
|
||||||
|
<link rel="icon" type="image/png" href="../img/shellfox-32.png">
|
||||||
|
<title>Shellfox settings</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<article>
|
<article>
|
||||||
|
@ -19,7 +21,7 @@
|
||||||
|
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<h3 id="ruleTitle">URL/Page rules</h3>
|
<h4 id="ruleTitle">URL/Page rules</h4>
|
||||||
<p id="ruleP">Associate the above commands with URLs, based on regex rules. When a URL is tied to a command, a button will appear in context-menus and the address bar to run said command.</p>
|
<p id="ruleP">Associate the above commands with URLs, based on regex rules. When a URL is tied to a command, a button will appear in context-menus and the address bar to run said command.</p>
|
||||||
<table id="regexTable">
|
<table id="regexTable">
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -239,6 +239,7 @@ function createCommandTr(name, command) {
|
||||||
// Replace the HTML elements’ text with the extension’s translations.
|
// Replace the HTML elements’ text with the extension’s translations.
|
||||||
function i18nPage() {
|
function i18nPage() {
|
||||||
document.getElementsByTagName("html")[0].setAttribute("lang", browser.i18n.getMessage("@@ui_locale"));
|
document.getElementsByTagName("html")[0].setAttribute("lang", browser.i18n.getMessage("@@ui_locale"));
|
||||||
|
document.getElementsByTagName("title")[0].innerText = browser.i18n.getMessage("optionsPageTitle");
|
||||||
|
|
||||||
document.getElementById("commandTitle").innerText = browser.i18n.getMessage("optionsTitleShell");
|
document.getElementById("commandTitle").innerText = browser.i18n.getMessage("optionsTitleShell");
|
||||||
document.getElementById("commandP").innerText = browser.i18n.getMessage("optionsDescShell");
|
document.getElementById("commandP").innerText = browser.i18n.getMessage("optionsDescShell");
|
||||||
|
@ -280,3 +281,14 @@ populateCommandTable();
|
||||||
populateRegexTable();
|
populateRegexTable();
|
||||||
populateDownloadTable();
|
populateDownloadTable();
|
||||||
i18nPage();
|
i18nPage();
|
||||||
|
|
||||||
|
|
||||||
|
// Only add CSS if we’re not in the Firefox-embedded settings, but
|
||||||
|
// rather, in our own tab.
|
||||||
|
if (!(location.toString().includes("?in_ui"))) {
|
||||||
|
let cssElement = document.createElement("LINK");
|
||||||
|
cssElement.setAttribute("rel", "stylesheet");
|
||||||
|
cssElement.setAttribute("type", "text/css");
|
||||||
|
cssElement.setAttribute("href", "error.css");
|
||||||
|
document.getElementsByTagName("head")[0].appendChild(cssElement);
|
||||||
|
}
|
||||||
|
|
|
@ -5,13 +5,15 @@
|
||||||
|
|
||||||
"description": "__MSG_extensionDescription__",
|
"description": "__MSG_extensionDescription__",
|
||||||
"homepage_url": "https://hak.xwx.moe/jadedctrl/shellfox",
|
"homepage_url": "https://hak.xwx.moe/jadedctrl/shellfox",
|
||||||
|
"author": "Jaidyn Ann",
|
||||||
|
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
|
|
||||||
"icons": {
|
"icons": {
|
||||||
"250": "img/shellfox.png",
|
"512": "img/shellfox-512.png",
|
||||||
"38": "img/shellfox-38.png",
|
"48": "img/shellfox-48.png",
|
||||||
"19": "img/shellfox-19.png"
|
"32": "img/shellfox-32.png",
|
||||||
|
"16": "img/shellfox-16.png"
|
||||||
},
|
},
|
||||||
|
|
||||||
"page_action": {
|
"page_action": {
|
||||||
|
@ -23,6 +25,9 @@
|
||||||
"default_title": "__MSG_pageActionName__"
|
"default_title": "__MSG_pageActionName__"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"browser_action": {
|
||||||
|
},
|
||||||
|
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"activeTab",
|
"activeTab",
|
||||||
"downloads",
|
"downloads",
|
||||||
|
@ -45,6 +50,6 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
"options_ui": {
|
"options_ui": {
|
||||||
"page": "html/options.html"
|
"page": "html/options.html?in_ui"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ŝarĝante…
Reference in New Issue