清除csdn广告 清爽页面

2020/9/17 4:01:41油猴脚本Tampermonkey油猴

image.png

// ==UserScript==
// @name         删除csdn无关页面元素
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://blog.csdn.net/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    clear()
    setInterval(()=>{
        clear()
    },1000)
    let style = document.createElement('style')
    style.innerHTML = `
        .nodata .container main{width:100% !important;}
        @media print{.nodata .container{width:100% !important;}}
    `;
    document.body.appendChild(style)
    function clear(){
        [
            'script',
            '#rightAside',
            'iframe',
            'svg',
            '#csdn-toolbar',
            '.blog_container_aside',
            '.comment-box',
            '.comment-edit-box',
            '.second-recommend-box',
            '[style*="overflow-x:hidden"]',
            '[style*="display: none;"]',
            '[style*="display:none;"]',
            '.recommend-box',
            '.template-box',
            '.bottom-pub-footer',
            '.more-toolbox',
            '.article-info-box',
            '.csdn-side-toolbar',
            '.more-toolbox',
            '.login-mark',
            '#passportbox',
            '#pointDivs',
            '.report-box',
            '.skin-boxshadow',
            '.mask-dark',
            '#commentBox',
        ].forEach(item=>{
            let list = Array.from(document.querySelectorAll(item))
            if(list.length>0){
                list.forEach(el=>{
                    el.parentElement.removeChild(el)
                })
            }
        })
    }
    // Your code here...
})();