csdn只看文章和評論

awful ads

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         csdn只看文章和評論
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  awful ads
// @author       ppdesu
// @match        https://blog.csdn.net/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...


    //clear the aside
    setTimeout(()=>{

        var lists = [
            "header",
            "aside",
            ".csdn-toolbar",
            ".recommend-box",
            ".pulllog-box",
            ".tool-box",
            ".unlogin-box",
            ".edu-promotion"
        ];

        for(var i=0;i<lists.length;i++)
        {
            var ele = document.querySelector(lists[i]);
            console.log(lists[i]);
            if(ele != null)
            {
                ele.parentNode.removeChild(ele);
            }
            else
            {
                console.log(lists[i] + "aside query failed!");
                return;
            }
        }
        console.log("botton ads processing");
        function remove_bottom_ads()
        {
            var listsall = [
                "iframe"
            ];
            console.log("processing iframe");
            for(i=0;i<listsall.length;i++)
            {
                ele = document.querySelectorAll(listsall[i]);
                if(ele == null)continue;
                //while(ele.length==1)
                //{
                for(var j=0;j<ele.length;j++)
                {
                    console.log("remove iframe"+j);
                    if(ele[j] != null)
                    {
                        ele[j].parentNode.removeChild(ele[j]);
                    }
                }
                //ele = document.querySelectorAll(listsall[i]);
                //}
            }
        }
        var index = 0;
        var timeid = setInterval(()=>{
            remove_bottom_ads();
            index = index + 1;
            if(index >=20)
                clearInterval(timeid);
        },1000);
        //alert("executed!");

        var obj = document.querySelector("a#btn-readmore.btn.btn-red-hollow");
        if(obj!=null)
            obj.click();
    },10);
})();