Clean CSDN Blog

净化CSDN,优化阅读体验

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Clean CSDN Blog
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  净化CSDN,优化阅读体验
// @author       fengxxc
// @match        https://blog.csdn.net/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    // 干掉下边登录条
    var pulllogbox = document.getElementsByClassName('pulllog-box');
    if(pulllogbox.length > 0) {
        pulllogbox[0].style.display = 'none';
    }
    // 阅读更多
    function triggerClick(dom){
        //IE
        if(document.all) {
            dom.click();
        }
        // 其它浏览器
        else {
            var e = document.createEvent("MouseEvents");
            e.initEvent("click", true, true);
            dom.dispatchEvent(e);
        }
    }
    var btnReadmore = document.getElementsByClassName('btn-readmore')[0];
    if (btnReadmore) {
        triggerClick(btnReadmore); // csdn blog
    }
    // 干掉左边
    document.getElementById('mainBox').getElementsByTagName('aside')[0].remove();
    //document.getElementById('mainBox').getElementsByTagName('aside')[0].style.transform = 'translate(-370px,0)'; // new
    // 干掉右边
    document.getElementsByClassName('recommend-right')[0].style.display = 'none';
    //document.getElementsByClassName('recommend-right')[0].style.transform = 'translate(370px,0)'; // new
    // 放大中间
    document.getElementById('mainBox').style.zIndex = '999';
    document.getElementById('mainBox').style.position = 'relative'; // new
    document.getElementById('mainBox').getElementsByTagName('main')[0].style.position = 'absolute'; // new
    document.getElementById('mainBox').getElementsByTagName('main')[0].style.width = '100%';
    // 轮询干掉注册登录
    var passportboxHandle = setInterval(function() {
        var ppb = document.getElementById('passportbox')
        if(ppb) {
            document.getElementById('passportbox').style.display = 'none';
            passportboxHandle = null;
        }
    }, 800);
    
    // document.getElementsByClassName('login-mark')[0].style.display = 'none';

    // 干掉最上面的广告
    document.querySelector("#csdn-toolbar").remove();
    
    // 轮询干掉关注博主即可阅读全文
    var hideArticleBoxHandler = setInterval(function() {
        var hideArticleBox = document.getElementsByClassName('hide-article-box')
        if(hideArticleBox != null && hideArticleBox.length > 0) {
            hideArticleBox[0].style.display = 'none'
            document.getElementById('article_content').style.height = 'inherit'
            hideArticleBoxHandler = null
        }
    }, 800)
    
    
    // 轮询干掉下面作者条
    var leftBoxHandler = setInterval(function() {
        var leftBox = document.getElementsByClassName('left-toolbox');
        if(leftBox && leftBox.length > 0) {
            leftBox[0].style.display = 'none';
            leftBoxHandler = null;
        }
        
    }, 800)
    
})();