自动阅读全文;去广告;布局及格式优化;优化内容推荐展示样式;图片居中;删除空段落;去除首行缩进;支持MathJax。(修改自新版CSDN阅读体验提升)
当前为
// ==UserScript==
// @name CSDN阅读美化(新、旧版兼容)
// @namespace http://www.csdn.net/
// @icon https://favicon.yandex.net/favicon/csdn.net
// @version 0.0.6-20180307
// @description 自动阅读全文;去广告;布局及格式优化;优化内容推荐展示样式;图片居中;删除空段落;去除首行缩进;支持MathJax。(修改自新版CSDN阅读体验提升)
// @author zhuzhuyule
// @license GPL version 3
// @match http://blog.csdn.net/*
// @grant none
// @run-at document-body
// ==/UserScript==
(function() {
'use strict';
//初始化一个 document.ready 事件
(function () {
var ie = !!(window.attachEvent && !window.opera);
var wk = /webkit\/(\d+)/i.test(navigator.userAgent) && (RegExp.$1 < 525);
var fn = [];
var run = function () {
for (var i = 0; i < fn.length; i++) fn[i]();
};
var d = document;
d.ready = function (f) {
if (!ie && !wk && d.addEventListener)
return d.addEventListener('DOMContentLoaded', f, false);
if (fn.push(f) > 1) return;
if (ie)
(function () {
try {
d.documentElement.doScroll('left');
run();
}
catch (err) {
setTimeout(arguments.callee,0);
}
})();
else if (wk)
var t = setInterval(function () {
if (/^(loaded|complete)$/.test(d.readyState)){
clearInterval(t);
run();
}
}, 0);
};
})();
function addStyle() {
var s='';
//公共部分
s+='*{transition: opacity 1s, width 1s;}';
s+='h1 { "text-align": "center"; }';
s+='.article_content p { margin:1em 0; "line-height": "1.75em";"color":"#2F2F2F"}';
s+='.recommend_list { height: 90px; overflow-y: hidden; opacity:.2; }';
s+='.recommend_list.show { height:auto; overflow-y: visible;opacity:.2; }';
s+='.recommend_list:hover { opacity:1; }';
s+='.pulllog-box { display:none !important; }';
s+='article::after{content:"— The End —";color:#e0e0e0;text-align:center;width:100%;line-height:60px;margin-top:-40px;display:block;font-family:Monotype Corsiva,Blackadder ITC,Brush Script MT,Bradley Hand ITC,Bell MT;font-size:1.6em;padding-bottom:.6em;}';
//旧版本
s+='#homepageArticles { display: none !important; }';
s+='#nav_show_top_stop { display: none !important; }';
s+='#layerd { display: none !important; }';
s+='.QRcodebg1 { display: none !important; }';
s+='#com-quick-reply,#com-quick-collect,#com-d-top-a { min-width: 30px !important; width: 31px !important;}';
s+='#com-quick-reply:hover,#com-quick-collect:hover,#com-d-top-a:hover { width: 90px !important;}';
//新版本
s+='.fixRight,.extension_other,.fixRight_box,.persion_article { display: none !important;}';
s+='.article_content,.article_content p,.article_content p span:not([class^=MathJax] span):not([class^=MathJax]):not([id^=MathJax] span):not([id^=MathJax]) {"font-family": "Microsoft YaHei,Consolas";"font-size": "15px" }';
s+='.article_content p .MathJax { "font-size": "16px"; }';
s+='.article_content p img{ "display": "block";"margin": "0 auto" }';
//添加样式到 Head 中
var head = document.head || document.getElementsByTagName('head')[0];
if (head) {
var style = document.createElement("style");
style.type = "text/css";
style.appendChild(document.createTextNode(s));
head.appendChild(style);
}
}
try {
//修改原来烦人的样式
addStyle();
document.ready(function(){
//自动展开全文
var btnMore = document.querySelector('.readall_box a.btn.read_more_btn');
if (btnMore)
btnMore.click();
//优化推荐列表显示效果
var recommendList = document.querySelector('.recommend_list');
if (recommendList){
var func = function(){
this.classList.add('show');
recommendList.removeEventListener('mousemove',func);
};
recommendList.addEventListener('mousemove',func);
}
//删除空白段落
var paragraph = document.querySelectorAll('.article_content p');
paragraph.forEach(function(item){
if(!item.innerText.trim() && !item.querySelector('img,a') )
item.parentElement.removeChild(item);
});
});
} catch (e) {
console.log(e);
}
})();