Skip to content

Commit

Permalink
fix edge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Sneezry committed May 23, 2024
1 parent adeaf82 commit 6efa4ec
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 36 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
node_modules
build
chrome
firefox
edge
chrome*
firefox*
edge*
dist
.vscode
.atom-build.yml
Expand Down
4 changes: 3 additions & 1 deletion manifests/manifest-edge.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
],
"optional_permissions": [
"clipboardWrite",
"contextMenus",
"contextMenus"
],
"optional_host_permissions": [
"https://www.google.com/",
"https://*.dropboxapi.com/*",
"https://www.googleapis.com/*",
Expand Down
4 changes: 2 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Syntax:
# build.sh <platform>
# Platforms:
# 'chrome', 'firefox', 'test', or 'prod'
# 'chrome', 'firefox', 'edge', 'test', or 'prod'

PLATFORM=$1
REMOTE=$(git config --get remote.origin.url)
Expand All @@ -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
Expand Down
52 changes: 22 additions & 30 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 6efa4ec

Please sign in to comment.