csdn去广告

csdn去广告,自动展开

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         csdn去广告
// @namespace    http://tampermonkey.net/
// @version      2025-12-09
// @description  csdn去广告,自动展开
// @description:zh-cn  csdn去广告,自动展开
// @author       小明
// @license MIT
// @match        https://blog.csdn.net/*
// @match        https://www.csdn.net/*
// @match        https://edu.csdn.net/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=csdn.net
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';
    let display = "{display:none !important}";
    let vis = "{visibility:hidden !important}";

	//------blog------
    //顶部
    let ding1 = "#csdn-toolbar > div.toolbar-advert";
    GM_addStyle(ding1+display);

    //会员中心
    let ss1 = "#csdn-toolbar > div > div > div.toolbar-container-right > div > div.toolbar-btn.toolbar-btn-vip.csdn-toolbar-fl > a > img";
    GM_addStyle(ss1+display);
    //消息小红点
    let ss2 = "#toolbar-remind > span > i";
    GM_addStyle(ss2+display);

    //右侧
    // 右侧vip服务
    GM_addStyle(".sidecolumn-vip{display:none !important}");
    GM_addStyle(".csdn-common-logo-advert{display:none !important}");
    GM_addStyle("#sidecolumn-deepseek{display:none !important}");

    //内容
    let content1 = ".opt-box";
    GM_addStyle(content1+display);
    GM_addStyle(".pre-numbering{display:none !important}");

    //------www------

    //正在直播
    let zhibo1 = ".live-type";
    GM_addStyle(zhibo1+vis);


    //------edu------
    GM_addStyle(".top_banner"+display);
    //GM_addStyle(".v-modal"+display);
    GM_addStyle(".el-dialog__wrapper"+display);
	//GM_addStyle(`
	//.top_banner,
	//.v-modal,
	//.el-dialog__wrapper{
	//	display:none !important
	//}
	//`);


    function basicClick() {
        // 查找所有包含"hide-preCode-bt"的按钮
        const buttons = document.querySelectorAll('[class*="hide-preCode-bt"]');

        if (buttons.length > 0) {
            console.log(`找到 ${buttons.length} 个需要点击的展开按钮`);

            buttons.forEach(button => {
                try {
                    // 模拟点击事件
                    button.click();
                    console.log('已点击展开按钮:', button);
                } catch (error) {
                    console.error('点击按钮时出错:', error, button);
                }
            });
        } else {
            console.log('未找到包含"hide-preCode-bt"的按钮');
        }
    }

    basicClick();
    GM_addStyle(".hide-preCode-box{display:none !important}");

})();