Open settings-page in new tab, from toolbar button

This commit is contained in:
Jaidyn Ann 2024-03-09 01:40:14 -06:00
parent a10c4a9d21
commit 2a33fdaec1
7 changed files with 52 additions and 6 deletions

View File

@ -151,6 +151,11 @@
"description": "Name of button in options-page to save changes."
},
"optionsPageTitle": {
"message": "Shellfox settings",
"description": "Title of the settings-page."
},
"errorPageTitle": {
"message": "Shellfox error",
"description": "Title of the error-page."

View File

@ -151,6 +151,11 @@
"description": "Nomo de butono ĉe agordopaĝo por konservi ŝanĝojn."
},
"optionsPageTitle": {
"message": "Ŝelvulpaj agordoj",
"description": "Titolo de agordo-paĝo."
},
"errorPageTitle": {
"message": "Ŝelvulpo eraris"
},

View File

@ -17,6 +17,11 @@ function shellfoxFailed() {
port = undefined;
// Tell the user about the error…
openNewTab("/html/error.html?error=" + escape(error));
}
function openNewTab(url) {
browser.tabs.query({"active": true}).then((tabs) => {
let openerTab = undefined;
if (tabs && tabs.length > 0)
@ -24,7 +29,7 @@ function shellfoxFailed() {
browser.tabs.create({
"active": true,
"url": "/html/error.html?error=" + escape(error),
"url": url,
"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.
browser.downloads.onCreated.addListener((downloadItem) => {

View File

@ -1,3 +1,11 @@
/* SPCSS theme by Susam Pal, under the MIT license
* 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}}
table {
width: 100%;
}
input {
width: 100%;
}

View File

@ -2,6 +2,8 @@
<html>
<head>
<meta charset="utf8">
<link rel="icon" type="image/png" href="../img/shellfox-32.png">
<title>Shellfox settings</title>
</head>
<body>
<article>
@ -19,7 +21,7 @@
<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>
<table id="regexTable">
<tr>

View File

@ -239,6 +239,7 @@ function createCommandTr(name, command) {
// Replace the HTML elements text with the extensions translations.
function i18nPage() {
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("commandP").innerText = browser.i18n.getMessage("optionsDescShell");
@ -280,3 +281,14 @@ populateCommandTable();
populateRegexTable();
populateDownloadTable();
i18nPage();
// Only add CSS if were 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);
}

View File

@ -5,13 +5,15 @@
"description": "__MSG_extensionDescription__",
"homepage_url": "https://hak.xwx.moe/jadedctrl/shellfox",
"author": "Jaidyn Ann",
"default_locale": "en",
"icons": {
"250": "img/shellfox.png",
"38": "img/shellfox-38.png",
"19": "img/shellfox-19.png"
"512": "img/shellfox-512.png",
"48": "img/shellfox-48.png",
"32": "img/shellfox-32.png",
"16": "img/shellfox-16.png"
},
"page_action": {
@ -23,6 +25,9 @@
"default_title": "__MSG_pageActionName__"
},
"browser_action": {
},
"permissions": [
"activeTab",
"downloads",
@ -45,6 +50,6 @@
},
"options_ui": {
"page": "html/options.html"
"page": "html/options.html?in_ui"
}
}