mirror of
https://gitlab.com/KevinRoebert/ClearUrls
synced 2025-12-16 14:15:36 +07:00
Change to old clipboard copy technique, to support chrome and older firefox versions
This commit is contained in:
16
external_js/clipboard-helper.js
Normal file
16
external_js/clipboard-helper.js
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Source: https://github.com/mdn/webextensions-examples/tree/master/context-menu-copy-link-with-types
|
||||
*/
|
||||
function copyToClipboard(text) {
|
||||
function oncopy(event) {
|
||||
document.removeEventListener("copy", oncopy, true);
|
||||
|
||||
event.stopImmediatePropagation();
|
||||
|
||||
event.preventDefault();
|
||||
event.clipboardData.setData("text/plain", text);
|
||||
}
|
||||
document.addEventListener("copy", oncopy, true);
|
||||
|
||||
document.execCommand("copy");
|
||||
}
|
||||
Reference in New Issue
Block a user