CSDN-美化增强-免登录复制-沉浸式阅读-去广告等[茧绡]

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

当前为 2024-05-01 提交的版本,查看 最新版本

  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.49
  26. // @author Yuhanawa
  27. // @supportURL https://greasyfork.org/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.49 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(){document.querySelector("#config-page-awa")?document.querySelector("#config-page-awa").style.display="block":getConfigPage().then(fastestSite=>{void 0!==GM_openInTab?GM_openInTab(fastestSite,{active:!0}):location.href=fastestSite})}
  53. function LoadConfigPage(name){if(!document.querySelector("#config-page-awa"))return style(`
  54. .config-page-awa {
  55. position: fixed;
  56. background-color: rgba(245, 200, 200, 0.2);
  57. z-index: 9999;
  58. top: 0;
  59. left: 0;
  60. width: 100vw;
  61. height: 100vh;
  62. display: block;
  63. justify-content: center;
  64. align-items: center;
  65. flex-direction: column;
  66. backdrop-filter: blur(20px);
  67. }
  68. .config-page-container {
  69. width: 60%;
  70. height: 60%;
  71. position: absolute;
  72. top: 15%;
  73. left: 15%;
  74. cursor: auto;
  75. border: 1px thin #cccccc10;
  76. border-radius: 20px;
  77. box-shadow: 0 0 10px rgba(0, 0, 0, 0.65);
  78. background-color: rgba(255, 255, 255, 0.6);
  79. overflow: hidden;
  80. padding: 15px;
  81. box-sizing: border-box;
  82. overflow-y: hidden;
  83. min-width: 360px;
  84. min-height: 420px;
  85. resize: both;
  86. }
  87. .config-page-drag-area {
  88. position: absolute;
  89. width: 100%;
  90. height: 100%;
  91. top: 0;
  92. left: 0;
  93. cursor: move;
  94. background-color: transparent;
  95. }
  96. .config-page-iframe {
  97. border: 0;
  98. border-radius: 18px;
  99. overflow: hidden;
  100. box-sizing: border-box;
  101. overflow-y: auto;
  102. opacity: 0.95;
  103. width: 100%;
  104. height: 100%;
  105. box-shadow: 1px 1px 4px rgba(185, 185, 185, 0.2);
  106. background-color: rgba(255, 255, 255, 0.25);
  107. margin: -1px;
  108. }
  109. .config-page-close-btn {
  110. position: absolute;
  111. top: 4px;
  112. right: 5px;
  113. font-size: 20px;
  114. background-color: transparent;
  115. border: 0;
  116. color: #C00;
  117. cursor: pointer;
  118. outline: none;
  119. padding: 0;
  120. margin: 0;
  121. }
  122. .config-page-close-btn:hover {
  123. color: #A00;
  124. }
  125. .config-page-close-btn:active {
  126. color: #f00;
  127. transform: scale(0.8);
  128. transition: 0.15s;
  129. }
  130. `),getConfigPage().then(fastestSite=>{document.body.insertAdjacentHTML("afterend",`
  131. <div class="config-page-awa" id="config-page-awa" style="display: none;">
  132. <div class="config-page-container">
  133. <div class="config-page-drag-area"></div>
  134. <iframe class="config-page-iframe"
  135. src="${fastestSite}?menuKey=${name}&iniframe"></iframe>
  136.  
  137. <button class="config-page-close-btn">⭕</button>
  138. </div>
  139. </div>`);const configPage=document.querySelector("#config-page-awa"),container=configPage.querySelector(".config-page-container"),iframe=configPage.querySelector(".config-page-iframe");var fastestSite=configPage.querySelector(".config-page-drag-area"),pos1=0,pos2=0,pos3=0,pos4=0;
  140. 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"}
  141. function closeDragElement(){iframe.style.pointerEvents="auto",configPage.onmouseup=null,configPage.onmousemove=null}return fastestSite.onmousedown=function(e){(e=e||window.event).preventDefault(),pos3=e.clientX,pos4=e.clientY,iframe.style.pointerEvents="none",configPage.onmouseup=closeDragElement,configPage.onmousemove=elementDrag;e=window.getComputedStyle(event.target).cursor;console.log("当前鼠标样式:"+e)},configPage.querySelector(".config-page-close-btn").onclick=function(){configPage.style.display="none"},Promise.resolve()});showConfigPage()}
  142. function loadConfig(name,properties){GM_registerMenuCommand("在新窗口打开设置中心",()=>{showConfigPage()}),GM_registerMenuCommand("在页面内镶嵌设置中心(BETA)",()=>{LoadConfigPage(name).then(()=>showConfigPage())}),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});(location.href.match("yuhan-script-config.netlify.app")||location.href.match("user-script-config-form.vercel.app")||location.href.match("yuhanawa.github.io/tools/userscriptconfig")||location.href.match("localhost"))&&(void 0===unsafeWindow.userscript&&(unsafeWindow.userscript={}),unsafeWindow.userscript[name]={props:properties,anchors:anchors,get:get,set:set})}
  143.  
  144.  
  145. 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"}]}},"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' }}"}})
  146.  
  147. let features_csdn_1114922075 = {
  148. csdn_ui_opt: {
  149. name: "净化",
  150. match: [/blog\.csdn\.net(\/.*)?\/article\/details./],
  151. values: {
  152. 极简$lite: (self) => {
  153. var value = [
  154. "#treeSkill",
  155. "#blogVoteBox",
  156. ".recommend-box",
  157. ".first-recommend-box",
  158. ".second-recommend-box",
  159. ".insert-baidu-box.recommend-box-style",
  160. "#recommendNps",
  161. "#commentBox",
  162. "#pcCommentBox",
  163. "#toolBarBox",
  164. ".blog-footer-bottom",
  165. "#rightAside",
  166. "#groupfile",
  167. "#rightAside .kind_person",
  168. ".sidetool-writeguide-box",
  169. ".option-box[data-type=guide]",
  170. ".option-box[data-type=cs]",
  171. ".option-box[data-type=report]",
  172. ".btn-side-chatdoc-contentbox",
  173. "#csdn-toolbar",
  174. "#mainBox .blog_container_aside",
  175. "#csdn-toolbar .toolbar-container-left",
  176. "#csdn-toolbar .toolbar-container-right",
  177. "#csdn-toolbar .toolbar-container-middle",
  178. "#blogExtensionBox .extension_official",
  179. "#asideProfile",
  180. "#footerRightAds",
  181. "#asideWriteGuide",
  182. "#asideSearchArticle",
  183. "#asideHotArticle",
  184. "#asideCategory",
  185. "#asideNewComments",
  186. "#asideNewNps",
  187. "#asideArchive",
  188. "#asidedirectory",
  189. ".passport-container-mini-tip",
  190. ".passport-login-container",
  191. ];
  192.  
  193. self.hide(value);
  194. },
  195. "简|作者+目录$lite1": (self) => {
  196. self.hide([
  197. ".passport-container-mini-tip",
  198. "#asideArchive",
  199. "#csdn-toolbar .toolbar-menus",
  200. "#csdn-toolbar .toolbar-btn-vip",
  201. "#csdn-toolbar .toolbar-btn-msg",
  202. "#csdn-toolbar .toolbar-btn-mp",
  203. "#csdn-toolbar .toolbar-btn-writet",
  204. "#blogExtensionBox .extension_official",
  205. "#footerRightAds",
  206. "#asideProfile .item-rank",
  207. "#asideProfile .aside-box-footer",
  208. "#asideWriteGuide",
  209. "#asideHotArticle",
  210. "#asideNewComments",
  211. "#asideNewNps",
  212. "main .article-bar-top",
  213. "main .article-title-box .article-type-img",
  214. "#recommendNps",
  215. "#commentBox",
  216. "#pcCommentBox",
  217. "#treeSkill",
  218. "#blogVoteBox",
  219. ".recommend-box",
  220. ".first-recommend-box",
  221. ".second-recommend-box",
  222. ".insert-baidu-box.recommend-box-style",
  223. ".blog-footer-bottom",
  224. "#toolBarBox",
  225. ".sidetool-writeguide-box",
  226. ".option-box[data-type=guide]",
  227. ".option-box[data-type=cs]",
  228. ".option-box[data-type=report]",
  229. ".btn-side-chatdoc-contentbox",
  230. "#csdn-toolbar .toolbar-logo",
  231. "#csdn-toolbar .toolbar-container-left",
  232. "#asideProfile .data-info",
  233. "#asideCategory",
  234. ".passport-login-container",
  235. ]);
  236. },
  237. "简|作者+目录+菜单$lite2": (self) => {
  238. self.hide([
  239. ".passport-container-mini-tip",
  240. "#asideArchive",
  241. "#csdn-toolbar .toolbar-menus",
  242. "#csdn-toolbar .toolbar-btn-vip",
  243. "#footerRightAds",
  244. "#asideProfile .item-rank",
  245. "#asideProfile .aside-box-footer",
  246. "#asideWriteGuide",
  247. "#asideHotArticle",
  248. "#asideNewComments",
  249. "#asideNewNps",
  250. "main .article-bar-top",
  251. "main .article-title-box .article-type-img",
  252. "#recommendNps",
  253. "#commentBox",
  254. "#pcCommentBox",
  255. "#treeSkill",
  256. "#blogVoteBox",
  257. ".insert-baidu-box.recommend-box-style",
  258. ".blog-footer-bottom",
  259. ".sidetool-writeguide-box",
  260. ".option-box[data-type=guide]",
  261. ".option-box[data-type=cs]",
  262. ".option-box[data-type=report]",
  263. ".btn-side-chatdoc-contentbox",
  264. "#csdn-toolbar .toolbar-logo",
  265. "#csdn-toolbar .toolbar-container-left",
  266. "#asideCategory",
  267. ".first-recommend-box",
  268. ".second-recommend-box",
  269. ".recommend-box",
  270. "#toolBarBox",
  271. ".passport-login-container",
  272. ]);
  273. },
  274. "简|以上信息+推荐$lite3": (self) => {
  275. self.hide([
  276. ".passport-container-mini-tip",
  277. "#asideArchive",
  278. "#csdn-toolbar .toolbar-btn-vip",
  279. "#footerRightAds",
  280. "#asideProfile .item-rank",
  281. "#asideProfile .aside-box-footer",
  282. "#asideWriteGuide",
  283. "#asideHotArticle",
  284. "#asideNewComments",
  285. "#asideNewNps",
  286. "main .article-bar-top",
  287. "main .article-title-box .article-type-img",
  288. "#recommendNps",
  289. "#treeSkill",
  290. "#blogVoteBox",
  291. ".insert-baidu-box.recommend-box-style",
  292. ".blog-footer-bottom",
  293. ".sidetool-writeguide-box",
  294. ".option-box[data-type=guide]",
  295. ".option-box[data-type=cs]",
  296. ".option-box[data-type=report]",
  297. ".btn-side-chatdoc-contentbox",
  298. "#asideCategory",
  299. "#toolBarBox",
  300. "#csdn-toolbar .toolbar-menus",
  301. "#csdn-toolbar .toolbar-logo",
  302. "#csdn-toolbar .toolbar-container-left",
  303. ]);
  304. },
  305. 常规$normal: (self) => {
  306. var value = [
  307. "#csdn-toolbar .toolbar-logo",
  308. "#csdn-toolbar .toolbar-btn-mp",
  309. "#csdn-toolbar .toolbar-btn-write",
  310. "#csdn-toolbar .toolbar-btn-msg",
  311. "#csdn-toolbar .toolbar-btn-vip",
  312. "#asideProfile .profile-intro-name-boxOpration",
  313. "#asideProfile .aside-box-footer",
  314. "#asideProfile .item-rank",
  315. "#footerRightAds",
  316. "#asideWriteGuide",
  317. "#asideHotArticle",
  318. "#asideNewComments",
  319. "#asideNewNps",
  320. "#asideArchive",
  321. "#asideSearchArticle",
  322. "main .article-title-box .article-type-img",
  323. "#treeSkill",
  324. "#blogVoteBox",
  325. ".insert-baidu-box.recommend-box-style",
  326. "#recommendNps",
  327. "#commentBox",
  328. ".blog-footer-bottom",
  329. "#rightAside .kind_person",
  330. ".sidetool-writeguide-box",
  331. ".option-box[data-type=guide]",
  332. ".option-box[data-type=cs]",
  333. ".option-box[data-type=report]",
  334. ".btn-side-chatdoc-contentbox",
  335. ".passport-container-mini-tip",
  336. ".passport-login-container",
  337. ];
  338.  
  339. self.hide(value);
  340. },
  341. 自定义$custom: () => {
  342. style(
  343. `${get("csdn_ui_opt_value")} { display: none !important; width: 0 !important; height: 0 !important; visibility: collapse !important; }`,
  344. );
  345. },
  346. 已关闭$off: () => {},
  347. },
  348. hide: (value) => {
  349. style(
  350. `${value.join(", ")} { display: none !important; width: 0 !important; height: 0 !important; visibility: collapse !important; }`,
  351. );
  352. },
  353. },
  354. csdn_toolbox: {
  355. name: "低部菜单工具栏",
  356. match: [/blog\.csdn\.net(\/.*)?\/article\/details./],
  357. values: {
  358. 移除$remove: `.left-toolbox{
  359. display: none!important;
  360. }`,
  361. 不跟随$relative: `.left-toolbox{
  362. z-index: 996!important;
  363. left: 0px!important;
  364. bottom: 0px!important;
  365. width: 900px!important;
  366. position: relative!important;
  367. }`,
  368. 半透明$opacity: `.left-toolbox{
  369. opacity: 0.55!important;
  370. transition: opacity 0.5s!important;
  371. }
  372. .left-toolbox:hover{
  373. opacity: 1!important;
  374. }`,
  375. 淡化不跟随$opacity_relative: `.left-toolbox{
  376. z-index: 996!important;
  377. left: 0px!important;
  378. bottom: 0px!important;
  379. width: 900px!important;
  380. position: relative!important;
  381. opacity: 0.55!important;
  382. transition: opacity 1.5s!important;
  383. }
  384. .left-toolbox:hover{
  385. opacity: 1!important;
  386. }`,
  387. 显示$off: null,
  388. },
  389. },
  390. csdn_setting_btn: {
  391. name: "设置按钮",
  392. match: [/blog\.csdn\.net(\/.*)?\/article\/details./],
  393. values: {
  394. 已开启$on: () => {
  395. timeoutAfterLoad(() => {
  396. const articleTitleBox =
  397. document.getElementsByClassName("article-title-box")[0];
  398. const settingButton = document.createElement("a");
  399. settingButton.innerText = "脚本设置";
  400. settingButton.href =
  401. "https://yuhanawa.github.io/tools/userscriptconfig/";
  402. settingButton.target = "_blank";
  403. settingButton.style = `float: right;margin: 12px;font-size: 20px;text-decoration: underline !important;color: #4ea1db;`;
  404. articleTitleBox.insertAdjacentElement("afterbegin", settingButton);
  405. }, 200);
  406. },
  407. 已关闭$off: null,
  408. },
  409. },
  410. csdn_redirect: {
  411. name: "外链重定向自动跳转",
  412. match: ["link.csdn.net/"],
  413. values: {
  414. 已开启$on: () => {
  415. const url = new URLSearchParams(location.search).get("target");
  416. location.href = url;
  417. location.replace(url);
  418. },
  419. 已关闭$off: null,
  420. },
  421. },
  422. csdn_header: {
  423. name: "顶部菜单",
  424. match: [/blog\.csdn\.net(\/.*)?\/article\/details./],
  425. values: {
  426. 移除$remove: `#csdn-toolbar{ display: none!important; }`,
  427. 半透明$opacity: `#csdn-toolbar{
  428. transition: opacity 0.5s!important;
  429. opacity: 0.75;
  430. backdrop-filter: blur(8px);
  431. filter: blur(2px);
  432. }
  433. #csdn-toolbar:hover,
  434. #csdn-toolbar:focus,
  435. #csdn-toolbar:focus-within,
  436. #csdn-toolbar:active {
  437. opacity: 1;
  438. backdrop-filter: none;
  439. filter: none;
  440. } `,
  441. 淡化不跟随$opacity_static: `#csdn-toolbar{position: static !important; opacity: 0.5; transition: opacity 1.5s!important;} #csdn-toolbar:hover{opacity: 1;}`,
  442. 不跟随$static: `#csdn-toolbar{position: static !important;}`,
  443. 显示$off: null,
  444. },
  445. },
  446. csdn_fontsize: {
  447. name: "调整字体大小",
  448. match: ["csdn.net"],
  449. values: {
  450. 已开启$on: () => {
  451. style(
  452. `body{--font-size-title: ${get("csdn_font_size_title", "32px")
  453. };--font-size-p: ${get("csdn_font_size_p", "18px")
  454. };--font-size-h2: ${get("csdn_font_size_h2", "24px")
  455. };--font-size-code: ${get("csdn_font_size_code", "15px")
  456. };}`,
  457. );
  458. 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}";
  459. },
  460. 已关闭$off: null,
  461. },
  462. },
  463. csdn_copy: {
  464. name: "免登录复制",
  465. match: [/blog\.csdn\.net(\/.*)?\/article\/details./],
  466. values: {
  467. 已开启$on: () => {
  468. timeoutAfterLoad(() => {
  469. // 修改复制按钮
  470. document.querySelectorAll(".hljs-button").forEach((e) => {
  471. e.setAttribute("data-title", "点击复制");
  472. e.classList.remove("signin");
  473. e.removeAttribute("onclick");
  474. e.addEventListener("click", () => {
  475. e.setAttribute("data-title", " ");
  476. navigator.clipboard.writeText(e.parentNode.innerText);
  477. e.setAttribute("data-title", "复制成功");
  478. setTimeout(() => e.setAttribute("data-title", "点击复制"), 1200);
  479. });
  480. }, 250);
  481.  
  482. // 复制功能
  483. document.querySelector(".blog-content-box").addEventListener(
  484. "copy",
  485. (e) => {
  486. e.stopPropagation();
  487. e.preventDefault();
  488.  
  489. navigator.clipboard.writeText(window.getSelection().toString());
  490. },
  491. true,
  492. );
  493. document.addEventListener(
  494. "keydown",
  495. (e) => {
  496. if (e.ctrlKey && e.keyCode == 67) {
  497. e.stopPropagation();
  498. e.preventDefault();
  499.  
  500. navigator.clipboard.writeText(window.getSelection().toString());
  501. }
  502. },
  503. true,
  504. );
  505.  
  506. document.oncopy = null;
  507. window.oncopy = null;
  508. }, 500);
  509.  
  510. 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}";
  511. },
  512. 已关闭$off: null,
  513. },
  514. },
  515. csdn_content_fullscreen: {
  516. name: "Ctrl + Enter开启专注模式",
  517. match: [/blog\.csdn\.net(\/.*)?\/article\/details./],
  518. values: {
  519. 已关闭$off: null,
  520. 已开启$on: () => {
  521. document.addEventListener("keydown", (e) => {
  522. if (e.ctrlKey && e.keyCode == 13) {
  523. if (document.fullscreenElement) document.exitFullscreen();
  524. else
  525. document.querySelector(".blog-content-box").requestFullscreen();
  526. }
  527. });
  528. },
  529. },
  530. },
  531. csdn_base: {
  532. name: "$",
  533. match: ["csdn.net"],
  534. values: () => {
  535. if (get("csdn_beautify", true)) {
  536. if (false) {
  537. // 可能存在问题,临时删除
  538. }
  539. }
  540.  
  541. fn = () => {
  542. const aside = document.getElementsByClassName(
  543. "blog_container_aside",
  544. )[0];
  545. if (aside == undefined || aside == null) {
  546. setTimeout(fn, 150);
  547. return;
  548. }
  549.  
  550. if (getComputedStyle(aside).display === "none") {
  551. style(`#mainBox { width: auto !important; }`);
  552. style(`main { margin: 0px 6px 40px 6px }`);
  553. if (get("csdn_width", "on") === "on") {
  554. style(`#mainBox > main{ width: 100% !important; }`);
  555. style(
  556. `body #mainBox{ width: ${get("csdn_width_value", "82")}% !important; }`,
  557. );
  558. }
  559. }
  560. };
  561. onload(fn);
  562.  
  563. 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}';
  564. },
  565. },
  566. csdn_background: {
  567. name: "自定义背景",
  568. match: [/blog\.csdn\.net(\/.*)?\/article\/details./],
  569. values: {
  570. 已关闭$off: null,
  571. 已开启$on: () => {
  572. if (get("csdn_background-value")) {
  573. style(`body{background:url("${get("csdn_background-value")}")}`);
  574. }
  575. style(
  576. `body{--blog-content-box-background:${get("csdn_blog-content-box-background-value")}}`,
  577. );
  578. style(
  579. `body{--blog-content-box-opacity:${get("csdn_blog-content-box-opacity-value", "0.98")}}`,
  580. );
  581. style(
  582. `body{--blog-header-box-background:${get("csdn_blog-header-box-background-value")}}`,
  583. );
  584. 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}";
  585. },
  586. },
  587. },
  588. csdn_ad: {
  589. name: "去广告",
  590. match: ["csdn.net"],
  591. values: {
  592. 已开启$on: () =>
  593. "#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}",
  594. 已关闭$off: null,
  595. },
  596. },
  597.  
  598. };
  599.  
  600. run(features_csdn_1114922075);