csdn自由复制

可自由复制csdn内的文本,并且去除了侧边栏,使用更简洁高效

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         csdn自由复制
// @namespace    http://tampermonkey.net/
// @version      2024-01-31
// @description  可自由复制csdn内的文本,并且去除了侧边栏,使用更简洁高效
// @license      MIT
// @author       You
// @match        https://blog.csdn.net/*/article/*
// @icon         https://g.csdnimg.cn/static/logo/favicon32.ico
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    document.querySelectorAll("body>.main_father>#mainBox>main>.blog-content-box>.baidu_pl>#article_content>#content_views>pre>code").forEach((ele)=>{
        ele.style.userSelect="text"
    })
    document.querySelectorAll("body>.main_father>#mainBox>main>.blog-content-box>.baidu_pl>#article_content>#content_views>pre .hljs-button").forEach((ele)=>{
        ele.remove()
    })
    document.querySelector("body>.main_father>#mainBox>main>.blog-content-box").addEventListener("copy",function(event){
        event.stopImmediatePropagation()
    },true)
    document.querySelector("body>.main_father>#mainBox>main").style.width='1300px'
})();