csdn暴力美化

去除所有与文章无关的信息

当前为 2021-11-11 提交的版本,查看 最新版本

// ==UserScript==
// @name         csdn暴力美化
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  去除所有与文章无关的信息
// @author       wanghaozhe
// @match        *://blog.csdn.net/*/article/details/*
// @match        *://*.blog.csdn.net/article/details/*
// @match        *://bbs.csdn.net/topics/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=gf.qytechs.cn
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var body = document.getElementsByTagName('body')[0]
    var style = document.createElement('style')
    var css = `
#articleSearchTip{
display: none !important;
}
.hljs-button{
display: none !important;
}
.passport-login-container{
display: none !important;
}
code,ol{
user-select: text !important;
}
    `
    var innerStyle = document.createTextNode(css)
    style.appendChild(innerStyle)
    document.head.appendChild(style)
    // 修改背景
    body.style.setProperty('background-color', 'black')
    body.style.setProperty('background-image', 'none')
    if(document.getElementsByClassName('csdn-side-toolbar').length) {
        // 隐藏右侧悬浮工具(广告)栏
        document.getElementsByClassName('csdn-side-toolbar')[0].style.display = 'none'
    }
    if(document.getElementsByClassName('nodata ').length) {
        // 移除上方导航(广告)栏
        document.getElementsByClassName('nodata ')[0].removeChild(document.getElementById('csdn-toolbar'))
    }
    if(document.getElementsByClassName('left-toolbox').length) {
        // 隐藏左侧工具栏
        document.getElementsByClassName('left-toolbox')[0].style.display = 'none'
    }
    if(document.getElementsByClassName('article-info-box').length) {
        // 隐藏标题下方信息
        document.getElementsByClassName('article-info-box')[0].style.display = 'none'
    }
    if(document.getElementsByClassName('column-group').length) {
        // 隐藏订阅专栏行
        document.getElementsByClassName('column-group')[0].style.display = 'none'
    }
    if(document.getElementById('rightAside')) {
        // 隐藏右侧目录部分
        document.getElementById('rightAside').style.display = 'none'
    }
    if(document.getElementById('mainBox')) {
        // 获取容器
        let mainBox = document.getElementById('mainBox')
        // 删除右侧所有浮窗
        if(document.getElementsByClassName('blog_container_aside').length){
            mainBox.removeChild(document.getElementsByClassName('blog_container_aside')[0])
        }
        // 设置整体容器宽度并使其居中
        mainBox.style.width = '100%'
        mainBox.style.display = 'flex'
        mainBox.style.setProperty('justify-content', 'center')
    }
    if(document.getElementsByTagName("main").length) {
        // 文章宽度设置为80%
        document.getElementsByTagName("main")[0].style.width = '80%'
        if(document.getElementsByClassName('recommend-box insert-baidu-box').length) {
            document.getElementsByTagName('main')[0].removeChild(document.getElementsByClassName('recommend-box insert-baidu-box')[0])
        }
        if(document.getElementsByClassName('blog-footer-bottom').length) {
            document.getElementsByTagName('main')[0].removeChild(document.getElementsByClassName('blog-footer-bottom')[0])
        }
    }
    window.onload = function(){
        if(document.getElementsByClassName('csdn-reapck-select').length) {
            body.removeChild(document.getElementsByClassName('csdn-reapck-select')[0])
        }
    }
    // 禁止弹窗
    window.alert = function() {
        return false;
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址