diff --git a/.gitignore b/.gitignore index 937f37a3..d2335a07 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ node_modules build -chrome -firefox -edge +chrome* +firefox* +edge* dist .vscode .atom-build.yml diff --git a/manifests/manifest-edge.json b/manifests/manifest-edge.json index eafa47af..8f267544 100644 --- a/manifests/manifest-edge.json +++ b/manifests/manifest-edge.json @@ -57,7 +57,9 @@ ], "optional_permissions": [ "clipboardWrite", - "contextMenus", + "contextMenus" + ], + "optional_host_permissions": [ "https://www.google.com/", "https://*.dropboxapi.com/*", "https://www.googleapis.com/*", diff --git a/scripts/build.sh b/scripts/build.sh index 65f47711..3da00c0e 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -4,7 +4,7 @@ # Syntax: # build.sh # Platforms: -# 'chrome', 'firefox', 'test', or 'prod' +# 'chrome', 'firefox', 'edge', 'test', or 'prod' PLATFORM=$1 REMOTE=$(git config --get remote.origin.url) @@ -20,7 +20,7 @@ fi echo "Removing old build files..." rm -rf build dist -rm -rf firefox chrome release test +rm -rf firefox chrome edge release test echo "Checking style..." if ./node_modules/.bin/prettier --check $STYLEFILES 1> /dev/null ; then true diff --git a/src/background.ts b/src/background.ts index dc3cb1ed..30b95a15 100644 --- a/src/background.ts +++ b/src/background.ts @@ -58,36 +58,6 @@ chrome.alarms.onAlarm.addListener(() => { chrome.runtime.sendMessage({ action: "stopImport" }); }); -chrome.permissions.contains( - { permissions: ["contextMenus"] }, - (hasPermission) => { - if (hasPermission) { - chrome.contextMenus.onClicked.addListener((info, tab) => { - let popupUrl = "view/popup.html?popup=true"; - if (tab && tab.url && tab.title) { - popupUrl += - "&url=" + - encodeURIComponent(tab.url) + - "&title=" + - encodeURIComponent(tab.title); - } - let windowType; - if (isFirefox) { - windowType = "detached_panel"; - } else { - windowType = "panel"; - } - chrome.windows.create({ - url: chrome.runtime.getURL(popupUrl), - type: windowType as chrome.windows.createTypeEnum, - height: 400, - width: 320, - }); - }); - } - } -); - async function getCapture(tab: chrome.tabs.Tab) { const dataUrl = await chrome.tabs.captureVisibleTab(tab.windowId, { format: "png", @@ -573,6 +543,28 @@ async function updateContextMenu() { title: chrome.i18n.getMessage("extName"), contexts: ["all"], }); + chrome.contextMenus.onClicked.addListener((info, tab) => { + let popupUrl = "view/popup.html?popup=true"; + if (tab && tab.url && tab.title) { + popupUrl += + "&url=" + + encodeURIComponent(tab.url) + + "&title=" + + encodeURIComponent(tab.title); + } + let windowType; + if (isFirefox) { + windowType = "detached_panel"; + } else { + windowType = "panel"; + } + chrome.windows.create({ + url: chrome.runtime.getURL(popupUrl), + type: windowType as chrome.windows.createTypeEnum, + height: 400, + width: 320, + }); + }); } else { chrome.contextMenus.removeAll(); }