CSDN 优化

优化 CSDN 体验

Verze ze dne 20. 01. 2023. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         CSDN 优化
// @namespace    http://tampermonkey.net/
// @version      0.2.0
// @description  优化 CSDN 体验
// @author       share121
// @match        https://blog.csdn.net/*/article/details/*
// @icon         https://g.csdnimg.cn/static/logo/favicon32.ico
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    "use strict";
    document.querySelectorAll("pre, code").forEach((e) => {
        e.style.cssText +=
            "-webkit-touch-callout:auto;-webkit-user-select:auto;-khtml-user-select:auto;-moz-user-select:auto;-ms-user-select:auto;user-select:auto;";
    });
    document.querySelectorAll(".pre-numbering").forEach((e) => {
        e.style.cssText +=
            "-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;";
    });
    document.querySelectorAll(".hljs-button.signin").forEach((e) => {
        e.onclick = function (e) {
            e.stopPropagation();
            navigator.clipboard
                .writeText(this.parentNode.innerText)
                .then(() => {
                    this.setAttribute("data-title", "复制成功");
                    console.log(`“${this.parentNode.innerText}”写入剪贴板成功`);
                    setTimeout(() => {
                        this.setAttribute("data-title", "复制");
                    }, 3000);
                })
                .catch((err) => console.log(`写入剪贴板失败,错误为“${err}”`));
        };
        e.setAttribute("data-title", "复制");
    });
    let tmp = setInterval(() => {
        let button = document.querySelector("#passportbox > span");
        if (button) {
            clearInterval(tmp);
            button.click();
        }
    }, 0);
    document.querySelector("#article_content").style.height = "auto"
    document.querySelector(".hide-article-box.hide-article-pos")?.remove()
    document.querySelector("#blogExtensionBox")?.remove()
    document.querySelectorAll(".look-more-preCode").forEach(e=>e.click())
})();