Works in Chrome again! (had to make TabFS name lowercase)

Add install script to cover all the native messaging install cases.
This commit is contained in:
Omar Rizwan 2020-10-23 22:03:13 -07:00
parent eee57547ac
commit 281e0a3d8c
3 changed files with 55 additions and 24 deletions

View file

@ -1,23 +0,0 @@
EXE_PATH=$(shell pwd)/fs/tabfs
define NATIVE_MESSAGING_APP_MANIFEST
{
"name": "com.rsnous.TabFS",
"description": "TabFS",
"path": "$(EXE_PATH)",
"type": "stdio",
"allowed_extensions": ["tabfs@rsnous.com"]
}
endef
export NATIVE_MESSAGING_APP_MANIFEST
# "allowed_origins": [
# "chrome-extension://knldjmfmopnpolahpmmgbagdohdnhkik/"
# ]
# ~/Library/Application Support/Google/Chrome/NativeMessagingHosts
MANIFEST_LOCATION="$$HOME/Library/Application Support/Mozilla/NativeMessagingHosts"
APP_NAME="com.rsnous.TabFS"
install:
# install native messaging json
mkdir -p $(MANIFEST_LOCATION)
echo "$$NATIVE_MESSAGING_APP_MANIFEST" > $(MANIFEST_LOCATION)/$(APP_NAME).json

View file

@ -365,7 +365,7 @@ async function onMessage(req) {
};
function tryConnect() {
port = chrome.runtime.connectNative('com.rsnous.TabFS');
port = chrome.runtime.connectNative('com.rsnous.tabfs');
/* console.log('hello', port);*/
/* updateToolbarIcon();*/
port.onMessage.addListener(onMessage);

54
install.sh Executable file
View file

@ -0,0 +1,54 @@
#!/bin/bash -eux
OS="$(uname -s)"
BROWSER="$(echo ${1:-chrome} | tr '[:upper:]' '[:lower:]')"
# https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_manifests#Manifest_location
# https://developer.chrome.com/extensions/nativeMessaging#native-messaging-host-location
case "$OS $BROWSER" in
"Linux firefox")
MANIFEST_LOCATION="$HOME/.mozilla/native-messaging-hosts";;
"Darwin firefox")
MANIFEST_LOCATION="$HOME/Library/Application Support/Mozilla/NativeMessagingHosts";;
"Linux chrome")
MANIFEST_LOCATION="$HOME/.config/google-chrome/NativeMessagingHosts";;
"Linux chromium")
MANIFEST_LOCATION="$HOME/.config/chromium/NativeMessagingHosts";;
"Darwin chrome")
MANIFEST_LOCATION="$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts";;
"Darwin chromium")
MANIFEST_LOCATION="$HOME/Library/Application Support/Chromium/NativeMessagingHosts";;
esac
mkdir -p "$MANIFEST_LOCATION"
APP_NAME="com.rsnous.tabfs"
EXE_PATH=$(pwd)/fs/tabfs
case "$BROWSER" in
chrome | chromium)
MANIFEST=$(cat <<EOF
{
"name": "$APP_NAME",
"description": "TabFS",
"path": "$EXE_PATH",
"type": "stdio",
"allowed_extensions": ["tabfs@rsnous.com"],
"allowed_origins": ["chrome-extension://jimpolemfaeckpjijgapgkmolankohgj/"]
}
EOF
);;
firefox)
MANIFEST=$(cat <<EOF
{
"name": "$APP_NAME",
"description": "TabFS",
"path": "$EXE_PATH",
"type": "stdio",
"allowed_extensions": ["tabfs@rsnous.com"]
}
EOF
);;
esac
echo "$MANIFEST" > "$MANIFEST_LOCATION/$APP_NAME.json"