Compare commits

..

No commits in common. "a1578a12eff0d978b4a58f0374a78aafa4643a38" and "9000b2a3b0747b08b0c65c0a080857a9b2585c5a" have entirely different histories.

2 changed files with 16 additions and 32 deletions

View File

@ -1,14 +1,4 @@
let port = undefined;
// Run the shellfox helper program.
function init_shellfox_port() {
port = browser.runtime.connectNative("shellfox");
port.onDisconnect.addListener((port) => {
console.log(port.error);
port = undefined;
});
}
let port = browser.runtime.connectNative("shellfox");
// Return the command-string associated with a URL, if any.
@ -36,9 +26,8 @@ function getUrlCommand(url) {
// Execute the shell command associated with the given URL, if any.
function runUrlCommand(url) {
console.log("Executing…");
let command = getUrlCommand(url);
if (!port)
init_shellfox_port();
if (command && port) {
port.postMessage(command);
}
@ -57,15 +46,20 @@ function compareRegexComplexity(a, b) {
}
// When the address-bar button is clicked, run the according command (if any).
port.onDisconnect.addListener((port) => {
console.log(port.error);
port = undefined;
});
browser.pageAction.onClicked.addListener((tab) => {
console.log("onClicked");
runUrlCommand(tab.url);
});
// When a tabs URL has been changed, enable/disable the address-bar button
// based on whether or not there is an according command.
browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
console.log("onUpdated");
if (getUrlCommand(tab.url))
browser.pageAction.show(tabId);
else
@ -73,11 +67,8 @@ browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
});
// When the active tab has changed, enable/disable the address-bar button based
// on whether or not there is an according command for it.
browser.tabs.onActivated.addListener((activeInfo) => {
browser.tabs.get(activeInfo.tabId).then((tab) => {
if (getUrlCommand(tab.url))
browser.pageAction.show(tab.id);
});
console.log("activated");
let url = browser.tabs.get(activeInfo.tabId).url;
});

View File

@ -25,15 +25,8 @@ read_message() {
}
# Deescape a JSON stream from input.
json_deescape() {
sed 's/^"//' \
| sed 's/"$//' \
| sed 's/\"/"/g'
}
while true; do
command="$(read_message | json_deescape)"
nohup "$SHELL" -c "$command" > /dev/null &
message="$(read_message)"
command="$(echo "$message" | sed 's/^"//' | sed 's/"$//')"
"$SHELL" -c "$command"
done