Clean csdn blog 清爽阅读博客

烦人的半屏顶部广告和左侧栏位都去掉了

// ==UserScript==
// @name         Clean csdn blog 清爽阅读博客
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  烦人的半屏顶部广告和左侧栏位都去掉了
// @author       Zszen
// @match        https://blog.csdn.net/*
// @match        https://www.cnblogs.com/*/p/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    rm_el({
        'csdn-toolbar':'id',
        'blog_container_aside':'class',
        'left-toolbox':'class',
        'canvas':'tag',
    })
    document.getElementsByClassName('main_father')[0].className = 'abc'
    var bodyWid = document.body.clientWidth;
    if (bodyWid<=1200){
        document.getElementsByClassName('container')[0].style.width = '800px';
    }else{
        document.getElementsByClassName('container')[0].style.width = '1200px';
    }
    //document.getElementById('csdn-toolbar').style.display='none'
    //document.getElementsByClassName('blog_container_aside')[0].style.display='none'
    function rm_el(dic){
        for(var key in dic){
            var tar = null
            try{
                switch(dic[key]){
                    case 'id':
                        tar = document.getElementById(key)
                        break
                    case 'class':
                        tar = document.getElementsByClassName(key)[0]
                        break
                }
            }catch(e){
                console.log(e)
            }
            if(tar!=null){
                tar.style.display='none'
                tar.parentElement.removeChild(tar)
            }
        }


    }
    // Your code here...
})();