Skip to content
Snippets Groups Projects
Commit 31c91f8e authored by David Byers's avatar David Byers
Browse files

Chrome support.

parent c3c28d02
No related branches found
No related tags found
No related merge requests found
source edge/BUILD
build --source firefox \
--target edge \
--target $target \
--override "edge/manifest.override.json" \
--ext zip
......
......@@ -3,5 +3,9 @@
"16": "icon16x16.png",
"32": "icon32x32.png",
"128": "icon128x128.png"
}
},
"permissions": [
"clipboardWrite",
"contextMenus"
]
}
{
"background": {
"scripts": [
"links.js",
"menu.js"
]
},
......
......@@ -62,7 +62,7 @@ parse_args() {
}
setup_globals() {
TARGETS=(thunderbird firefox edge)
TARGETS=(thunderbird firefox edge chrome)
BASEDIR="$( cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null 2>&1 && pwd )"
BUILDDIR="$BASEDIR/build"
......
......@@ -21,6 +21,24 @@
// Context menu
/*
* Workaround for Chrome
*/
async function copyToClipboard(text) {
try {
await navigator.clipboard.writeText(text);
}
catch {
const textArea = document.createElement('textarea');
document.body.append(textArea);
textArea.textContent = text;
textArea.select();
document.execCommand('copy');
textArea.remove();
}
}
/*
* Minimal polyfill for Chrome
*/
......@@ -41,6 +59,6 @@ browser.menus.create({
browser.menus.onClicked.addListener((info, tab) => {
if (info.menuItemId == "liu-safelinks-copy") {
navigator.clipboard.writeText(untangleLink(info.linkUrl));
copyToClipboard(untangleLink(info.linkUrl));
}
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment