Greasy Fork

Greasy Fork is available in English.

选中即复制

鼠标选中页面中的字符,自动复制进剪贴板

目前为 2020-09-04 提交的版本。查看 最新版本

// ==UserScript==
// @name         选中即复制
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  鼠标选中页面中的字符,自动复制进剪贴板
// @author       kakasearch
// @include      *://**/*
// @grant        GM_setClipboard
// @grant        unsafeWindow
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Your code here..
    var text
    document.onclick = function() {
    if (unsafeWindow.getSelection) {
        text = unsafeWindow.getSelection();
    } else if (document.selection) {
        text = document.selection.createRange();
    }
        GM_setClipboard(text.toString())

}
})();