CSDN-Optimize-Beautify-Simplify

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

Per 25-08-2023. Zie de nieuwste versie.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==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.1.20
// @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://greasyfork.org/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
// @match	*://yuhan-script-config.netlify.app/*
// @match	*://user-script-config-form.vercel.app/*
// @grant	unsafeWindow
// ==/UserScript==

/* 
    csdn v.0.1.20 by Yuhanawa
    Build with the framework: https://github.com/Yuhanawa/UserScript/tree/master/framework/
    It doesn't have a good name, temporarily called banana.
*/

isLoaded=!1,onload(()=>isLoaded=!0);const __props__=new Map;
function $get(k,d){return void 0===d?GM_getValue(k,__props__.get(k)):GM_getValue(k,d)}
function $set(k,v){return GM_setValue(k,v)}
function loadConfig(name,properties){GM_registerMenuCommand("打开设置中心(vercel|如果打不开点下一个)",()=>{location.href="https://user-script-config-form.vercel.app"}),GM_registerMenuCommand("打开设置中心(netlify|如果打不开点上一个)",()=>{location.href="https://yuhan-script-config.netlify.app"}),Object.keys(properties).forEach(key=>__props__.set(name+"_"+key,properties[key].default)),(location.href.match("yuhan-script-config.netlify.app")||location.href.match("user-script-config-form.vercel.app")||location.href.match("localhost"))&&(null==unsafeWindow.banana&&(unsafeWindow.banana={}),unsafeWindow.banana[name]={props:properties,get:$get,set:$set})}
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){var{name,values}=feature;if("$"===name)try{"function"==typeof values?"string"==typeof(result=values(feature))&&style(result):"string"==typeof values&&style(value)}catch(e){console.error(e)}else{var result=Object.keys(values),key0=getOptionKeyAndName(result[0]).key;let current=$get(key,key0),index=result.findIndex(x=>getOptionKeyAndName(x).key===current);-1!==index&&null!=index||($set(key,key0),index=0,current=key0),option(name,key,result,current,index);try{const value=values[result[index]];if(null!==value&&void 0!==value)if("function"==typeof value){const result=value(feature);"string"==typeof result&&style(result)}else"string"==typeof value&&style(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}}


loadConfig('csdn', {"line_ts":{"widget":"line","title":"如果发现某条设置存在问题请反馈: https://greasyfork.org/zh-CN/scripts/471071/feedback/"},"line_bc":{"widget":"line","title":"❗❗❗修改完记得点保存(在最下面)❗❗❗"},"copy":{"title":"免登录复制","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"opt":{"title":"极简化|沉浸式阅读","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"width":{"title":"调整文章宽度(前置功能:极简化)","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"width_value":{"title":"文章宽度(前置功能:调整文章宽度)","default":"82","description":"单位:%|百分比"},"header":{"title":"顶部菜单栏不跟随","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"remove_header":{"title":"文章页移除顶部菜单栏","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"toolbox":{"title":"低部菜单工具栏不跟随","default":"remove","widget":"select","props":{"options":[{"label":"移除","value":"remove"},{"label":"不跟随","value":"relative"},{"label":"关闭","value":"off"}]}},"line_fz":{"widget":"line","title":"调整字体大小"},"fontsize":{"title":"调整字体大小","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"font_size_title":{"title":"标题","default":"32px"},"font-size-p":{"title":"正文","default":"18px"},"font-size-h2":{"title":"子标题","default":"24px"},"font_size_code":{"title":"代码","default":"15px"},"line_bg":{"widget":"line","title":"自定义背景"},"background":{"title":"自定义背景(总开关)","default":"off","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"background-value":{"title":"页面背景","description":"body的背景","default":"url(\"https://csdnimg.cn/release/blogv2/dist/pc/themesSkin/skin-code/images/bg.png?v20200831\")"},"blog-content-box-background-value":{"title":"文章背景","description":"用于放置文章的div颜色","default":"rgb(245 246 247 / 90%)"},"blog-content-box-opacity-value":{"title":"文章透明度","description":"文章整体透明度,包括文章内容","default":"0.98"},"header-box-background-value":{"title":"文章标题及部分卡片背景","description":"建议保持透明或使用高透明度颜色","default":"transparent"},"line_ui":{"widget":"line","title":"自定义开关每一个UI的","description":"开启为显示该模块,关闭为隐藏该模块"},"ui":{"title":"UI调整(总开关)","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"ui_toolbar":{"title":"顶部菜单","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"ui_toolbar_container_middle":{"title":"搜索框","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"ui_toolbar_container_right":{"title":"搜索框右侧","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"ui_toolbar_btn_vip":{"title":"会员中心","default":"off","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"ui_asideProfile":{"title":"作者档案","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"ui_asideSearchArticle":{"title":"搜索作者文章","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"ui_asideHotArticle":{"title":"热门文章","default":"off","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"ui_asideCategory":{"title":"分类专栏","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"ui_asideNewComments":{"title":"最新评论","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"ui_asideNewNps":{"title":"您愿意向朋友推荐“博客详情页”吗","default":"off","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"ui_asideArchive":{"title":"最新文章","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"ui_asidedirectory":{"title":"文章目录","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"ui_copyright_box":{"title":"copyright-box","default":"off","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"ui_recommendNps":{"title":"“相关推荐”对你有帮助么","default":"off","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"ui_recommend_box":{"title":"文章推荐","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"ui_toolBarBox":{"title":"下方工具栏","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}}})

let features_csdn_8661={
	csdn_ui:{name:"UI调整 | 设置中可开关每个UI",match:["csdn.net"],values:{"已开启$on":()=>{var add=(key,selector,defaultBool)=>{"off"===$get(key,null==defaultBool||defaultBool?"on":"off")&&style(selector+"{display: none !important;}")
};add("csdn_ui_toolbar",".csdn-toolbar",!0),add("csdn_ui_toolbar_container_left",".toolbar_container_left",!0),add("csdn_ui_toolbar_container_middle",".toolbar_container_middle",!0),add("csdn_ui_toolbar_container_right",".toolbar_container_right",!0),add("csdn_ui_toolbar_btn_vip",".toolbar_btn_vip",!1),add("csdn_ui_asideProfile","#asideProfile",!0),add("csdn_ui_asideSearchArticle","#asideSearchArticle",!0),add("csdn_ui_asideHotArticle","#asideHotArticle",!1),add("csdn_ui_asideCategory","#asideCategory",!0),add("csdn_ui_asideNewComments","#asideNewComments",!0),add("csdn_ui_asideNewNps","#asideNewNps",!1),add("csdn_ui_asideArchive","#asideArchive",!0),add("csdn_ui_asidedirectory","#asidedirectory",!0),add("csdn_ui_copyright_box","#copyright_box",!1),add("csdn_ui_recommendNps","#recommendNps",!1),add("csdn_ui_recommend_box",".recommend_box",!0),add("csdn_ui_toolBarBox","#toolBarBox",!0)},"已关闭$off":null}},
	csdn_toolbox:{name:"底部不跟随或移除",match:[/blog\.csdn\.net(\/.*)?\/article\/details./],values:{"移除$remove":()=>`.left-toolbox{
          display: none!important;
        }`,"不跟随$relative":()=>`.left-toolbox{
          z-index: 996!important;
          left: 0px!important;
          bottom: 0px!important;
          width: 900px!important;
          position: relative!important;
        }`,"已关闭$off":null}},
	csdn_setting_btn:{name:"设置按钮",match:[/blog\.csdn\.net(\/.*)?\/article\/details./],values:{"已开启$on":()=>{timeoutOnLoad(()=>{var articleTitleBox=document.getElementsByClassName("article-title-box")[0],settingButton=document.createElement("a");settingButton.innerText="脚本设置",settingButton.href="https://yuhan-script-config.netlify.app",settingButton.target="_blank",settingButton.style="float: right;margin: 12px;font-size: 20px;text-decoration: underline !important;color: #4ea1db;",articleTitleBox.insertAdjacentElement("afterbegin",settingButton)},200)},"已关闭$off":null}},
	csdn_opt:{name:"极简化",match:[/blog\.csdn\.net(\/.*)?\/article\/details./],values:{"已开启$on":()=>(timeoutOnLoad(()=>{try{document.getElementsByClassName("option-box")[0].remove(),document.getElementsByClassName("option-box")[0].remove(),document.getElementsByClassName("option-box")[0].remove()}catch{}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),"on"===$get("csdn_width","on")&&(style("#mainBox > main{ width: 100% !important; }"),style(`body #mainBox{ width: ${$get("csdn_width_value","82")}% !important; }`)),"#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}.article-info-box{opacity:.92}#rightAsideConcision,.directory{display:none!important}"),"已关闭$off":null}},
	csdn_header:{name:"移除顶部或不跟随或淡化",match:[/blog\.csdn\.net(\/.*)?\/article\/details./],values:{"移除$remove":"#csdn-toolbar{ display: none!important; }","淡化不跟随$opacity":"#csdn-toolbar{position: static !important; opacity: 0.55;}","不跟随$static":"#csdn-toolbar{position: static !important;}","已关闭$off":null}},
	csdn_fontsize:{name:"调整字体大小",match:["csdn.net"],values:{"已开启$on":()=>(style(`body{--font-size-title: ${$get("csdn_font_size_title","32px")
};--font-size-p: ${$get("csdn_font_size_p","18px")
};--font-size-h2: ${$get("csdn_font_size_h2","24px")
};--font-size-code: ${$get("csdn_font_size_code","15px")
};}`),"html{--font-size-title:36px;--font-size-p:18px;--font-size-h2:24px;--font-size-code:15px}html body main div.blog-content-box .article-header-box .article-header div.article-title-box .title-article{font-size:var(--font-size-title)!important}html body main #content_views p{font-size:var(--font-size-p)!important}html body main #content_views h2{font-size:var(--font-size-h2)!important}html body main #content_views pre code{font-size:var(--font-size-code)!important}"),"已关闭$off":null}},
	csdn_copy:{name:"免登录复制",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}},
	csdn_background:{name:"自定义背景",match:[/blog\.csdn\.net(\/.*)?\/article\/details./],values:{"已关闭$off":null,"已开启$on":()=>(style(`body{--background:${$get("csdn-background-value",'url("https://csdnimg.cn/release/blogv2/dist/pc/themesSkin/skin-code/images/bg.png?v20200831")')}}`),style(`body{--blog-content-box-background:${$get("csdn-blog-content-box-background-value","rgb(245 246 247 / 90%)")}}`),style(`body{--blog-content-box-opacity:${$get("csdn-blog-content-box-opacity-value","0.98")}}`),style(`body{--blog-header-box-background:${$get("csdn-blog-header-box-background-value","transparent")}}`),":root body{background:var(--background)}:root body .blog-content-box{background:var(--blog-content-box-background)!important;opacity:var(--blog-content-box-opacity)!important}:root body #blogColumnPayAdvert,:root body #blogHuaweiyunAdvert,:root body .article-header-box{background-color:var(--blog-header-box-background)!important}")}},
	csdn_ad:{name:"去广告",match:["csdn.net"],values:{"已开启$on":()=>"#ad_iframe,#ad_unit,#mainBox>aside>div.box-shadow.mb8,.GoogleActiveViewElement,.GoogleActiveViewInnerContainer,.adsbygoogle{display:none!important;visibility:hidden!important;width:0!important;height:0!important}","已关闭$off":null}}
};
run(features_csdn_8661);