Compare commits

...

3 Enmetoj

Author SHA1 Message Date
Jaidyn Ann 74735233b0 Add TabFS recommendation to README
Also folds lines to ~80 chars (excepting links).
2024-05-06 09:50:07 -05:00
Jaidyn Ann e721fcbc18 Bump version 2024-04-02 11:59:05 -05:00
Jaidyn Ann da847fc55c Also substitute referrer-URL into commands
… as the variable $REFERRER.
2024-03-12 17:55:16 -05:00
6 changed files with 27 additions and 17 deletions

View File

@ -1,16 +1,19 @@
# ![](img/shellfox-32.png) Shellfox # ![](img/shellfox-32.png) Shellfox
[Shellfox](https://hak.xwx.moe/jadedctrl/shellfox) is a simple add-on for [Firefox](https://firefox.com) that allows you to run shell commands at the click of a button. [Shellfox](https://hak.xwx.moe/jadedctrl/shellfox) is a simple add-on for [Firefox](https://firefox.com) that allows you to run shell
commands at the click of a button.
<img alt="Screenshot of Shellfox." width=555px src="img/screenshot-youtube.png"> <img alt="Screenshot of Shellfox." width=555px src="img/screenshot-youtube.png">
## Installation ## Installation
Shellfox has two components: A Firefox extension, and a native script that the extension uses to run commands. Shellfox has two components: A Firefox extension, and a native script that the
extension uses to run commands.
You can install the Firefox extension from [Firefox Add-ons (AMO)](https://addons.mozilla.org/en-US/firefox/addon/shellfox). You can install the Firefox extension from [Firefox Add-ons (AMO)](https://addons.mozilla.org/en-US/firefox/addon/shellfox).
The native script has only been tested on GNU/Linux, though it is likely to work on BSDs, and potentially macOS. It can be installed like so: The native script has only been tested on GNU/Linux, though it is likely to work
on BSDs, and potentially macOS. It can be installed like so:
1. Download the repository: [master.zip](https://hak.xwx.moe/jadedctrl/shellfox/archive/master.zip) 1. Download the repository: [master.zip](https://hak.xwx.moe/jadedctrl/shellfox/archive/master.zip)
2. Extract the ZIP-archive; this will make a folder called `shellfox/`. 2. Extract the ZIP-archive; this will make a folder called `shellfox/`.
@ -31,7 +34,11 @@ $ sudo make native-install
## Related projects ## Related projects
This add-on was inspired by [Textern](https://github.com/jlebon/textern/), which allows you to edit text-boxes with an external editor like [Emacs](https://gnu.org/software/emacs). Its very useful, I highly recommend it! This add-on was inspired by [Textern](https://github.com/jlebon/textern/), which allows you to edit text-boxes
with an external editor like [Emacs](https://gnu.org/software/emacs). Its very useful, I highly recommend it!
If you like mixing web-browsing with shell, then youll probably also like
[TabFS](https://omar.website/tabfs/), a FUSE filesystem that exposes your browser tabs as files.
## Source code ## Source code

View File

@ -107,7 +107,7 @@
}, },
"optionsDescDownload": { "optionsDescDownload": {
"message": "Assign commands to be executed for certain URLs (by regex) when downloads are initiated or finished. In commands, $URL will be replaced with the downloads URL, and $FILE with the target file.", "message": "Assign commands to be executed for certain URLs (by regex) when downloads are initiated or finished. In commands, $FILE will be replaced with the target file, $URL will be replaced with the downloads URL, and $REFERRER with the referring URL.",
"description": "Description of options-page section for download commands." "description": "Description of options-page section for download commands."
}, },

View File

@ -107,7 +107,7 @@
}, },
"optionsDescDownload": { "optionsDescDownload": {
"message": "Agordi ordonojn kiuj ruliĝu dum komenciĝo aŭ finiĝo de elŝutado, laŭ URL (regulesprime). En ordonoj, «$URL» anstataŭiĝos per la elŝuta URL, kaj «$FILE» per la elŝuta dosiervojo.", "message": "Agordi ordonojn kiuj ruliĝu dum komenciĝo aŭ finiĝo de elŝutado, laŭ URL (regulesprime). En ordonoj, «$FILE» anstataŭiĝos per la elŝuta dosiervojo, «$URL» anstataŭiĝos per la elŝuta URL, kaj «$REFERRER» per la deelŝutita URL.",
"description": "Priskribo de agordo-parto por elŝutaj ordonoj." "description": "Priskribo de agordo-parto por elŝutaj ordonoj."
}, },

View File

@ -99,25 +99,27 @@ function getDownloadCommand(url, type) {
} }
// Execute the given command string, subsituting “$URL” with url and // Execute the given command string, subsituting “$URL” with url,
// “$FILE” with filepath. // “$FILE” with filepath, and “$REFERRER” with referrer.
function runCommand(command, url, filepath) { function runCommand(command, url, filepath, referrer) {
if (!port) if (!port)
initShellfoxProgram(); initShellfoxProgram();
if (command && port) if (command && port)
port.postMessage(command port.postMessage(command
.replaceAll("$URL", url) .replaceAll("$URL", url)
.replaceAll("${URL}", url) .replaceAll("${URL}", url)
.replaceAll("$REFERRER", referrer || "")
.replaceAll("${REFERRER}", referrer || "")
.replaceAll("$FILE", filepath) .replaceAll("$FILE", filepath)
.replaceAll("${FILE}", filepath)); .replaceAll("${FILE}", filepath));
} }
// Execute the shell command associated with the given URL, if any. // Execute the shell command associated with the given URL, if any.
function runUrlCommand(url) { function runUrlCommand(url, referrer) {
let commands = getUrlCommands(url); let commands = getUrlCommands(url);
if (commands) if (commands)
runCommand(commands[0], url); runCommand(commands[0], url, "", referrer);
} }
@ -264,10 +266,10 @@ browser.menus.onClicked.addListener((info, tab) => {
if (itemName == "run-page-command") if (itemName == "run-page-command")
runUrlCommand(tab.url); runUrlCommand(tab.url);
else if (itemName == "run-link-command" && info.linkUrl) else if (itemName == "run-link-command" && info.linkUrl)
runUrlCommand(info.linkUrl); runUrlCommand(info.linkUrl, tab.url);
else if (itemName.startsWith("run-")) { else if (itemName.startsWith("run-")) {
let command_i = itemName.split("-command-")[1]; let command_i = itemName.split("-command-")[1];
runCommand(savedArray("commands")[command_i][1], info.linkUrl || tab.url); runCommand(savedArray("commands")[command_i][1], info.linkUrl || tab.url, tab.url);
} }
}); });
@ -280,7 +282,7 @@ browser.browserAction.onClicked.addListener(() => {
browser.downloads.onCreated.addListener((downloadItem) => { browser.downloads.onCreated.addListener((downloadItem) => {
let command = getDownloadCommand(downloadItem.url, 0); let command = getDownloadCommand(downloadItem.url, 0);
if (command) if (command)
runCommand(command, downloadItem.url, downloadItem.filename); runCommand(command, downloadItem.url, downloadItem.filename, downloadItem.referrer);
}); });
@ -290,7 +292,8 @@ browser.downloads.onChanged.addListener((downloadDelta) => {
if (downloadDelta.state.current == "complete" && downloadItems.length > 0) { if (downloadDelta.state.current == "complete" && downloadItems.length > 0) {
let command = getDownloadCommand(downloadItems[0].url, 1); let command = getDownloadCommand(downloadItems[0].url, 1);
if (command) if (command)
runCommand(command, downloadItems[0].url, downloadItems[0].filename); runCommand(command, downloadItems[0].url,
downloadItems[0].filename, downloadItems[0].referrer);
} }
}) })
}); });

View File

@ -37,7 +37,7 @@
<article> <article>
<h3 id="downloadTitle">Download commands</h3> <h3 id="downloadTitle">Download commands</h3>
<p id="downloadP">Assign commands to be executed for certain URLs (by regex) when downloads are initiated or finished. In commands, $URL will be replaced with the downloads URL, and $FILE with the target file.</p> <p id="downloadP">Assign commands to be executed for certain URLs (by regex) when downloads are initiated or finished. In commands, $FILE will be replaced with the target file, $URL will be replaced with the downloads URL, and $REFERRER with the referring URL.</p>
<table id="downloadTable"> <table id="downloadTable">
<tr> <tr>
<th id="downloadTypeTh">On start/finish</th> <th id="downloadTypeTh">On start/finish</th>

View File

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "__MSG_extensionName__", "name": "__MSG_extensionName__",
"version": "0.13", "version": "0.14",
"description": "__MSG_extensionDescription__", "description": "__MSG_extensionDescription__",
"homepage_url": "https://hak.xwx.moe/jadedctrl/shellfox", "homepage_url": "https://hak.xwx.moe/jadedctrl/shellfox",