CSDN-优化美化极简化-沉浸式阅读-免登录复制-去广告等

优化和美化CSDN浏览体验 - 沉浸式阅读、免登录复制、去广告等

当前为 2023-07-20 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         CSDN-Optimize-Beautify-Simplify
// @name:zh      CSDN-优化美化极简化-沉浸式阅读-免登录复制-去广告等
// @name:zh-CN   CSDN-优化美化极简化-沉浸式阅读-免登录复制-去广告等
// @name:zh-TW   CSDN-優化美化極簡化-沉浸式閱讀-免登入複製-去廣告等
// @name:en      Streamline and Beautify CSDN Browsing Experience
// @name:ja      CSDNブラウジング体験の合理化と美化 - 沈浸的読書、広告なしなど
// @name:fr      Rationaliser et embellir l'expérience de navigation CSDN
// @name:es      Simplificar y embellecer la experiencia de navegación de CSDN
// @name:de      Optimieren und verschönern Sie das CSDN-Browsen 
// @name:it      Semplificare e abbellire l'esperienza di navigazione CSDN
// @namespace    http://github.com/yuhanawa/UserScript
// @version      0.0.1.2
// @description         优化和美化CSDN浏览体验 - 沉浸式阅读、免登录复制、去广告等 
// @description:zh      优化和美化CSDN浏览体验 - 沉浸式阅读、免登录复制、去广告等 
// @description:zh-CN   优化和美化CSDN浏览体验 - 沉浸式阅读、免登录复制、去广告等 
// @description:zh-TW   優化和美化CSDN瀏覽體驗 - 沉浸式閱讀、免登录复制、去廣告等
// @description:en      Streamline and Beautify CSDN Browsing Experience -  Immersive Reading,Ad-free,etc.  
// @description:ja      CSDNブラウジング体験の合理化と美化 - 沈浸的読書、広告なしなど.
// @description:fr      Script utilisateur: Rationaliser et embellir l'expérience de navigation CSDN - Lecture immersive, sans publicité, etc.
// @description:es      Script de usuario: Simplificar y embellecer la experiencia de navegación de CSDN - Lectura inmersiva, sin anuncios, etc.
// @description:de      Benutzer-Skript: Optimieren und verschönern Sie das CSDN-Browsen - immersives Lesen, werbefrei, etc.
// @description:it      Script utente: Semplificare e abbellire l'esperienza di navigazione CSDN - Lettura immersiva, senza pubblicità, ecc.
// @node         更新日志请见 https://github.com/yuhanawa/UserScript/blob/master/CHANGELOG.md
// @author       Yuhanawa
// @supportURL   https://greatest.deepsurf.us/zh-CN/scripts/471071/feedback
// @license      GPL-3.0
// @match        *://*.csdn.net/*
// @icon         none
// @run-at       document-start
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_addStyle
// @grant        GM_registerMenuCommand
// ==/UserScript==
function $get(k,d){return GM_getValue(k,d)}
function $set(k,v){return GM_setValue(k,v)}
function style(css){var node;"undefined"!=typeof GM_addStyle?GM_addStyle(css):((node=document.createElement("style")).appendChild(document.createTextNode(css)),document.body.appendChild(node))}
function option(name,key,options,current,index,onclick){return null!=current&&null!=index||(current=$set(key,getOptionKeyAndName(options[0]).key),index=options.indexOf(options.filter(x=>getOptionKeyAndName(x).key==current)[0])),-1!==index&&null!=index||($set(key,getOptionKeyAndName(options[0]).key),current=getOptionKeyAndName(options[index=0]).key),name+=`:${getOptionKeyAndName(options[index]).name}[${index+1}/${options.length}]<点击切换模式`,GM_registerMenuCommand(name,()=>{if(index+1>=options.length?$set(key,getOptionKeyAndName(options[0]).key):$set(key,getOptionKeyAndName(options[index+1]).key),onclick)try{onclick()}catch{}location.reload()}),index}
function onload(f){isLoaded?f():document.addEventListener("DOMContentLoaded",()=>f())}
function timeoutOnLoad(f,t){onload(()=>setTimeout(()=>f(),t))}
function intervalOnLoad(f,timeout){onload(()=>setInterval(f,timeout))}
function delay(fn,time,interval){(interval?intervalOnLoad:timeoutOnLoad)(fn,time)}
function run(fts){void 0===fts&&(fts=features);for(const key of Object.keys(fts)){var feature=fts[key];0!=feature.match.filter(m=>"string"==typeof m?null!==window.location.href.match(m):m.test(window.location.href)).length&&addFeature(key,feature)}}
function addFeature(key,feature){console.log(feature);var name=feature.name,values=feature.values,options=Object.keys(values),key0=getOptionKeyAndName(options[0]).key;let current=$get(key,key0),index=options.indexOf(options.filter(x=>getOptionKeyAndName(x).key==current)[0]);-1!==index&&null!=index||($set(key,key0),index=0,current=key0),option(name,key,options,current,index);try{var result,value=values[options[index]];null!=value&&("function"==typeof value?"string"==typeof(result=value(feature))&&style(result):"string"==typeof value?style(value):console.error(`出现了不应该出现的类型: ${typeof value} `+value))}catch(e){console.error(e)}}
function getOptionKeyAndName(optionStr){var key=optionStr.match(/\$([^ ]+)/)?.[0];return key?{key:key.replace("$",""),name:optionStr.replace(key,"")}:{key:optionStr,name:optionStr}}isLoaded=!1,onload(()=>isLoaded=!0);
let features_csdn_6433={
	csdn_csdn_toolbox:{name:"CSDN底部不跟随",match:[/blog\.csdn\.net\/.*\/article\/details/],values:{"已开启$on":()=>`.left-toolbox{
          z-index: 996!important;
          left: 0px!important;
          bottom: 0px!important;
          width: 900px!important;
          position: relative!important;
        }`,"已关闭":null}},
	csdn_csdn_remove_header:{name:"CSDN移除顶部",match:[/blog\.csdn\.net\/.*\/article\/details/],values:{"已关闭$off":null,"已开启$on":()=>"#csdn-toolbar{ display: none!important; }"}},
	csdn_csdn_opt:{name:"CSDN极简化",match:[/blog\.csdn\.net\/.*\/article\/details/],values:{"已开启$on":()=>(timeoutOnLoad(()=>{document.getElementsByClassName("option-box")[0].remove(),document.getElementsByClassName("option-box")[0].remove(),document.getElementsByClassName("option-box")[0].remove();var taghtml=document.getElementsByClassName("blog-tags-box")[0].outerHTML+"";document.getElementsByClassName("blog-tags-box")[0].remove(),document.getElementsByClassName("article-bar-top")[0].innerHTML=document.getElementsByClassName("article-bar-top")[0].innerHTML+taghtml,document.getElementsByClassName("time")[0].innerHTML=document.getElementsByClassName("time")[0].innerHTML.replace("于&nbsp;","").replace("&nbsp;发布",""),document.getElementsByClassName("left-toolbox")[0].style.left="auto",document.getElementsByClassName("blog-tags-box")[0].innerHTML=document.getElementsByClassName("blog-tags-box")[0].innerHTML.replaceAll(":","")},100),"#blogColumnPayAdvert,#dmp_ad_58,#recommendNps,.article-type-img,.blog-footer-bottom,.hide-article-box,.hide-preCode-box,.passport-login-container,.recommend-item-box,.recommend-right,.sidecolumn,.template-box,aside{display:none!important}#article_content,#mainBox,.article-bar-top,.article-info-box,header div.article-info-box div.blog-tags-box .tags-box.artic-tag-box a.tag-link,main div.blog-content-box .article-header-box .article-header div.article-info-box div.blog-tags-box,main div.blog-content-box .article-header-box .article-header div.article-info-box div.blog-tags-box .tags-box{margin:auto;width:auto!important;height:auto!important;padding:0!important;overflow:hidden}.tag-link{margin:5px 0 0!important;overflow:hidden}main div.blog-content-box article{padding-top:10px}main div.blog-content-box .article-header-box .article-header div.article-info-box div.article-bar-top span{margin-right:4px}main div.blog-content-box .article-header-box .article-header div.article-info-box div.article-bar-top .follow-nickName{margin-right:2px}main div.blog-content-box .article-header-box .article-header div.article-info-box div.article-bar-top .bar-conten{padding-left:0;margin-left:10px}pre .hljs-button{display:block;position:absolute;right:4px;top:4px;font-size:12px;color:#fff;background-color:#666;padding:4px 12px;margin:8px;border-radius:4px;cursor:pointer;box-shadow:0 2px 4px rgb(0 0 0/5%),0 2px 4px rgb(0 0 0/5%)}main div.blog-content-box pre.set-code-hide{height:auto!important}"),"已关闭$off":null}},
	csdn_csdn_header:{name:"CSDN顶部不跟随",match:[/blog\.csdn\.net\/.*\/article\/details/],values:{"已开启$on":()=>"#csdn-toolbar{position: static !important;}","已关闭":null}},
	csdn_csdn_copy:{name:"CSDN免登录复制",match:[/blog\.csdn\.net\/.*\/article\/details/],values:{"已开启$on":()=>{timeoutOnLoad(()=>{document.querySelectorAll("code").forEach(c=>{c.contentEditable="true"}),document.querySelectorAll(".hljs-button").forEach(e=>{e.setAttribute("data-title","点击复制"),e.classList.remove("signin"),e.removeAttribute("onclick"),e.addEventListener("click",()=>{e.setAttribute("data-title"," "),navigator.clipboard.writeText(e.parentNode.innerText),e.setAttribute("data-title","复制成功"),setTimeout(()=>e.setAttribute("data-title","点击复制"),1200)})},250),document.addEventListener("keydown",e=>{e.ctrlKey&&67==e.keyCode&&(e.stopPropagation(),e.preventDefault(),navigator.clipboard.writeText(window.getSelection().toString()))},!0)},500)},"已关闭$off":null}}
};

run(features_csdn_6433);