diff --git a/Makefile b/Makefile deleted file mode 100644 index f15f5dc..0000000 --- a/Makefile +++ /dev/null @@ -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 diff --git a/extension/background.js b/extension/background.js index 1e47b98..75520d9 100644 --- a/extension/background.js +++ b/extension/background.js @@ -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); diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..aa13668 --- /dev/null +++ b/install.sh @@ -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 < "$MANIFEST_LOCATION/$APP_NAME.json"