Greasy Fork is available in English.

cnblogs garden

better cnblogs

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

  1. // ==UserScript==
  2. // @name cnblogs garden
  3. // @name:zh 博客花园-博客园(cnblogs)美化增强
  4. // @namespace http://github.com/yuhanawa/UserScript
  5. // @name:zh-CN 博客花园-博客园(cnblogs)美化增强
  6. // @description better cnblogs
  7. // @description:zh 博客园 首页及文章美化/自动翻页字体放大/样式调整等
  8. // @description:zh-CN 博客园 首页及文章美化/自动翻页/字体放大/样式调整等
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // @grant GM_addStyle
  12. // @grant GM_registerMenuCommand
  13. // @grant GM_xmlhttpRequest
  14. // @grant GM_openInTab
  15. // @grant unsafeWindow
  16. // @match *://*.cnblogs.com/*
  17. // @match *://yuhan-script-config.netlify.app/*
  18. // @match *://user-script-config-form.vercel.app/*
  19. // @match *://yuhanawa.github.io/tools/userscriptconfig/*
  20. // @version 0.1.19
  21. // @author Yuhanawa
  22. // @license GPL-3.0
  23. // @icon none
  24. // @run-at document-start
  25. // ==/UserScript==
  26.  
  27. /*
  28. cnblogs v.0.1.19 by Yuhanawa
  29. Source: https://github.com/Yuhanawa/UserScript
  30. */
  31.  
  32. isLoaded=!1,onload(()=>isLoaded=!0);const __props__=new Map;
  33. function get(k,d){return GM_getValue(k,void 0===d?__props__.get(k):d)}
  34. function set(k,v){return GM_setValue(k,v)}
  35. function cfg(k,v){return void 0===v?get(k):set(k,v)}
  36. function getOptionKeyAndName(optionStr){var key=optionStr.match(/\$([^ ]+)/)?.[0];return key?{key:key.replace("$",""),name:optionStr.replace(key,"")}:{key:optionStr,name:optionStr}}
  37. function style(css){var node;"undefined"!=typeof GM_addStyle?GM_addStyle(css):((node=document.createElement("style")).appendChild(document.createTextNode(css)),document.body.appendChild(node))}
  38. 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}
  39. function onload(f){isLoaded?f():document.addEventListener("DOMContentLoaded",()=>f())}
  40. function timeoutAfterLoad(f,t){onload(()=>setTimeout(()=>f(),t))}
  41. function intervalAfterLoad(f,t,runOnFirst){onload(()=>{runOnFirst&&f(),setInterval(f,t)})}
  42. 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)}}
  43. 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)}}}
  44. 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()})})}
  45. 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))}
  46. function showConfigPage(){getConfigPage().then(fastestSite=>{void 0!==GM_openInTab?GM_openInTab(fastestSite,{active:!0}):location.href=fastestSite})}
  47. function LoadConfigPage(name){console.log("LoadConfigPage "+name)}
  48. 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}}
  49. 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;
  50. 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"}
  51. 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)}
  52.  
  53.  
  54. function receiveMessage(event) {
  55. const data = event.data
  56. switch (data.type) {
  57. case "resizeIframe":
  58. document.getElementById("ing_iframe").style.height = `${data.height}px`;
  59. break;
  60.  
  61. default:
  62. break;
  63. }
  64. }
  65. unsafeWindow.addEventListener("message", receiveMessage, false);
  66.  
  67. function show_ing_iframe() {
  68. if (document.getElementById("ing_iframe")) return;
  69. timeoutAfterLoad(() => {
  70. const iframe = document.createElement('iframe')
  71. iframe.id = "ing_iframe"
  72. iframe.src = "https://ing.cnblogs.com/"
  73. document.querySelector('#main_flow').replaceChild(iframe, document.querySelector('#main_flow>.card'))
  74. }, 50)
  75. }
  76.  
  77. function getPage(url, obj) {
  78. GM_xmlhttpRequest({
  79. url: url,
  80. method: 'GET',
  81. overrideMimeType: `text/html; charset=${document.characterSet || document.charset || document.inputEncoding}`,
  82. headers: {
  83. 'x-requested-with': 'XMLHttpRequest',
  84. 'Referer': location.href,
  85. 'User-Agent': navigator.userAgent,
  86. 'Accept': 'text/html,application/xhtml+xml,application/xml'
  87. },
  88. timeout: 10000,
  89. onerror: (response) => {
  90. console.error(`ERR: URL:${url}`, response);
  91. },
  92. ontimeout: (response) => {
  93. console.warn(`TIMEOUT: URL:${url}`, response);
  94. },
  95. ...obj
  96. });
  97. }
  98.  
  99. loadConfig('cnblogs', {".line_bc":{"widget":"line","title":"❗❗❗修改完记得点保存(在最下面)❗❗❗"},".line_sw":{"widget":"line","title":"❗开关还没做完❗"},"logo_switch":{"title":"LOGO替换","default":true,"widget":"switch","type":"boolean"},"menu_switch":{"title":"首页左侧菜单增强","default":true,"widget":"switch","type":"boolean"},"auto_pager_ing_switch":{"title":"闪存自动翻页开关","default":true,"widget":"switch","type":"boolean"}})
  100.  
  101. let features_cnblogs_1574814730 = {
  102. cnblogs_side_right: {
  103. name: "右侧吸底",
  104. match: [
  105. /www.cnblogs.com\/[^\/]*$/,
  106. /www.cnblogs.com\/(sitehome|pick|candidate|subscription|following|aggsite|cate|comment)\//,
  107. ],
  108. directlyRun: true,
  109. switchable: true,
  110. values: () => {
  111. fn = () => {
  112. const side = document.getElementById("side_right");
  113. if (side && side.clientHeight > window.innerHeight)
  114. side.style.top = `${window.innerHeight - side.clientHeight}px`;
  115. else setTimeout(fn, 200);
  116. };
  117. timeoutAfterLoad(fn, 200);
  118. },
  119. },
  120. cnblogs_menu: {
  121. name: "sidenav",
  122. match: [
  123. /www.cnblogs.com\/[^\/]*$/,
  124. /www.cnblogs.com\/(sitehome|pick|candidate|subscription|following|aggsite|cate|comment)\//,
  125. ],
  126. directlyRun: true,
  127. switchable: true,
  128. values: () => {
  129. onload(() => {
  130. const sidenav = document.getElementsByClassName("sidenav")[0];
  131. function insertNavItem(pos, id, href, title, icon) {
  132. const li = document.createElement("li");
  133. li.id = id;
  134. li.className = "sidenav-item";
  135. li.innerHTML = `<a href="${href}" title="${title}">
  136. <img src="${icon}">
  137. <span>${title}</span>
  138. </a>`;
  139. sidenav.insertAdjacentElement(pos, li);
  140. return li;
  141. }
  142. const sidenav_ing = insertNavItem(
  143. "afterBegin",
  144. "sidenav_ing",
  145. "#ing",
  146. "闪存",
  147. "https://assets.cnblogs.com/images/ing/lucky-star-3-1.png",
  148. );
  149. sidenav_ing.addEventListener("click", () => show_ing_iframe());
  150.  
  151. const sidenav_home = insertNavItem(
  152. "afterBegin",
  153. "sidenav_home",
  154. "/",
  155. "主页",
  156. document.getElementById("user_icon").src,
  157. );
  158. if (/www.cnblogs.com\/#ing*$/.test(location.href)) {
  159. sidenav_ing.className += " current-nav";
  160. } else if (/www.cnblogs.com\/[^\/]*$/.test(location.href)) {
  161. sidenav_home.className += " current-nav";
  162. }
  163.  
  164. setTimeout(() => {
  165. sidenav_home.querySelector("img").src =
  166. document.getElementById("user_icon").src;
  167. }, 320);
  168. });
  169. },
  170. },
  171. cnblogs_logo: {
  172. name: "LOGO替换",
  173. match: [
  174. /www.cnblogs.com\/[^\/]*$/,
  175. /www.cnblogs.com\/(sitehome|pick|candidate|subscription|following|aggsite|cate|comment)\//,
  176. ],
  177. directlyRun: true,
  178. switchable: true,
  179. values:
  180. ".navbar-branding>a{background:url(//common.cnblogs.com/images/logo/logo20170227.png);background-size:contain;background-repeat:no-repeat;width:auto;height:36px;display:block;margin-left:8px}.navbar-branding>a>img{display:none!important}",
  181. },
  182. cnblogs_ing_in_iframe: {
  183. name: "ing_in_iframe",
  184. match: [/ing.cnblogs.com/],
  185. directlyRun: true,
  186. values: () => {
  187. var style =
  188. ":root,:root #container,:root #container_content,:root #main,:root #wrapper,body,body #container,body #container_content,body #main,body #wrapper,html,html #container,html #container_content,html #main,html #wrapper{height:fit-content!important;scrollbar-width:0}:root .feed_body,body .feed_body,html .feed_body{display:flex;flex-direction:column;flex-wrap:wrap;align-content:flex-start}:root .feed_body:not(*),body .feed_body:not(*),html .feed_body:not(*){background:red}";
  189.  
  190. if (top === self) return style;
  191.  
  192. var style =
  193. style +
  194. "#app_bar,#footer,#goTop,#header,#right_sidebar,#top{display:none!important}#container,#container_content,#main,#wrapper,:root,body,html{width:100%;height:fit-content;margin:0;padding:0}.ing-item{display:flex;flex-direction:row;justify-content:space-around;align-items:flex-end;flex-wrap:nowrap}#user_ing_block{margin:24px 16px}";
  195. var refreshHeight = () => {
  196. unsafeWindow.parent.postMessage(
  197. {
  198. type: "resizeIframe",
  199. height:
  200. document.body.scrollHeight ?? document.body.clientHeight + 220,
  201. },
  202. "*",
  203. );
  204. };
  205. const observer = new MutationObserver(function (mutations) {
  206. mutations.forEach(function (mutation) {
  207. // 遍历所有变化
  208. if (mutation.type === "childList") {
  209. refreshHeight();
  210. } else if (mutation.type === "attributes") {
  211. // 属性变化
  212. }
  213. });
  214. });
  215. onload(() => {
  216. refreshHeight();
  217.  
  218. // 观察 #main 元素
  219. observer.observe(document.getElementById("main"), {
  220. childList: true,
  221. attributes: false,
  222. subtree: true,
  223. });
  224. });
  225.  
  226. timeoutAfterLoad(() => {
  227. // if (!document.querySelector(".pager")) return
  228.  
  229. var timeout = 0;
  230. setInterval(() => {
  231. if (timeout > 0) timeout--;
  232. }, 1000);
  233. unsafeWindow.nextPage = nextPage;
  234. document.querySelectorAll(".pager").forEach((el) => el.remove());
  235.  
  236. function receiveMessage(event) {
  237. const data = event.data;
  238. switch (data.type) {
  239. case "nextPage":
  240. nextPage();
  241. break;
  242.  
  243. default:
  244. break;
  245. }
  246. }
  247. if (get("cnblogs_auto_pager_ing_switch")) {
  248. unsafeWindow.addEventListener("message", receiveMessage, false);
  249. }
  250.  
  251. function nextPage() {
  252. if (timeout > 0) return;
  253. timeout = 3;
  254.  
  255. IngListType = "All";
  256. PageIndex = 2;
  257. getPage(
  258. `/ajax/ing/GetIngList?IngListType=${IngListType}&PageIndex=${PageIndex}&PageSize=30&Tag=&_=${Date.now()}`,
  259. {
  260. onload: (response) => {
  261. try {
  262. const doc = response.responseText;
  263. document
  264. .querySelector(".feed_block")
  265. .insertAdjacentHTML("beforeend", doc);
  266.  
  267. document
  268. .querySelectorAll(".feed_loading")
  269. .forEach((el) => el.remove());
  270. document
  271. .querySelector(".feed_block")
  272. .insertAdjacentHTML(
  273. "beforeend",
  274. `<div class="feed_loading"><img align="absmiddle" src="//assets.cnblogs.com/images/loading.gif" alt=""> 正在加载数据...</div>`,
  275. );
  276. PageIndex++;
  277. } catch (e) {
  278. console.error("ERR", e, response.responseText);
  279. }
  280. },
  281. onerror: (response) => {
  282. console.error(`ERR: URL:${url}`, response);
  283. },
  284. },
  285. );
  286. }
  287. }, 400);
  288.  
  289. return style;
  290. },
  291. },
  292. cnblogs_ing: {
  293. name: "ing",
  294. match: [/www.cnblogs.com\/#ing*$/],
  295. directlyRun: true,
  296. values: () => {
  297. show_ing_iframe();
  298. if (get("cnblogs_auto_pager_ing_switch")) {
  299. setInterval(() => {
  300. if (
  301. document.body.offsetHeight - window.scrollY - window.innerHeight <
  302. window.innerHeight * 2
  303. ) {
  304. document
  305. .getElementById("ing_iframe")
  306. .contentWindow.postMessage({ type: "nextPage" }, "*");
  307. }
  308. }, 2000);
  309. }
  310. },
  311. },
  312. cnblogs_better_skin: {
  313. name: "better_skin",
  314. match: true,
  315. directlyRun: true,
  316. switchable: true,
  317. values:
  318. '.skin-lessismoreright #blogTitle{display:flex;flex-direction:row;flex-wrap:wrap;align-content:stretch;justify-content:center;align-items:baseline;padding:12px}.skin-lessismoreright #blogTitle .title:after{content:" | ";white-space:pre}.skin-lessismoreright #blogTitle .subtitle{font-size:15.5pt;color:#222}.skin-lessismoreright #blogTitle .subtitle::before{content:" ";white-space:pre}.skin-lessismoreright #main{padding:4px 20px}.skin-lessismoreright #main .post .postTitle{border-bottom:1px solid rgba(66,119,206,.5333333333);border-bottom-style:dashed;font-size:24px;font-weight:700;margin:20px 0 12px;width:fit-content}.skin-lessismoreright #main .post .postBody{color:rgba(0,0,0,.9882352941);font-size:15px;line-height:25px;font-family:-apple-system,PingFangSC-Regular,Pingfang SC,Hiragino Sans GB,Noto Sans,system-ui,BlinkMacSystemFont,Microsoft YaHei,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans",simsun,arial,helvetica,"Helvetica Neue",sans-serif}.skin-lessismoreright #main .post #blog_post_info{height:fit-content;width:-webkit-fill-available;display:inline-flex;flex-direction:row;justify-content:space-between}.skin-lessismoreright #main .post #blog_post_info #author_profile{border:1px solid #ccc;background:#f0f8ff;padding:12px 14px 0;width:fit-content;height:88px;border-radius:6px}.skin-lessismoreright #main .post #blog_post_info #author_profile a{text-decoration:none;color:rgba(0,0,0,.9882352941);font-size:14px;margin:2px}.skin-lessismoreright #main .post #blog_post_info #author_profile #author_profile_follow{position:relative;float:right;top:-18px}.skin-lessismoreright #main .post #blog_post_info #author_profile #author_profile_follow a{color:#06c}.skin-lessismoreright #main .post #blog_post_info #author_profile .author_avatar{margin-right:16px;border:1px solid rgba(128,128,128,.5019607843);border-radius:6px;width:64px}.skin-lessismoreright #main #blog-comments-placeholder .feedback_area_title{font-size:18px}.skin-lessismoreright #main #blog-comments-placeholder .layer{color:gray}.skin-lessismoreright #main #blog-comments-placeholder .blog_comment_body{font-size:15px;color:rgba(0,0,0,.9882352941)}.skin-lessismoreright .commentbox_main.comment_textarea{width:100%}#green_channel{padding:5px 0 15px;margin-bottom:10px;margin-top:10px;border:0;border-top:#eee 1px dashed;border-bottom:#eee 1px dashed;font-size:12px;width:100%!important;text-align:center;display:inline-block;vertical-align:middle}#green_channel_digg,#green_channel_favorite,#green_channel_follow{width:80px}#btn_comment_submit,#green_channel_digg,#green_channel_favorite,#green_channel_follow,#green_channel_wechat,#green_channel_weibo{text-decoration:none;color:#fff;margin:10px auto auto;height:30px;display:inline-block;line-height:30px;font-size:12px;font-weight:500;letter-spacing:2px;border-radius:3px;text-transform:uppercase;transition:all .4s;-webkit-transition:all .4s;-moz-transition:all .4s;-ms-transition:all .4s;-o-transition:all .4s;position:relative;background-image:none}#btn_comment_submit{width:80px}#green_channel_digg:hover,#green_channel_favorite:hover,#green_channel_follow:hover,#green_channel_wechat:hover,#green_channel_weibo:hover{transform:scale(1.02,1.02)}#green_channel_digg:active,#green_channel_favorite:active,#green_channel_follow:active,#green_channel_wechat:active,#green_channel_weibo:active{transform:scale(.95,.95);transition:all .4s -125ms}#green_channel_digg{background-color:#5c8ec6;box-shadow:0 15px 18px -6px rgba(95,193,206,.65)}#green_channel_follow{background-color:#e33100!important;box-shadow:0 15px 18px -6px rgba(227,49,0,.65);margin-left:10px}#green_channel_favorite{background-color:#ffb515;box-shadow:0 15px 18px -6px rgba(255,198,75,.65);margin-left:10px}#green_channel_wechat,#green_channel_weibo{background-color:#ff464b!important;box-shadow:0 15px 18px -6px rgba(255,70,75,.65)!important;margin-left:10px;width:45px}#green_channel_wechat{background-color:#3cb034!important;box-shadow:0 15px 18px -6px rgba(60,176,52,.65)!important}div#green_channel img{height:20px;width:20px}',
  319. },
  320. cnblogs_base: {
  321. name: "美化",
  322. match: [
  323. /www.cnblogs.com\/[^\/]*$/,
  324. /www.cnblogs.com\/(sitehome|pick|candidate|subscription|following|aggsite|cate|comment)\//,
  325. ],
  326. directlyRun: true,
  327. values:
  328. '@charset "UTF-8";*{transition:all .1s}:root{--text-color-1:#202020;--text-color-2:#596172 // old: #555;--text-color-3:#555;--highlighted-color:#5e72e4;--theme-color:#5e72e4}#side_nav{position:sticky;top:8px}#side_nav .sidenav{width:fit-content;font-size:larger;padding-top:14px}#side_nav .sidenav .sidenav-item{margin:2px!important;padding:14px;border-radius:16px}#side_nav .sidenav .sidenav-item img{width:24px;height:24px}#side_nav .sidenav .sidenav-item:hover:not(.current-nav){background:rgba(204,204,204,.8)}#side_nav .sidenav .sidenav-item .dropdown-button>a{display:flex;align-items:center}#side_nav .sidenav .sidenav-category-active,#side_nav .sidenav .sidenav-item.current-nav{padding:14px!important;margin:2px 4px 2px 2px!important;font-weight:700}#side_nav .sidenav .sidenav-category-active img,#side_nav .sidenav .sidenav-item.current-nav img{width:26px;height:26px;box-shadow:inset 0 0 12px 32px rgba(205,255,255,.8509803922),-6px 3px 12px 6px rgba(0,255,255,.1215686275);border-radius:18px}#sidenav_more .dropdown-menu{left:6px;top:85%;font-size:large}#sidenav_more:hover .dropdown-menu{box-shadow:2px 5px 16px 4px #ccc}.post-list{border-top:1px dashed #dcdcdc;margin-top:20px}.post-list a{position:relative;color:#2d65b3!important}.post-list a,.post-list a:hover{text-decoration:none!important}.post-list a:hover:after{left:0!important;width:100%!important;transition:width 350ms!important}.post-list a:after{content:""!important;position:absolute!important;border-bottom:2px solid #f16d7a!important;bottom:-2px!important;left:100%!important;width:0!important;transition:width 350ms,left 350ms!important}.post-list a>em,.post-list a>strong{color:#f73131!important;text-decoration:none!important}.post-list .post-item .avatar{border-radius:4px;padding:0;border:1px solid rgba(34,34,34,.3333333333);margin-top:4px}.post-list>.post-item>.post-item-body>.post-item-text>.post-item-title,.post-list>.post-item>.post-item-body>.post-item-text>.post-item-title:link{color:var(--title-color-2);text-decoration:none;font-weight:500;font-size:19px}.post-list>.post-item>.post-item-body>.post-item-text>.post-item-title:focus,.post-list>.post-item>.post-item-body>.post-item-text>.post-item-title:hover,.post-list>.post-item>.post-item-body>.post-item-text>.post-item-title:link:focus,.post-list>.post-item>.post-item-body>.post-item-text>.post-item-title:link:hover{color:var(--highlighted-color);text-decoration:underline;text-decoration-thickness:2px;text-underline-offset:2px;text-decoration-color:var(--highlighted-color);transition:all .15s ease-in-out}.post-list>.post-item>.post-item-body>.post-item-text>.post-item-summary{color:var(--text-color-3);margin-top:8px;font-size:15px;font-family:-apple-system,MiSans,Microsoft YaHei,Tahoma,Arial,"Helvetica Neue",Helvetica,"Nimbus Sans L",Arial,"Liberation Sans","PingFang SC","Hiragino Sans GB","Source Han Sans CN","Source Han Sans SC","Microsoft YaHei","Wenquanyi Micro Hei","WenQuanYi Zen Hei","ST Heiti",SimHei,"WenQuanYi Zen Hei Sharp",sans-serif}.card.headline{background:rgba(240,248,255,.8705882353);border-radius:16px;box-shadow:2px 2px 14px 1px rgba(240,248,255,.8705882353)}.card.headline a{font-size:14px;color:#003aae}.card.headline a:hover{text-decoration:none}.card.headline a:hover #text{text-decoration:underline}.card.headline .headline-label{font-size:16px;color:#4242fb}#side_right{position:sticky;top:-2200px;height:fit-content}#side_right #sidebar_bh{background:#fff;padding:8px 16px;border-radius:16px}#side_right #sidebar_bh a{display:inline-grid;align-content:space-evenly;justify-content:start;align-items:stretch;justify-items:start;color:rgba(34,34,34,.8666666667);font-size:14px;grid-row-gap:6px}#side_right #sidebar_bh a:hover{color:#222;font-style:italic;text-decoration:none}#side_right #sidebar_bh a:before{content:"博客园 VIP 会员";font-size:18px;font-weight:700}#side_right #sidebar_bh a:after{content:" G O ! >>";color:#fff;font-weight:bolder;background:#4378ff;border-radius:14px;padding:6px 8px;margin:0 0 2px;font-style:italic;box-shadow:2px 1px 8px 0#4378ff}.sidebar .card .card-title{margin-bottom:12px;color:#444;font-size:15px;font-weight:700}.sidebar .item-list li{font-size:14px;margin:8px 0}.sidebar .item-list li:hover{font-size:15px;margin:10px -1px;color:#4378ff}#top_nav{border-bottom:1px solid rgba(0,0,0,.05);box-shadow:0 2px 4px 0 rgba(0,0,0,.05);font-family:-apple-system,BlinkMacSystemFont,PingFang SC,"Segoe UI",Hiragino Sans GB,Arial,Microsoft YaHei,Verdana,Roboto,Noto,Helvetica Neue,ui-sans-serif}#ing_iframe{width:100%;min-height:100%;scroll-behavior:hidden;border:0;overflow:hidden}',
  329. },
  330. cnblogs_auto_pager_ing: {
  331. name: "AutoPager",
  332. match: [/www.cnblogs.com\/#ing*$/],
  333. directlyRun: true,
  334. switchable: true,
  335. values: () => {
  336. // 功能实现在ing_in_iframe中
  337. },
  338. },
  339. cnblogs_auto_pager_home: {
  340. name: "AutoPager",
  341. match: [
  342. /www.cnblogs.com\/[^\/]*$/,
  343. /www.cnblogs.com\/(sitehome|pick|candidate|subscription|following|aggsite|cate|comment)\//,
  344. ],
  345. directlyRun: true,
  346. switchable: true,
  347. values: () => {
  348. timeoutAfterLoad(() => {
  349. if (
  350. !document.querySelector(".pager") ||
  351. document.querySelector("#Autopage_number")
  352. )
  353. return;
  354.  
  355. var timeout = 0;
  356. setInterval(() => {
  357. if (timeout > 0) timeout--;
  358. }, 1000);
  359. unsafeWindow.nextPage = nextPage;
  360.  
  361. setInterval(() => {
  362. if (!document.querySelector(".pager")) return;
  363.  
  364. if (
  365. document.body.offsetHeight - window.scrollY - window.innerHeight <
  366. window.innerHeight * 2
  367. ) {
  368. nextPage();
  369. }
  370. }, 2000);
  371.  
  372. function nextPage() {
  373. if (timeout > 0) return;
  374. timeout = 3;
  375.  
  376. getPage(document.querySelector(".pager > a:nth-last-child(1)").href, {
  377. onload: (response) => {
  378. try {
  379. const doc = new DOMParser().parseFromString(
  380. response.responseText,
  381. "text/html",
  382. ); //"text/html"
  383. const articles = doc.querySelectorAll("#post_list>article");
  384. for (const article of articles) {
  385. document
  386. .querySelector("#post_list")
  387. .insertAdjacentElement("beforeend", article);
  388. }
  389. document
  390. .querySelector(".pager")
  391. .parentNode.replaceChild(
  392. doc.querySelector(".pager"),
  393. document.querySelector(".pager"),
  394. );
  395. } catch (e) {
  396. console.error("ERR", e, response.responseText);
  397. }
  398. },
  399. });
  400.  
  401. // GM_xmlhttpRequest({
  402. // url: document.querySelector(".pager > a:nth-last-child(1)").href,
  403. // method: 'GET',
  404. // overrideMimeType: `text/html; charset=${document.characterSet || document.charset || document.inputEncoding}`,
  405. // headers: {
  406. // 'x-requested-with': 'XMLHttpRequest',
  407. // 'Referer': location.href,
  408. // 'User-Agent': navigator.userAgent,
  409. // 'Accept': 'text/html,application/xhtml+xml,application/xml'
  410. // },
  411. // timeout: 10000,
  412. // onload: (response) => {
  413. // try {
  414. // const doc = (new DOMParser()).parseFromString(response.responseText, "text/html");//"text/html"
  415. // const articles = doc.querySelectorAll('#post_list>article')
  416. // for (const article of articles) {
  417. // document.querySelector('#post_list').insertAdjacentElement('beforeend', article)
  418. // }
  419. // document.querySelector('.pager').parentNode.replaceChild(doc.querySelector('.pager'), document.querySelector('.pager'))
  420.  
  421. // } catch (e) {
  422. // console.error('ERR', e, response.responseText);
  423. // }
  424. // },
  425. // onerror: (response) => {
  426. // console.error(`ERR: URL:${url}`, response);
  427. // },
  428. // ontimeout: (response) => {
  429. // console.warn(`TIMEOUT: URL:${url}`, response);
  430. // }
  431. // });
  432. }
  433. }, 400);
  434. },
  435. },
  436.  
  437. };
  438.  
  439. run(features_cnblogs_1574814730);