csdn暴力美化

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

目前为 2021-11-10 提交的版本。查看 最新版本

// ==UserScript==
// @name         csdn暴力美化
// @namespace    http://tampermonkey.net/
// @version      0.1
// @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]
    // 修改背景
    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('has-numbering').length) {
        // 改变userselect使文本可复制
        for(let i = 0, len = document.getElementsByClassName('has-numbering').length; i < len; i++){
            document.getElementsByClassName('has-numbering')[i].style.setProperty('user-select', 'text', 'important');
        }
    }
    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.getElementsByClassName('hljs-ln').length) {
        // 使文本可复制
        console.log(document.getElementsByClassName('hljs-ln'))
        document.getElementsByClassName('hljs-ln')[0].style.setProperty('user-select', 'text');
    }
    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.alert = function() {
        return false;
    }
})();

QingJ © 2025

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