zoukankan      html  css  js  c++  java
  • 用TamperMonkey去掉cdsn中的广告

    最近CSDN需要登录后才能查看更多内容,有点影响心情

    解决方案

    添加一段书签

    javascript:(function(){document.getElementById('article_content').style.height='auto';document.getElementsByClassName('hide-article-box')[0].style.display='none';}())

    在网页里面点一下就行了

    进阶版

    每次点一下还是有点麻烦,还是使用了一个chorme插件TamperMonkey来自动执行代码,下面的代码隐藏掉一些碍眼的广告和推荐(CSDN自带JQuery)

    // ==UserScript==
    // @name         BOLCK CSDN
    // @namespace    http://tampermonkey.net/
    // @version      0.1
    // @description  try to take over the world!
    // @author       WozHuang
    // @match        https://blog.csdn.net/*
    // @grant        none
    // @run-at       document-end
    // ==/UserScript==
    
    function rm(elementArray){
        for(let element of elementArray){
            element && element.parentNode.removeChild(element);
            //element.style.display='none';
        }
    }
    
    (function() {
        'use strict';
        var old_onload = window.onload;
        var temp
        window.onload=function(){
            old_onload && old_onload();
            (function(){
                (temp = document.getElementById('article_content')) && (temp.style.height='auto');
                (temp = document.getElementsByClassName('hide-article-box')[0]) && (temp.style.display='none');
            }())
            rm([
                document.getElementsByClassName('adblock')[0],
                document.getElementById('csdn-toolbar'),
                document.getElementById('asideProfile').parentNode,
                document.getElementsByClassName('pulllog-box')[0],
                document.getElementsByClassName('recommend-right')[0],
                document.getElementsByClassName('tool-box')[0],
                document.getElementsByClassName('fourth_column')[0],
                document.getElementsByClassName('comment-box')[0],
                document.getElementById('dmp_ad_58'),
            ]);
            var main = document.getElementsByTagName('main')[0];
            main && (main.style.float='none');
            main && (main.style.margin='0px auto');
            var $ = window.$;
            if(!$){alert('There are no jQuery');}
            $(function(){
                var rec_box = $(".recommend-box");
                rec_box.css("opacity","0.1");
                rec_box.css("overflow","hidden");
                rec_box.css("height","100px");
            });
            $(".recommend-box").hover(function(){
                $(this).css("opacity","1");
                $(this).css("height","auto");
            },function(){
                $(this).css("opacity","0.1");
            });
        };
    })();
  • 相关阅读:
    修改MFC标题栏上的图标
    【转】子窗口刷新父窗口的问题
    水晶报表添加引用
    【转】MetadataType的使用,MVC的Model层数据验证
    poj 1556 The Doors 线段相交判断+最短路
    poj 1269 Intersecting Lines 求直线交点 判断直线平行共线
    string 函数操作
    poj 1066 Treasure Hunt 线段相交判断
    poj 1410 Intersection 线段相交判断
    poj 3347 Kadj Squares 扩大数据化整数
  • 原文地址:https://www.cnblogs.com/wozho/p/10044975.html
Copyright © 2011-2022 走看看