CSDN博客专用

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

目前為 2018-11-16 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    //自动展开
    let ad1 = document.getElementById("btn-readmore");
    ;
    if (ad1) {
        ad1.click();
    }
    let ad2 = document.querySelector("#mainBox > aside > div.csdn-tracking-statistics.mb8.box-shadow");
    if (ad2) {
        ad2.style.display = "none";
    }
    //去除博主推荐
    let ad3 = document.querySelector("#mainBox > main > div.recommend-box > div.recommend-item-box.blog-expert-recommend-box");
    if (ad3) {
        ad3.style.display = "none";
    }
    //第四范式广告
    let ad4 = document.querySelector("#mainBox > main > div.recommend-box > div.p4courset3_target._4paradigm_box.recommend-item-box.clearfix");
    if (ad4) {
        ad4.style.display = "none";
    }
    //去除feed ad
    let ad5 = document.querySelector("#a_d_feed_0");
    if (ad5) {
        ad5.style.display = "none";
    }
    //
    //去除热词
    let ad6 = document.querySelector("#mainBox > main > div.recommend-box > div.recommend-item-box.type_hot_word");
    if (ad6) {
        ad6.style.display = "none";
    }
    let ad7 = document.querySelector("#mainBox > main > div.recommend-box > div.recommend-item-box.recommend-ad-box");
    if (ad7) {
        ad7.style.display = "none";
    }
    //
    let ad8 = document.querySelector("body > div.pulllog-box");
    if (ad8) {
        ad8.style.display = "none";
    }
    //ad9 #mainBox > main > div.recommend-box > div:nth-child(19)
    let ad9 = document.querySelectorAll("#mainBox > main > div.recommend-box > div.recommend-item-box.recommend-ad-box");
    if (ad9) {
        for (let i = 0; i < ad9.length; i++) {
            ad9[i].style.display = "none";
        }
    }
    //
    let ad10 = document.querySelector("body > div.fourth_column");
    if (ad10) {
        ad10.style.display = "none";
    }

    //去除博客右侧动态添加的广告
    let interval = setInterval(ad, 200);
    let timeSrun = 0;

    function ad() {
        let xx = $(".recommend-fixed-box");
        let yy = xx.children("div");
        for (let i = 0; i < yy.length; i++) {
            timeSrun += 1;
            yy[i].remove();
            if (timeSrun === 10) {
                clearInterval(interval);
            }
        }
    }

})();