CSDN博客专用

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

当前为 2018-11-16 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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

    //自动展开
    var doc = document.getElementById("btn-readmore");;
    if (doc) {
        logger("已自动展开");
        doc.click();
    }
    var add1 = document.querySelector("#mainBox > aside > div.csdn-tracking-statistics.mb8.box-shadow");
    if(add1){
        logger("已去除博主推荐");
     add1.style.display="none";
    }
    //去除博主推荐
    var bztj = document.querySelector("#mainBox > main > div.recommend-box > div.recommend-item-box.blog-expert-recommend-box");
    if(bztj){
      logger("已去除博主推荐");
     bztj.style.display="none";
    }
    //第四范式广告
    var a4d = document.querySelector("#mainBox > main > div.recommend-box > div.p4courset3_target._4paradigm_box.recommend-item-box.clearfix");
    if(a4d){
        logger("已去除第四范式广告");
        a4d.style.display="none";
    }
    //去除feed ad
    var hotad = document.querySelector("#a_d_feed_0");
    if(hotad){
        logger("已去除feed ad");
        hotad.style.display="none";
    }
    //
     //去除热词
    var ad6 = document.querySelector("#mainBox > main > div.recommend-box > div.recommend-item-box.type_hot_word");
    if(ad6){
        logger("已去除热词");
        ad6.style.display="none";
    }
    var ad7 = document.querySelector("#mainBox > main > div.recommend-box > div.recommend-item-box.recommend-ad-box");
    if(ad7){
        logger("已去除ad7");
        ad7.style.display="none";
    }
    //
    var pulllog = document.querySelector("body > div.pulllog-box");
    if(pulllog){
        logger("已去除pulllog");
        pulllog.style.display="none";
    }
    //asideFooter #mainBox > main > div.recommend-box > div:nth-child(19)
    var asideFooter = document.querySelectorAll("#mainBox > main > div.recommend-box > div.recommend-item-box.recommend-ad-box");
    if(asideFooter){
      logger("已去除asideFooter");
        for (var i=0;i<asideFooter.length;i++){
           asideFooter[i].style.display="none";
        }
    }
    //去除博客右侧动态添加的广告
    var interval = setInterval(ad, 200);
    var timeSrun = 0;
    function ad() {
        var xx = $(".recommend-fixed-box");
        var yy = xx.children("div");
        for (var i = 0; i < yy.length; i++) {
            timeSrun += 1;
            yy[i].remove();
            if (timeSrun == 10) {
                clearInterval(interval);
            }
        }
    }

})();