CSDN页面上方广告条太烦人?js写个油猴脚本给它隐藏了~

油猴怎么安装就不说了,百度一下都有

安装后之后点添加新脚本

代码 :把那个div隐藏了就得了,设置个display:none属性

// ==UserScript==
// @name         csdn去广告
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       vhukze
// @match        *://blog.csdn.net/*
// @match        *://i.csdn.net/*
// @icon         https://www.google.com/s2/favicons?domain=csdn.net
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var flag = false;
    var t = setInterval(function(){
        if(flag){
            clearInterval(t);
        }else{
            var arr = document.getElementsByClassName('toolbar-advert');
            if(arr.length != 0){
               arr[0].style.display='none';
               flag = true;
            }
        }
    },1);

})();

注意,上面那些注释也是需要的呢

猜你喜欢

转载自blog.csdn.net/qq_41890624/article/details/121283413