解除CSDN登录(不可用)复制

去你妈的CSDN登录(不可用)复制,无需登录(不可用)即可复制

ของเมื่อวันที่ 30-08-2024 ดู เวอร์ชันล่าสุด

// ==UserScript==
// @name         解除CSDN登录(不可用)复制
// @namespace    https://greasyforks.org/users/1169082/
// @version 1.0.0.5
// @description  去你妈的CSDN登录(不可用)复制,无需登录(不可用)即可复制
// @author       人民的勤务员 <[email protected]>
// @match        https://blog.csdn.net/*
// @supportURL              https://github.com/ChinaGodMan/UserScripts/issues
// @homepageURL   https://github.com/ChinaGodMan/UserScripts
// @grant        none
// ==/UserScript==

(function () {
    'use strict'

    function timeoutAfterLoad(callback, delay) {
        setTimeout(callback, delay)
    }

    timeoutAfterLoad(() => {
        // 修改复制按钮
        document.querySelectorAll(".hljs-button").forEach((e) => {
            e.setAttribute("data-title", "点击复制")
            e.classList.remove("signin")
            e.removeAttribute("onclick")
            e.addEventListener("click", () => {
                e.setAttribute("data-title", " ")
                navigator.clipboard.writeText(e.parentNode.innerText)
                e.setAttribute("data-title", "复制成功")
                setTimeout(() => e.setAttribute("data-title", "点击复制"), 1200)
            })
        })

        // 复制功能
        document.querySelector(".blog-content-box").addEventListener(
            "copy",
            (e) => {
                e.stopPropagation()
                e.preventDefault()

                navigator.clipboard.writeText(window.getSelection().toString())
            },
            true,
        )
        document.addEventListener(
            "keydown",
            (e) => {
                if (e.ctrlKey && e.keyCode == 67) { // Ctrl+C
                    e.stopPropagation()
                    e.preventDefault()

                    navigator.clipboard.writeText(window.getSelection().toString())
                }
            },
            true,
        )

        document.oncopy = null
        window.oncopy = null
    }, 500)
})()
长期地址
遇到问题?请前往 GitHub 提 Issues。