Greasy Fork is available in English.
鼠标选中页面中的字符,自动复制进剪贴板
当前为
// ==UserScript==
// @name 选中即复制
// @namespace http://tampermonkey.net/
// @version 0.2
// @description 鼠标选中页面中的字符,自动复制进剪贴板
// @author kakasearch
// @include *://**/*
// @grant unsafeWindow
// ==/UserScript==
(function() {
'use strict';
var text
document.onclick = function() {
if ( unsafeWindow.getSelection) {
text = unsafeWindow.getSelection();
} else if (document.selection) {
text = document.selection.createRange();
}
// 放到粘贴板里,操作浏览器自身的API
// console.log(text.toString());
document.execCommand('Copy'); // 执行浏览器的复制命令
}
})();