CSDN 博客文章页面简化

CSDN 博客页面简化脚本,自动展开全文,去除无用内容,调整了文章内容样式。

目前为 2018-12-17 提交的版本。查看 最新版本

// ==UserScript==
// @name CSDN 博客文章页面简化
// @description CSDN 博客页面简化脚本,自动展开全文,去除无用内容,调整了文章内容样式。
// @version 0.4.0
// @namespace Violentmonkey Scripts
// @match https://blog.csdn.net/*/article/details/*
// @grant none
// ==/UserScript==

function addCss(cssString) {
    var head = document.getElementsByTagName('head')[0];
    var newCss = document.createElement('style');
    newCss.type = 'text/css';
    newCss.innerHTML = cssString;
    head.appendChild(newCss);
}

addCss(`
.tool-box {
    display: none !important;
}

.recommend-right {
    display: none;
}

.recommend-box {
    display: none;
}

aside {
    float: none;
    width: 100%;
    max-width: 860px;
    margin: 0px auto;
    position: static !important;
}

main {
    width: 100% !important;
    float: none;
    max-width: 860px;
    margin: 2rem auto 1rem auto;
}

p > span[style] {
    font-family: inherit !important;
    font-size: inherit !important;
}

.pulllog-box {
    display: none !important;
}

#csdn-toolbar li a[title="活动"], #csdn-toolbar li a[title="商城"], #csdn-toolbar li a[title="APP"], #csdn-toolbar li a[title="学院"],#csdn-toolbar li a[title="VIP会员"] {
    display: none;
}
`);

// 展开全文
var article = document.getElementById('article_content');
if (article) {
  article.style = ''
}

// 移除“阅读更多”按钮
var btn = document.getElementById('btn-readmore');
btn.parentNode.parentNode.removeChild(btn.parentNode);

// 移除一堆无用元素
['asideNewArticle', 'asideColumn', 'asideCategory', 'asideArchive', 'asideHotArticle', 'asideNewComments', 'asideFooter'].forEach(function (id) {
  var el = document.getElementById(id);
  if (el) {
    el.parentNode.removeChild(el);
  }
})