Change to old clipboard copy technique, to support chrome and older firefox versions

This commit is contained in:
Kevin Röbert
2019-04-10 19:08:07 +02:00
parent cfd3bf5f43
commit 1b6cc37bdd
3 changed files with 36 additions and 4 deletions

View 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");
}