CSDN博客专用

CSDN博客网站专用 自动展开+去除页面广告

目前為 2018-12-03 提交的版本,檢視 最新版本

// ==UserScript==
// @name         CSDN博客专用
// @namespace    [email protected]
// @version      1.3.1
// @description  CSDN博客网站专用 自动展开+去除页面广告
// @author       zhaoxiufei
// @match        *://blog.csdn.net/*
// @run-at       document-end
// ==/UserScript==
(function () {
    'use strict';
    let isDebug = true;
    let log = isDebug ? console.log.bind(console) : function () {
    };

    let i = 0;
    //自动展开
    let clean = window.setInterval(cleanAd, 500);

    function displayOne(name, selector) {
        let ad = document.querySelector(selector);
        if (ad) {
            ad.style.display = "none";
            log(name + "已执行");
        } else {
            log(name + "未执行");
        }
    }
    function displayAll(name, selector) {
        let ad = document.querySelectorAll(selector);
        if (ad) {
            for (let i = 0; i < ad.length; i++) {
                ad[i].style.display = "none";
            }
            log(name + "已执行");
        } else {
            log(name + "未执行");
        }
    }
    function cleanAd() {
        if (i > 3) {
            clearInterval(clean)
        }
        log("执行");
        //自动展开
        $("#article_content").removeAttr("style");
        $("#mainBox > div > ul").remove();
        $("#mainBox > main > div.blog-content-box > article > div.hide-article-box.text-center").remove();
        displayOne("ad1", "#mainBox > main > div.recommend-box > div.recommend-item-box.blog-expert-recommend-box");
        displayOne("ad2", "#mainBox > aside > div.csdn-tracking-statistics.mb8.box-shadow");
        displayOne("ad3", "#mainBox > main > div.recommend-box > div.p4courset3_target._4paradigm_box.recommend-item-box.clearfix");
        //displayOne("ad4", "");
        displayOne("ad5", "#mainBox > main > div.recommend-box > div.recommend-item-box.type_hot_word");
        displayOne("ad6", "#mainBox > main > div.recommend-box > div.recommend-item-box.recommend-ad-box");
        displayOne("ad7", "body > div.pulllog-box");
        displayAll("ad8", "#mainBox > main > div.recommend-box > div.recommend-item-box.recommend-ad-box");
        displayOne("ad9", "body > div.fourth_column");
        displayOne("ad10", "#asideFooter");
        i++;
    }
})();

QingJ © 2025

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