click-copy-text

try to take over the world!

目前为 2021-10-17 提交的版本。查看 最新版本

// ==UserScript==
// @name         click-copy-text
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  try to take over the world!
// @author       You
// @match        http://*/*
// @match        https://*/*
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// @grant        GM_setClipboard
// ==/UserScript==

(function() {
    'use strict';
    $('body').on('click','*',function(event){
        if(event.altKey){
            event.preventDefault();
            event.stopPropagation()
            let text = $(this).text().trim() || $(this).val()
            if(text){
                text = text.replace(/[::]$/,'')
                highlight(event.target)
                GM_setClipboard(text)
            }else if($(this).find('input')){
                highlight($(this).find('input')[0])
                GM_setClipboard($(this).find('input').val())
            }
        }
    })
    function highlight(clickedElement){
        var rect = clickedElement.getBoundingClientRect();
        var frame = document.createElement("div");
        frame.style.position = "absolute";
        frame.style.top = (rect.top + window.scrollY) + "px";
        frame.style.left = (rect.left + window.scrollX) + "px";
        frame.style.width = (rect.width - 4) + "px";
        frame.style.height = (rect.height - 4) + "px";
        frame.style.border = "solid 2px gold";
        frame.style.borderRadius = "5px";
        frame.style.zIndex = "99999";
        frame.style.pointerEvents = "none";
        document.body.appendChild(frame);

        $(frame).fadeIn(300, "swing").delay(500).fadeOut(500, "swing");
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址