diff --git a/_locales/en/messages.json b/_locales/en/messages.json index e92c8b6..e3a790c 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -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." diff --git a/_locales/eo/messages.json b/_locales/eo/messages.json index 25ff21f..300942d 100644 --- a/_locales/eo/messages.json +++ b/_locales/eo/messages.json @@ -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" }, diff --git a/background.js b/background.js index 60729b4..5166dfe 100644 --- a/background.js +++ b/background.js @@ -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.action.onClicked.addListener(() => { + openNewTab("/html/options.html"); +}); + // When a download starts, run any applicable download commands. browser.downloads.onCreated.addListener((downloadItem) => { diff --git a/html/error.css b/html/error.css index 2349f0b..989cd0c 100644 --- a/html/error.css +++ b/html/error.css @@ -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%; +} diff --git a/html/options.html b/html/options.html index 2532fd3..c9d6778 100644 --- a/html/options.html +++ b/html/options.html @@ -2,6 +2,8 @@ + + Shellfox settings
@@ -19,7 +21,7 @@
-

URL/Page rules

+

URL/Page rules

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.

diff --git a/html/options.js b/html/options.js index e8082fa..ce1a0dd 100644 --- a/html/options.js +++ b/html/options.js @@ -239,6 +239,7 @@ function createCommandTr(name, command) { // Replace the HTML elements’ text with the extension’s 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 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); +} diff --git a/manifest.json b/manifest.json index 9b6d492..cba52c5 100644 --- a/manifest.json +++ b/manifest.json @@ -1,17 +1,19 @@ { - "manifest_version": 2, + "manifest_version": 3, "name": "__MSG_extensionName__", "version": "0.12", "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__" }, + "action": { + }, + "permissions": [ "activeTab", "downloads", @@ -45,6 +50,6 @@ }, "options_ui": { - "page": "html/options.html" + "page": "html/options.html?in_ui" } }