码迷,mamicode.com
首页 > Web开发 > 详细

js初学练手:Csdn Ads Cleaner

时间:2019-01-12 22:50:55      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:清除   bsp   ora   https   target   ati   div   nta   content   

这里啦:https://greasyfork.org/zh-CN/scripts/376621-csdn-ads-cleaner

 

隔壁csdn的广告太猖獗啦!写个js管管它

需配合TemperMonkey使用,点击左上角的按钮就可以清除广告。

V1.0代码:

技术分享图片
// ==UserScript==
// @name         Csdn Ads Cleaner
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Clear those fxxking ads on csdn!
// @author       sun123zxy
// @match        blog.csdn.net/*
// @grant        none
// ==/UserScript==

(function() {
    ‘use strict‘;
    
    var CAB = document.createElement("button");
    CAB.innerHTML="Clear Ads";
    //CAB.setAttribute("onclick", "javascript:ClearAds()");

    CAB.onclick=function(){
        console.log("Finding ads...");
        var Ads = new Array(document.getElementsByClassName("csdn-tracking-statistics mb8 box-shadow")[0],
                            document.getElementsByClassName("fourth_column")[0],
                            document.getElementsByClassName("right-item _paradigm_S8_csdn_ads_render")[0],
                            document.getElementById("kp_box_57"),
                            document.getElementsByClassName("right-item _paradigm_S27_csdn_ads_render")[0],
                            document.getElementsByClassName("pulllog-box")[0],
                            document.getElementById("adContent")
                           );
        console.log("Clearing ads...");
        for(var i=0;i<Ads.length;i++){
            if(Ads[i]){
               Ads[i].parentNode.removeChild(Ads[i]);
            }
        }
        console.log("Sucessfully Clear Ads!");
    }
    var body= document.body;
    body.insertBefore(CAB,document.getElementsByClassName("container clearfix")[0]);
    console.log("Sucessfully spawn Clear Button...");
})();
View Code

 

js初学练手:Csdn Ads Cleaner

标签:清除   bsp   ora   https   target   ati   div   nta   content   

原文地址:https://www.cnblogs.com/sun123zxy/p/csdnadscleaner.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!