Compare commits
3 Enmetoj
Author | SHA1 | Date | |
---|---|---|---|
Jaidyn Ann | 74735233b0 | ||
Jaidyn Ann | e721fcbc18 | ||
Jaidyn Ann | da847fc55c |
15
README.md
15
README.md
|
@ -1,16 +1,19 @@
|
|||
# ![](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/`.
|
||||
|
@ -31,7 +34,11 @@ $ 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!
|
||||
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.
|
||||
|
||||
|
||||
## 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, $URL will be replaced with the download’s 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 download’s URL, and $REFERRER with the referring URL.",
|
||||
"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, «$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."
|
||||
},
|
||||
|
||||
|
|
|
@ -99,25 +99,27 @@ function getDownloadCommand(url, type) {
|
|||
}
|
||||
|
||||
|
||||
// Execute the given command string, subsituting “$URL” with url and
|
||||
// “$FILE” with filepath.
|
||||
function runCommand(command, url, filepath) {
|
||||
// Execute the given command string, subsituting “$URL” with url,
|
||||
// “$FILE” with filepath, and “$REFERRER” with referrer.
|
||||
function runCommand(command, url, filepath, referrer) {
|
||||
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) {
|
||||
function runUrlCommand(url, referrer) {
|
||||
let commands = getUrlCommands(url);
|
||||
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")
|
||||
runUrlCommand(tab.url);
|
||||
else if (itemName == "run-link-command" && info.linkUrl)
|
||||
runUrlCommand(info.linkUrl);
|
||||
runUrlCommand(info.linkUrl, tab.url);
|
||||
else if (itemName.startsWith("run-")) {
|
||||
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) => {
|
||||
let command = getDownloadCommand(downloadItem.url, 0);
|
||||
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) {
|
||||
let command = getDownloadCommand(downloadItems[0].url, 1);
|
||||
if (command)
|
||||
runCommand(command, downloadItems[0].url, downloadItems[0].filename);
|
||||
runCommand(command, downloadItems[0].url,
|
||||
downloadItems[0].filename, downloadItems[0].referrer);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
|
@ -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, $URL will be replaced with the download’s 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 download’s URL, and $REFERRER with the referring URL.</p>
|
||||
<table id="downloadTable">
|
||||
<tr>
|
||||
<th id="downloadTypeTh">On start/finish</th>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "__MSG_extensionName__",
|
||||
"version": "0.13",
|
||||
"version": "0.14",
|
||||
|
||||
"description": "__MSG_extensionDescription__",
|
||||
"homepage_url": "https://hak.xwx.moe/jadedctrl/shellfox",
|
||||
|
|
Ŝarĝante…
Reference in New Issue