Compare commits
No commits in common. "master" and "v0.13" have entirely different histories.
15
README.md
15
README.md
|
@ -1,19 +1,16 @@
|
|||
# ![](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">
|
||||
|
||||
|
||||
## 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).
|
||||
|
||||
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)
|
||||
2. Extract the ZIP-archive; this will make a folder called `shellfox/`.
|
||||
|
@ -34,11 +31,7 @@ $ sudo make native-install
|
|||
|
||||
|
||||
## 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). It’s very useful, I highly recommend it!
|
||||
|
||||
If you like mixing web-browsing with shell, then you’ll probably also like
|
||||
[TabFS](https://omar.website/tabfs/), a FUSE filesystem that exposes your browser tabs as files.
|
||||
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). It’s very useful, I highly recommend it!
|
||||
|
||||
|
||||
## Source code
|
||||
|
|
|
@ -107,7 +107,7 @@
|
|||
},
|
||||
|
||||
"optionsDescDownload": {
|
||||
"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 download’s URL, and $REFERRER with the referring URL.",
|
||||
"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 download’s URL, and $FILE with the target file.",
|
||||
"description": "Description of options-page section for download commands."
|
||||
},
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@
|
|||
},
|
||||
|
||||
"optionsDescDownload": {
|
||||
"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.",
|
||||
"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.",
|
||||
"description": "Priskribo de agordo-parto por elŝutaj ordonoj."
|
||||
},
|
||||
|
||||
|
|
|
@ -99,27 +99,25 @@ function getDownloadCommand(url, type) {
|
|||
}
|
||||
|
||||
|
||||
// Execute the given command string, subsituting “$URL” with url,
|
||||
// “$FILE” with filepath, and “$REFERRER” with referrer.
|
||||
function runCommand(command, url, filepath, referrer) {
|
||||
// Execute the given command string, subsituting “$URL” with url and
|
||||
// “$FILE” with filepath.
|
||||
function runCommand(command, url, filepath) {
|
||||
if (!port)
|
||||
initShellfoxProgram();
|
||||
if (command && port)
|
||||
port.postMessage(command
|
||||
.replaceAll("$URL", url)
|
||||
.replaceAll("${URL}", url)
|
||||
.replaceAll("$REFERRER", referrer || "")
|
||||
.replaceAll("${REFERRER}", referrer || "")
|
||||
.replaceAll("$FILE", filepath)
|
||||
.replaceAll("${FILE}", filepath));
|
||||
}
|
||||
|
||||
|
||||
// Execute the shell command associated with the given URL, if any.
|
||||
function runUrlCommand(url, referrer) {
|
||||
function runUrlCommand(url) {
|
||||
let commands = getUrlCommands(url);
|
||||
if (commands)
|
||||
runCommand(commands[0], url, "", referrer);
|
||||
runCommand(commands[0], url);
|
||||
}
|
||||
|
||||
|
||||
|
@ -266,10 +264,10 @@ browser.menus.onClicked.addListener((info, tab) => {
|
|||
if (itemName == "run-page-command")
|
||||
runUrlCommand(tab.url);
|
||||
else if (itemName == "run-link-command" && info.linkUrl)
|
||||
runUrlCommand(info.linkUrl, tab.url);
|
||||
runUrlCommand(info.linkUrl);
|
||||
else if (itemName.startsWith("run-")) {
|
||||
let command_i = itemName.split("-command-")[1];
|
||||
runCommand(savedArray("commands")[command_i][1], info.linkUrl || tab.url, tab.url);
|
||||
runCommand(savedArray("commands")[command_i][1], info.linkUrl || tab.url);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -282,7 +280,7 @@ browser.browserAction.onClicked.addListener(() => {
|
|||
browser.downloads.onCreated.addListener((downloadItem) => {
|
||||
let command = getDownloadCommand(downloadItem.url, 0);
|
||||
if (command)
|
||||
runCommand(command, downloadItem.url, downloadItem.filename, downloadItem.referrer);
|
||||
runCommand(command, downloadItem.url, downloadItem.filename);
|
||||
});
|
||||
|
||||
|
||||
|
@ -292,8 +290,7 @@ browser.downloads.onChanged.addListener((downloadDelta) => {
|
|||
if (downloadDelta.state.current == "complete" && downloadItems.length > 0) {
|
||||
let command = getDownloadCommand(downloadItems[0].url, 1);
|
||||
if (command)
|
||||
runCommand(command, downloadItems[0].url,
|
||||
downloadItems[0].filename, downloadItems[0].referrer);
|
||||
runCommand(command, downloadItems[0].url, downloadItems[0].filename);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
<article>
|
||||
<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, $FILE will be replaced with the target file, $URL will be replaced with the download’s URL, and $REFERRER with the referring URL.</p>
|
||||
<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 download’s URL, and $FILE with the target file.</p>
|
||||
<table id="downloadTable">
|
||||
<tr>
|
||||
<th id="downloadTypeTh">On start/finish</th>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "__MSG_extensionName__",
|
||||
"version": "0.14",
|
||||
"version": "0.13",
|
||||
|
||||
"description": "__MSG_extensionDescription__",
|
||||
"homepage_url": "https://hak.xwx.moe/jadedctrl/shellfox",
|
||||
|
|
Ŝarĝante…
Reference in New Issue