这个功能greasyfork已经有了,我复制过来了方便大家用。 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (function() { | | 'use strict'; | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function copyAndHint(text) { | | GM.setClipboard(text); | | | | unsafeWindow.showPrompt(null, null, 'Copied', 3000); | | } | | | | function setCopy(text, hint) { | | copyAndHint(text); | | } | | | | function copycode(code_div) { | | copyAndHint(code_div.textContent); | | } | | | | var greasemonkey4OrGreater = GM.info.scriptHandler == 'Greasemonkey' && | | parseFloat(GM.info.version) >= 4.0; | | if (greasemonkey4OrGreater) { | | | | | | exportFunction(copyAndHint, window, {defineAs:'copyAndHint'}); | | window.eval( | | 'window.setCopy = function(text, hint) { copyAndHint(text); };' + | | 'window.copycode = function(code_div) { copyAndHint(code_div.textContent); };'); | | } else { | | unsafeWindow.setCopy = setCopy; | | unsafeWindow.copycode = copycode; | | } | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | console.log('finished replacing Discuz\'s copy flash'); | | })();COPY |
|