Last active
April 13, 2020 14:43
-
-
Save bigfang/d49d1e71008f7dfd51a50be0b8b8bcf0 to your computer and use it in GitHub Desktop.
user script :: autocopy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name autocopy | |
// @namespace https://bigfang.github.io | |
// @description Auto copy selected text | |
// @match *://*/* | |
// @run-at document-end | |
// @grant GM_setClipboard | |
// ==/UserScript== | |
if (typeof GM_setClipboard != 'function') alert('Your UserScript client has no GM_setClipboard support'); | |
document.addEventListener('mouseup', | |
(e) => { | |
if (e.button != 0 || ['INPUT', 'TEXTAREA'].includes(e.target.tagName)) | |
return; | |
let stext = getSelection().toString(); | |
if (stext) { | |
GM_setClipboard(stext) | |
} | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment