Greasy Fork is available in English.

CSDN-Optimize-Beautify-Simplify

剥茧化绸,使 CSDN 重现柔曼如丝的新颜; 优化美化CSDN体验-个性化-免登录复制-沉浸式阅读-去广告等

Versione datata 03/05/2024. Vedi la nuova versione l'ultima versione.

  1. // ==UserScript==
  2. // @name CSDN-Optimize-Beautify-Simplify
  3. // @name:zh CSDN-美化增强-免登录复制-沉浸式阅读-去广告等[茧绡]
  4. // @name:en Streamline and Beautify CSDN Browsing Experience[Cocoon Silk]
  5. // @name:ja CSDNブラウジング体験の合理化と美化 - 沈浸的読書、広告なしなど[茧絲(けむりし)]
  6. // @namespace http://github.com/yuhanawa/UserScript
  7. // @name:zh-CN CSDN-美化增强-免登录复制-沉浸式阅读-去广告等[茧绡]
  8. // @name:zh-TW CSDN-美化增强-免登入複製-沉浸式閱讀-去廣告等[茧绡]
  9. // @description 剥茧化绸,使 CSDN 重现柔曼如丝的新颜; 优化美化CSDN体验-个性化-免登录复制-沉浸式阅读-去广告等
  10. // @description:zh 剥茧化绸,使 CSDN 重现柔曼如丝的新颜; 优化美化CSDN体验-个性化-免登录复制-沉浸式阅读-去广告等
  11. // @description:en Shedding the cocoon, CSDN emerges with a soft, silken radiance anew - Streamline and Beautify CSDN Browsing Experience - Immersive Reading,Ad-free,etc.
  12. // @description:ja 茧を脱ぎ捨て、CSDNは新たに絹のように柔らかな輝きを放-CSDNブラウジング体験の合理化と美化 - 沈浸的読書、広告なしなど.
  13. // @description:zh-CN 剥茧化绸,使 CSDN 重现柔曼如丝的新颜; 优化美化CSDN体验-个性化-免登录复制-沉浸式阅读-去广告等
  14. // @description:zh-TW 剥茧化绸,使 CSDN 重现柔曼如丝的新颜; 優化和美化CSDN瀏覽體驗 - 沉浸式閱讀、免登录复制、去廣告等
  15. // @grant GM_setValue
  16. // @grant GM_getValue
  17. // @grant GM_addStyle
  18. // @grant GM_registerMenuCommand
  19. // @grant GM_openInTab
  20. // @grant unsafeWindow
  21. // @match *://*.csdn.net/*
  22. // @match *://yuhan-script-config.netlify.app/*
  23. // @match *://user-script-config-form.vercel.app/*
  24. // @match *://yuhanawa.github.io/tools/userscriptconfig/*
  25. // @version 0.1.50
  26. // @author Yuhanawa
  27. // @supportURL https://greatest.deepsurf.us/zh-CN/scripts/471071/feedback
  28. // @license GPL-3.0
  29. // @icon none
  30. // @run-at document-start
  31. // ==/UserScript==
  32.  
  33. /*
  34. csdn v.0.1.50 by Yuhanawa
  35. Source: https://github.com/Yuhanawa/UserScript
  36. */
  37.  
  38. isLoaded=!1,onload(()=>isLoaded=!0);const __props__=new Map;
  39. function get(k,d){return GM_getValue(k,void 0===d?__props__.get(k):d)}
  40. function set(k,v){return GM_setValue(k,v)}
  41. function cfg(k,v){return void 0===v?get(k):set(k,v)}
  42. function getOptionKeyAndName(optionStr){var key=optionStr.match(/\$([^ ]+)/)?.[0];return key?{key:key.replace("$",""),name:optionStr.replace(key,"")}:{key:optionStr,name:optionStr}}
  43. function style(css){var node;"undefined"!=typeof GM_addStyle?GM_addStyle(css):((node=document.createElement("style")).appendChild(document.createTextNode(css)),document.body.appendChild(node))}
  44. function addMenu(name,key,options,current,index,onclick){const getOptionKey=o=>getOptionKeyAndName(o).key;void 0!==current&&null!=index&&-1!==index||(current=set(key,getOptionKey(options[0])),index=0);var o=`${name}:${o=options[index],getOptionKeyAndName(o).name}[${index+1}/${options.length}]<点击切换`;return GM_registerMenuCommand(o,()=>{if(set(key,getOptionKey(options[index+1>=options.length?0:index+1])),onclick)try{onclick()}catch(e){console.log(`发生错误(${name}-${current}-onclick): `+e)}location.reload()}),index}
  45. function onload(f){isLoaded?f():document.addEventListener("DOMContentLoaded",()=>f())}
  46. function timeoutAfterLoad(f,t){onload(()=>setTimeout(()=>f(),t))}
  47. function intervalAfterLoad(f,t,runOnFirst){onload(()=>{runOnFirst&&f(),setInterval(f,t)})}
  48. function run(fts){void 0===fts&&(fts=features);for(const key of Object.keys(fts))try{const feature=fts[key];("boolean"==typeof feature.match&&1==feature.match||0!==feature.match.filter(m=>"string"==typeof m?null!==window.location.href.match(m):m.test(window.location.href)).length)&&addFeature(key,feature)}catch(error){console.error("发生了一个意料之外的错误, 这可能是因为非法的feature所造成的, 不过请放心, 脚本将继续运行而不会崩溃. ",feature,error)}}
  49. function addFeature(key,feature){var{name,values}=feature;if(!feature.switchable||get(key+"_switch",feature.default_switch_state??!0))if("$"===name||feature.directlyRun)try{"function"==typeof values?"string"==typeof(result=values(feature))&&style(result):"string"==typeof values&&style(values)}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&&void 0!==index||(set(key,key0),index=0,current=key0),feature.hideInMenu||addMenu(name,key,result,current,index);try{var value=values[result[index]];if(null!=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)}}}
  50. function findFastestSite(sites){return new Promise((resolve,reject)=>{let fastestSite=null,fastestTime=1/0,completedRequests=0;sites.forEach(function(site){const xhr=new XMLHttpRequest,startTime=(new Date).getTime();xhr.onreadystatechange=()=>{var timeElapsed;fastestTime<100&&(xhr.abort(),resolve(fastestSite)),xhr.readyState===XMLHttpRequest.DONE&&(timeElapsed=(new Date).getTime()-startTime,console.log(`Ping ${site} took ${timeElapsed}ms`),console.log("Status: "+xhr.status),xhr.status<400&&timeElapsed<fastestTime&&(fastestTime=timeElapsed,fastestSite=site),++completedRequests===sites.length)&&resolve(fastestSite)},xhr.onprogress=()=>{fastestTime<100&&(xhr.abort(),resolve(fastestSite))},xhr.onload=()=>{console.log("Pinging "+site)},xhr.open("GET",site,!0),xhr.timeout=2e3,xhr.send()})})}
  51. function getConfigPage(){return findFastestSite(["https://user-script-config-form.vercel.app","https://yuhan-script-config.netlify.app","https://yuhanawa.github.io/tools/userscriptconfig/"]).then(fastestSite=>fastestSite).catch(error=>(console.error("Error:",error),null))}
  52. function showConfigPage(){getConfigPage().then(fastestSite=>{void 0!==GM_openInTab?GM_openInTab(fastestSite,{active:!0}):location.href=fastestSite})}
  53. function LoadConfigPage(name){console.log("LoadConfigPage "+name)}
  54. function loadConfig(name,properties){GM_registerMenuCommand("在新窗口打开设置中心",()=>{showConfigPage()}),GM_registerMenuCommand("在页面内镶嵌设置中心(BETA)",()=>{loadconfigComponent()}),anchors=[];for(const key of Object.keys(properties))__props__.set(name+"_"+key,properties[key].default),key.startsWith("#")&&anchors.push({key:key,href:properties[key].href||key,title:properties[key].title||properties[key].description||key});void 0!==unsafeWindow.awa&&void 0!==unsafeWindow.awa.userscript||(unsafeWindow.awa={},unsafeWindow.awa.userscript={}),unsafeWindow.awa.current=name,unsafeWindow.awa.userscript[name]={props:properties,anchors:anchors,get:get,set:set}}
  55. function loadconfigComponent(){unsafeWindow.useNewConfig=!0;var head=unsafeWindow.document.head,reactScript=document.createElement("script");reactScript.src="https://cdn.jsdelivr.net/npm/react@18.2.0/umd/react.production.min.js",head.appendChild(reactScript);const reactDOMScript=document.createElement("script");reactDOMScript.src="https://cdn.jsdelivr.net/npm/react-dom@18.2.0/umd/react-dom.production.min.js",head.appendChild(reactDOMScript);var commonStyles=document.createElement("link"),commonStyles=(commonStyles.rel="stylesheet",commonStyles.href="https://cdn.jsdelivr.net/gh/Yuhanawa/UserScript/config-component/dist/assets/css/common.css",head.appendChild(commonStyles),document.createElement("link")),commonStyles=(commonStyles.rel="stylesheet",commonStyles.href="https://cdn.jsdelivr.net/gh/Yuhanawa/UserScript/config-component/dist/assets/css/vendor.css",head.appendChild(commonStyles),document.createElement("link"));commonStyles.rel="stylesheet",commonStyles.href="https://cdn.jsdelivr.net/gh/Yuhanawa/UserScript/config-component/dist/assets/css/index.css",head.appendChild(commonStyles);const addscript=head=>{var indexModule=document.createElement("script"),indexModule=(indexModule.type="module",indexModule.crossOrigin=!0,indexModule.src="https://cdn.jsdelivr.net/gh/Yuhanawa/UserScript/config-component/dist/assets/js/index.js",head.appendChild(indexModule),document.createElement("script")),indexModule=(indexModule.type="module",indexModule.crossOrigin=!0,indexModule.src="https://cdn.jsdelivr.net/gh/Yuhanawa/UserScript/config-component/dist/assets/js/index.js",head.appendChild(indexModule),document.createElement("link")),indexModule=(indexModule.rel="modulepreload",indexModule.crossOrigin=!0,indexModule.href="https://cdn.jsdelivr.net/gh/Yuhanawa/UserScript/config-component/dist/assets/js/common.js",head.appendChild(indexModule),document.createElement("link"));indexModule.rel="modulepreload",indexModule.crossOrigin=!0,indexModule.href="https://cdn.jsdelivr.net/gh/Yuhanawa/UserScript/config-component/dist/assets/js/vendor.js",head.appendChild(indexModule),document.getElementById("config-component-root").appendChild(document.createElement("config-component"));const configPage=document.querySelector("#config-component-shadow"),container=configPage.querySelector("#config-component-root"),iframe=configPage.querySelector(".config-component");var pos1=0,pos2=0,pos3=0,pos4=0;
  56. function elementDrag(e){(e=e||window.event).preventDefault(),pos1=pos3-e.clientX,pos2=pos4-e.clientY,pos3=e.clientX,pos4=e.clientY,container.style.top=container.offsetTop-pos2+"px",container.style.left=container.offsetLeft-pos1+"px"}
  57. function closeDragElement(){iframe.style.pointerEvents="auto",configPage.onmouseup=null,configPage.onmousemove=null}container.onmousedown=function(e){(e=e||window.event).preventDefault(),pos3=e.clientX,pos4=e.clientY,iframe.style.pointerEvents="none",configPage.onmouseup=closeDragElement,configPage.onmousemove=elementDrag}};head=document.createElement("div"),head.id="config-component-shadow",document.body.appendChild(head),commonStyles=document.createElement("div");commonStyles.id="config-component-root",head.appendChild(commonStyles),reactScript.onload=()=>reactDOMScript.onload=()=>addscript(unsafeWindow.document.head)}
  58.  
  59.  
  60. loadConfig('csdn', {".line_ts":{"widget":"line","title":"如果发现某条设置存在问题请反馈: https://greatest.deepsurf.us/zh-CN/scripts/471071/feedback/"},".line_bc":{"widget":"line","title":"❗❗❗修改完记得点保存(在最下面)❗❗❗"},"copy":{"title":"免登录复制","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"beautify":{"title":"细节优化","default":true,"widget":"switch","type":"boolean"},"width":{"title":"调整文章宽度","description":"该功能仅当左侧边栏隐藏时生效","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"width_value":{"title":"文章宽度","description":"(单位:%|百分比) 该功能仅当左侧边栏隐藏时生效","default":"82","props":{"addonAfter":"%"},"hidden":"{{ formData.width === 'off' }}"},"header":{"title":"顶部菜单栏","default":"remove","widget":"select","props":{"options":[{"label":"移除","value":"remove"},{"label":"半透明","value":"opacity"},{"label":"淡化不跟随","value":"opacity_static"},{"label":"不跟随","value":"static"},{"label":"显示","value":"off"}]}},"toolbox":{"title":"低部菜单工具栏","default":"remove","widget":"select","props":{"options":[{"label":"移除","value":"remove"},{"label":"不跟随","value":"relative"},{"label":"半透明","value":"opacity"},{"label":"淡化不跟随","value":"opacity_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","hidden":"{{ formData.fontsize === 'off' }}"},"font-size-p":{"title":"正文","default":"18px","hidden":"{{ formData.fontsize === 'off' }}"},"font-size-h2":{"title":"子标题","default":"24px","hidden":"{{ formData.fontsize === 'off' }}"},"font_size_code":{"title":"代码块","default":"15px","hidden":"{{ formData.fontsize === 'off' }}"},"#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":"https://csdnimg.cn/release/blogv2/dist/pc/themesSkin/skin-code/images/bg.png?v20200831","hidden":"{{ formData.background === 'off' }}","widget":"imageInput","format":"image"},"blog-content-box-background-value":{"title":"文章背景","description":"用于放置文章的div颜色","default":"#f5f6f7E6","hidden":"{{ formData.background === 'off' }}","widget":"color"},"blog-content-box-opacity-value":{"title":"文章透明度","description":"文章整体透明度,包括文章内容","hidden":"{{ formData.background === 'off' }}","default":"0.98"},"header-box-background-value":{"title":"文章标题及部分卡片背景","description":"建议保持透明或使用高透明度颜色","hidden":"{{ formData.background === 'off' }}","default":"#00000000","widget":"color"},"#line_ui":{"widget":"line","title":"自定义UI","description":"自定义UI需将‘UI净化预设’设置为自定义模式"},"ui_opt":{"title":"UI净化预设","default":"lite","widget":"select","props":{"options":[{"label":"极简","value":"lite"},{"label":"简|作者+目录","value":"lite1"},{"label":"简|作者+目录+菜单","value":"lite2"},{"label":"简|以上信息+推荐","value":"lite3"},{"label":"常规","value":"normal"},{"label":"自定义","value":"custom"},{"label":"关闭","value":"off"}]}},"ui_opt_value":{"title":"自定义UI","description":"需要UI净化预设为自定义模式","default":["#asideArchive","#csdn-toolbar .toolbar-menus","#csdn-toolbar .toolbar-btn-vip","#footerRightAds","#asideProfile .item-rank","#asideProfile .aside-box-footer","#asideWriteGuide","#asideHotArticle","#asideNewComments","#asideNewNps","main .article-bar-top","main .article-title-box .article-type-img","#recommendNps","#commentBox","#pcCommentBox","#treeSkill","#blogVoteBox",".insert-baidu-box.recommend-box-style",".blog-footer-bottom",".sidetool-writeguide-box",".option-box[data-type=guide]",".option-box[data-type=cs]",".option-box[data-type=report]",".btn-side-chatdoc-contentbox","#csdn-toolbar .toolbar-logo","#csdn-toolbar .toolbar-container-left","#asideCategory",".first-recommend-box",".second-recommend-box",".recommend-box","#toolBarBox",".passport-login-container"],"widget":"CSDN_UI_editor","disabled":"{{ formData.ui_opt !== 'custom' }}"}})
  61.  
  62. let features_csdn_1114922075 = {
  63. csdn_ui_opt: {
  64. name: "净化",
  65. match: [/blog\.csdn\.net(\/.*)?\/article\/details./],
  66. values: {
  67. 极简$lite: (self) => {
  68. var value = [
  69. "#treeSkill",
  70. "#blogVoteBox",
  71. ".recommend-box",
  72. ".first-recommend-box",
  73. ".second-recommend-box",
  74. ".insert-baidu-box.recommend-box-style",
  75. "#recommendNps",
  76. "#commentBox",
  77. "#pcCommentBox",
  78. "#toolBarBox",
  79. ".blog-footer-bottom",
  80. "#rightAside",
  81. "#groupfile",
  82. "#rightAside .kind_person",
  83. ".sidetool-writeguide-box",
  84. ".option-box[data-type=guide]",
  85. ".option-box[data-type=cs]",
  86. ".option-box[data-type=report]",
  87. ".btn-side-chatdoc-contentbox",
  88. "#csdn-toolbar",
  89. "#mainBox .blog_container_aside",
  90. "#csdn-toolbar .toolbar-container-left",
  91. "#csdn-toolbar .toolbar-container-right",
  92. "#csdn-toolbar .toolbar-container-middle",
  93. "#blogExtensionBox .extension_official",
  94. "#asideProfile",
  95. "#footerRightAds",
  96. "#asideWriteGuide",
  97. "#asideSearchArticle",
  98. "#asideHotArticle",
  99. "#asideCategory",
  100. "#asideNewComments",
  101. "#asideNewNps",
  102. "#asideArchive",
  103. "#asidedirectory",
  104. ".passport-container-mini-tip",
  105. ".passport-login-container",
  106. ];
  107.  
  108. self.hide(value);
  109. },
  110. "简|作者+目录$lite1": (self) => {
  111. self.hide([
  112. ".passport-container-mini-tip",
  113. "#asideArchive",
  114. "#csdn-toolbar .toolbar-menus",
  115. "#csdn-toolbar .toolbar-btn-vip",
  116. "#csdn-toolbar .toolbar-btn-msg",
  117. "#csdn-toolbar .toolbar-btn-mp",
  118. "#csdn-toolbar .toolbar-btn-writet",
  119. "#blogExtensionBox .extension_official",
  120. "#footerRightAds",
  121. "#asideProfile .item-rank",
  122. "#asideProfile .aside-box-footer",
  123. "#asideWriteGuide",
  124. "#asideHotArticle",
  125. "#asideNewComments",
  126. "#asideNewNps",
  127. "main .article-bar-top",
  128. "main .article-title-box .article-type-img",
  129. "#recommendNps",
  130. "#commentBox",
  131. "#pcCommentBox",
  132. "#treeSkill",
  133. "#blogVoteBox",
  134. ".recommend-box",
  135. ".first-recommend-box",
  136. ".second-recommend-box",
  137. ".insert-baidu-box.recommend-box-style",
  138. ".blog-footer-bottom",
  139. "#toolBarBox",
  140. ".sidetool-writeguide-box",
  141. ".option-box[data-type=guide]",
  142. ".option-box[data-type=cs]",
  143. ".option-box[data-type=report]",
  144. ".btn-side-chatdoc-contentbox",
  145. "#csdn-toolbar .toolbar-logo",
  146. "#csdn-toolbar .toolbar-container-left",
  147. "#asideProfile .data-info",
  148. "#asideCategory",
  149. ".passport-login-container",
  150. ]);
  151. },
  152. "简|作者+目录+菜单$lite2": (self) => {
  153. self.hide([
  154. ".passport-container-mini-tip",
  155. "#asideArchive",
  156. "#csdn-toolbar .toolbar-menus",
  157. "#csdn-toolbar .toolbar-btn-vip",
  158. "#footerRightAds",
  159. "#asideProfile .item-rank",
  160. "#asideProfile .aside-box-footer",
  161. "#asideWriteGuide",
  162. "#asideHotArticle",
  163. "#asideNewComments",
  164. "#asideNewNps",
  165. "main .article-bar-top",
  166. "main .article-title-box .article-type-img",
  167. "#recommendNps",
  168. "#commentBox",
  169. "#pcCommentBox",
  170. "#treeSkill",
  171. "#blogVoteBox",
  172. ".insert-baidu-box.recommend-box-style",
  173. ".blog-footer-bottom",
  174. ".sidetool-writeguide-box",
  175. ".option-box[data-type=guide]",
  176. ".option-box[data-type=cs]",
  177. ".option-box[data-type=report]",
  178. ".btn-side-chatdoc-contentbox",
  179. "#csdn-toolbar .toolbar-logo",
  180. "#csdn-toolbar .toolbar-container-left",
  181. "#asideCategory",
  182. ".first-recommend-box",
  183. ".second-recommend-box",
  184. ".recommend-box",
  185. "#toolBarBox",
  186. ".passport-login-container",
  187. ]);
  188. },
  189. "简|以上信息+推荐$lite3": (self) => {
  190. self.hide([
  191. ".passport-container-mini-tip",
  192. "#asideArchive",
  193. "#csdn-toolbar .toolbar-btn-vip",
  194. "#footerRightAds",
  195. "#asideProfile .item-rank",
  196. "#asideProfile .aside-box-footer",
  197. "#asideWriteGuide",
  198. "#asideHotArticle",
  199. "#asideNewComments",
  200. "#asideNewNps",
  201. "main .article-bar-top",
  202. "main .article-title-box .article-type-img",
  203. "#recommendNps",
  204. "#treeSkill",
  205. "#blogVoteBox",
  206. ".insert-baidu-box.recommend-box-style",
  207. ".blog-footer-bottom",
  208. ".sidetool-writeguide-box",
  209. ".option-box[data-type=guide]",
  210. ".option-box[data-type=cs]",
  211. ".option-box[data-type=report]",
  212. ".btn-side-chatdoc-contentbox",
  213. "#asideCategory",
  214. "#toolBarBox",
  215. "#csdn-toolbar .toolbar-menus",
  216. "#csdn-toolbar .toolbar-logo",
  217. "#csdn-toolbar .toolbar-container-left",
  218. ]);
  219. },
  220. 常规$normal: (self) => {
  221. var value = [
  222. "#csdn-toolbar .toolbar-logo",
  223. "#csdn-toolbar .toolbar-btn-mp",
  224. "#csdn-toolbar .toolbar-btn-write",
  225. "#csdn-toolbar .toolbar-btn-msg",
  226. "#csdn-toolbar .toolbar-btn-vip",
  227. "#asideProfile .profile-intro-name-boxOpration",
  228. "#asideProfile .aside-box-footer",
  229. "#asideProfile .item-rank",
  230. "#footerRightAds",
  231. "#asideWriteGuide",
  232. "#asideHotArticle",
  233. "#asideNewComments",
  234. "#asideNewNps",
  235. "#asideArchive",
  236. "#asideSearchArticle",
  237. "main .article-title-box .article-type-img",
  238. "#treeSkill",
  239. "#blogVoteBox",
  240. ".insert-baidu-box.recommend-box-style",
  241. "#recommendNps",
  242. "#commentBox",
  243. ".blog-footer-bottom",
  244. "#rightAside .kind_person",
  245. ".sidetool-writeguide-box",
  246. ".option-box[data-type=guide]",
  247. ".option-box[data-type=cs]",
  248. ".option-box[data-type=report]",
  249. ".btn-side-chatdoc-contentbox",
  250. ".passport-container-mini-tip",
  251. ".passport-login-container",
  252. ];
  253.  
  254. self.hide(value);
  255. },
  256. 自定义$custom: () => {
  257. style(
  258. `${get("csdn_ui_opt_value")} { display: none !important; width: 0 !important; height: 0 !important; visibility: collapse !important; }`,
  259. );
  260. },
  261. 已关闭$off: () => {},
  262. },
  263. hide: (value) => {
  264. style(
  265. `${value.join(", ")} { display: none !important; width: 0 !important; height: 0 !important; visibility: collapse !important; }`,
  266. );
  267. },
  268. },
  269. csdn_toolbox: {
  270. name: "低部菜单工具栏",
  271. match: [/blog\.csdn\.net(\/.*)?\/article\/details./],
  272. values: {
  273. 移除$remove: `.left-toolbox{
  274. display: none!important;
  275. }`,
  276. 不跟随$relative: `.left-toolbox{
  277. z-index: 996!important;
  278. left: 0px!important;
  279. bottom: 0px!important;
  280. width: 900px!important;
  281. position: relative!important;
  282. }`,
  283. 半透明$opacity: `.left-toolbox{
  284. opacity: 0.55!important;
  285. transition: opacity 0.5s!important;
  286. }
  287. .left-toolbox:hover{
  288. opacity: 1!important;
  289. }`,
  290. 淡化不跟随$opacity_relative: `.left-toolbox{
  291. z-index: 996!important;
  292. left: 0px!important;
  293. bottom: 0px!important;
  294. width: 900px!important;
  295. position: relative!important;
  296. opacity: 0.55!important;
  297. transition: opacity 1.5s!important;
  298. }
  299. .left-toolbox:hover{
  300. opacity: 1!important;
  301. }`,
  302. 显示$off: null,
  303. },
  304. },
  305. csdn_setting_btn: {
  306. name: "设置按钮",
  307. match: [/blog\.csdn\.net(\/.*)?\/article\/details./],
  308. values: {
  309. 已开启$on: () => {
  310. timeoutAfterLoad(() => {
  311. const articleTitleBox =
  312. document.getElementsByClassName("article-title-box")[0];
  313. const settingButton = document.createElement("a");
  314. settingButton.innerText = "脚本设置";
  315. settingButton.href =
  316. "https://yuhanawa.github.io/tools/userscriptconfig/";
  317. settingButton.target = "_blank";
  318. settingButton.style = `float: right;margin: 12px;font-size: 20px;text-decoration: underline !important;color: #4ea1db;`;
  319. articleTitleBox.insertAdjacentElement("afterbegin", settingButton);
  320. }, 200);
  321. },
  322. 已关闭$off: null,
  323. },
  324. },
  325. csdn_redirect: {
  326. name: "外链重定向自动跳转",
  327. match: ["link.csdn.net/"],
  328. values: {
  329. 已开启$on: () => {
  330. const url = new URLSearchParams(location.search).get("target");
  331. location.href = url;
  332. location.replace(url);
  333. },
  334. 已关闭$off: null,
  335. },
  336. },
  337. csdn_header: {
  338. name: "顶部菜单",
  339. match: [/blog\.csdn\.net(\/.*)?\/article\/details./],
  340. values: {
  341. 移除$remove: `#csdn-toolbar{ display: none!important; }`,
  342. 半透明$opacity: `#csdn-toolbar{
  343. transition: opacity 0.5s!important;
  344. opacity: 0.75;
  345. backdrop-filter: blur(8px);
  346. filter: blur(2px);
  347. }
  348. #csdn-toolbar:hover,
  349. #csdn-toolbar:focus,
  350. #csdn-toolbar:focus-within,
  351. #csdn-toolbar:active {
  352. opacity: 1;
  353. backdrop-filter: none;
  354. filter: none;
  355. } `,
  356. 淡化不跟随$opacity_static: `#csdn-toolbar{position: static !important; opacity: 0.5; transition: opacity 1.5s!important;} #csdn-toolbar:hover{opacity: 1;}`,
  357. 不跟随$static: `#csdn-toolbar{position: static !important;}`,
  358. 显示$off: null,
  359. },
  360. },
  361. csdn_fontsize: {
  362. name: "调整字体大小",
  363. match: ["csdn.net"],
  364. values: {
  365. 已开启$on: () => {
  366. style(
  367. `body{--font-size-title: ${get("csdn_font_size_title", "32px")
  368. };--font-size-p: ${get("csdn_font_size_p", "18px")
  369. };--font-size-h2: ${get("csdn_font_size_h2", "24px")
  370. };--font-size-code: ${get("csdn_font_size_code", "15px")
  371. };}`,
  372. );
  373. return "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}";
  374. },
  375. 已关闭$off: null,
  376. },
  377. },
  378. csdn_copy: {
  379. name: "免登录复制",
  380. match: [/blog\.csdn\.net(\/.*)?\/article\/details./],
  381. values: {
  382. 已开启$on: () => {
  383. timeoutAfterLoad(() => {
  384. // 修改复制按钮
  385. document.querySelectorAll(".hljs-button").forEach((e) => {
  386. e.setAttribute("data-title", "点击复制");
  387. e.classList.remove("signin");
  388. e.removeAttribute("onclick");
  389. e.addEventListener("click", () => {
  390. e.setAttribute("data-title", " ");
  391. navigator.clipboard.writeText(e.parentNode.innerText);
  392. e.setAttribute("data-title", "复制成功");
  393. setTimeout(() => e.setAttribute("data-title", "点击复制"), 1200);
  394. });
  395. }, 250);
  396.  
  397. // 复制功能
  398. document.querySelector(".blog-content-box").addEventListener(
  399. "copy",
  400. (e) => {
  401. e.stopPropagation();
  402. e.preventDefault();
  403.  
  404. navigator.clipboard.writeText(window.getSelection().toString());
  405. },
  406. true,
  407. );
  408. document.addEventListener(
  409. "keydown",
  410. (e) => {
  411. if (e.ctrlKey && e.keyCode == 67) {
  412. e.stopPropagation();
  413. e.preventDefault();
  414.  
  415. navigator.clipboard.writeText(window.getSelection().toString());
  416. }
  417. },
  418. true,
  419. );
  420.  
  421. document.oncopy = null;
  422. window.oncopy = null;
  423. }, 500);
  424.  
  425. return "#content_views pre code{-webkit-touch-callout:text!important;-webkit-user-select:text!important;-khtml-user-select:text!important;-moz-user-select:text!important;-ms-user-select:text!important;user-select:text!important}pre .hljs-button{background-color:#666;padding:2px;margin:10px;box-shadow:0 2px 4px rgba(0,0,0,.05),0 2px 4px rgba(0,0,0,.05);width:fit-content!important;height:fit-content!important}";
  426. },
  427. 已关闭$off: null,
  428. },
  429. },
  430. csdn_content_fullscreen: {
  431. name: "Ctrl + Enter开启专注模式",
  432. match: [/blog\.csdn\.net(\/.*)?\/article\/details./],
  433. values: {
  434. 已关闭$off: null,
  435. 已开启$on: () => {
  436. document.addEventListener("keydown", (e) => {
  437. if (e.ctrlKey && e.keyCode == 13) {
  438. if (document.fullscreenElement) document.exitFullscreen();
  439. else
  440. document.querySelector(".blog-content-box").requestFullscreen();
  441. }
  442. });
  443. },
  444. },
  445. },
  446. csdn_base: {
  447. name: "$",
  448. match: ["csdn.net"],
  449. values: () => {
  450. if (get("csdn_beautify", true)) {
  451. if (false) {
  452. // 可能存在问题,临时删除
  453. }
  454. }
  455.  
  456. fn = () => {
  457. const aside = document.getElementsByClassName(
  458. "blog_container_aside",
  459. )[0];
  460. if (aside == undefined || aside == null) {
  461. setTimeout(fn, 150);
  462. return;
  463. }
  464.  
  465. if (getComputedStyle(aside).display === "none") {
  466. style(`#mainBox { width: auto !important; }`);
  467. style(`main { margin: 0px 6px 40px 6px }`);
  468. if (get("csdn_width", "on") === "on") {
  469. style(`#mainBox > main{ width: 100% !important; }`);
  470. style(
  471. `body #mainBox{ width: ${get("csdn_width_value", "82")}% !important; }`,
  472. );
  473. }
  474. }
  475. };
  476. onload(fn);
  477.  
  478. return '@charset "UTF-8";:root>*,:root>*>*,:root>*>*>*,:root>*>*>*>*{transition:all .3s!important}.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}code,main div.blog-content-box pre.set-code-hide,pre{height:auto!important}.hide-preCode-box{display:none}.set-code-hide,main div.blog-content-box pre{max-height:max-content!important;height:auto!important}.article-info-box{opacity:.92}.blog-content-box{overflow-y:auto}';
  479. },
  480. },
  481. csdn_background: {
  482. name: "自定义背景",
  483. match: [/blog\.csdn\.net(\/.*)?\/article\/details./],
  484. values: {
  485. 已关闭$off: null,
  486. 已开启$on: () => {
  487. if (get("csdn_background-value")) {
  488. style(`body{background:url("${get("csdn_background-value")}")}`);
  489. }
  490. style(
  491. `body{--blog-content-box-background:${get("csdn_blog-content-box-background-value")}}`,
  492. );
  493. style(
  494. `body{--blog-content-box-opacity:${get("csdn_blog-content-box-opacity-value", "0.98")}}`,
  495. );
  496. style(
  497. `body{--blog-header-box-background:${get("csdn_blog-header-box-background-value")}}`,
  498. );
  499. return ":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}";
  500. },
  501. },
  502. },
  503. csdn_ad: {
  504. name: "去广告",
  505. match: ["csdn.net"],
  506. values: {
  507. 已开启$on: () =>
  508. "#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}",
  509. 已关闭$off: null,
  510. },
  511. },
  512.  
  513. };
  514.  
  515. run(features_csdn_1114922075);