From 54145a753a03d4110fe4934eb726c5b246bc00cf Mon Sep 17 00:00:00 2001 From: Xmader Date: Thu, 29 Oct 2020 03:23:02 -0400 Subject: [PATCH] feat: convert as web extension works well in both firefox and chrome --- package.json | 7 ++++++- src/web-ext.js | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/web-ext.js diff --git a/package.json b/package.json index 8da139b..a673db6 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,14 @@ "*://musescore.com/*/*" ], "js": [ - "dist/main.js" + "src/web-ext.js" ], "run_at": "document_start" } ], + "web_accessible_resources": [ + "dist/main.js" + ], "dependencies": { "pdfkit": "git+https://github.com/Xmader/pdfkit.git", "svg-to-pdfkit": "^0.1.8", @@ -48,6 +51,8 @@ "scripts": { "build": "rollup -c", "watch": "npm run build -- --watch", + "start:ext": "web-ext run", + "start:ext-chrome": "npm run start:ext -- -t chromium", "bump-version:patch": "npm version patch --no-git-tag", "bump-version:minor": "npm version minor --no-git-tag" } diff --git a/src/web-ext.js b/src/web-ext.js new file mode 100644 index 0000000..55a0811 --- /dev/null +++ b/src/web-ext.js @@ -0,0 +1,10 @@ +// entry file for the Web Extension +/* eslint-disable no-undef */ + +const MAIN_FILE = 'dist/main.js' + +const script = document.createElement('script') +script.src = chrome.runtime.getURL(MAIN_FILE) +script.addEventListener('load', () => script.remove()) + +document.documentElement.appendChild(script)