cnblogs garden

better cnblogs

Versione datata 01/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.18
  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.18 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(){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})}
  47. function LoadConfigPage(name){if(!document.querySelector("#config-page-awa"))return style(`
  48. .config-page-awa {
  49. position: fixed;
  50. background-color: rgba(245, 200, 200, 0.2);
  51. z-index: 9999;
  52. top: 0;
  53. left: 0;
  54. width: 100vw;
  55. height: 100vh;
  56. display: block;
  57. justify-content: center;
  58. align-items: center;
  59. flex-direction: column;
  60. backdrop-filter: blur(20px);
  61. }
  62. .config-page-container {
  63. width: 60%;
  64. height: 60%;
  65. position: absolute;
  66. top: 15%;
  67. left: 15%;
  68. cursor: auto;
  69. border: 1px thin #cccccc10;
  70. border-radius: 20px;
  71. box-shadow: 0 0 10px rgba(0, 0, 0, 0.65);
  72. background-color: rgba(255, 255, 255, 0.6);
  73. overflow: hidden;
  74. padding: 15px;
  75. box-sizing: border-box;
  76. overflow-y: hidden;
  77. min-width: 360px;
  78. min-height: 420px;
  79. resize: both;
  80. }
  81. .config-page-drag-area {
  82. position: absolute;
  83. width: 100%;
  84. height: 100%;
  85. top: 0;
  86. left: 0;
  87. cursor: move;
  88. background-color: transparent;
  89. }
  90. .config-page-iframe {
  91. border: 0;
  92. border-radius: 18px;
  93. overflow: hidden;
  94. box-sizing: border-box;
  95. overflow-y: auto;
  96. opacity: 0.95;
  97. width: 100%;
  98. height: 100%;
  99. box-shadow: 1px 1px 4px rgba(185, 185, 185, 0.2);
  100. background-color: rgba(255, 255, 255, 0.25);
  101. margin: -1px;
  102. }
  103. .config-page-close-btn {
  104. position: absolute;
  105. top: 4px;
  106. right: 5px;
  107. font-size: 20px;
  108. background-color: transparent;
  109. border: 0;
  110. color: #C00;
  111. cursor: pointer;
  112. outline: none;
  113. padding: 0;
  114. margin: 0;
  115. }
  116. .config-page-close-btn:hover {
  117. color: #A00;
  118. }
  119. .config-page-close-btn:active {
  120. color: #f00;
  121. transform: scale(0.8);
  122. transition: 0.15s;
  123. }
  124. `),getConfigPage().then(fastestSite=>{document.body.insertAdjacentHTML("afterend",`
  125. <div class="config-page-awa" id="config-page-awa" style="display: none;">
  126. <div class="config-page-container">
  127. <div class="config-page-drag-area"></div>
  128. <iframe class="config-page-iframe"
  129. src="${fastestSite}?menuKey=${name}&iniframe"></iframe>
  130.  
  131. <button class="config-page-close-btn">⭕</button>
  132. </div>
  133. </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;
  134. 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"}
  135. 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()}
  136. 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})}
  137.  
  138.  
  139. function receiveMessage(event) {
  140. const data = event.data
  141. switch (data.type) {
  142. case "resizeIframe":
  143. document.getElementById("ing_iframe").style.height = `${data.height}px`;
  144. break;
  145.  
  146. default:
  147. break;
  148. }
  149. }
  150. unsafeWindow.addEventListener("message", receiveMessage, false);
  151.  
  152. function show_ing_iframe() {
  153. if (document.getElementById("ing_iframe")) return;
  154. timeoutAfterLoad(() => {
  155. const iframe = document.createElement('iframe')
  156. iframe.id = "ing_iframe"
  157. iframe.src = "https://ing.cnblogs.com/"
  158. document.querySelector('#main_flow').replaceChild(iframe, document.querySelector('#main_flow>.card'))
  159. }, 50)
  160. }
  161.  
  162. function getPage(url, obj) {
  163. GM_xmlhttpRequest({
  164. url: url,
  165. method: 'GET',
  166. overrideMimeType: `text/html; charset=${document.characterSet || document.charset || document.inputEncoding}`,
  167. headers: {
  168. 'x-requested-with': 'XMLHttpRequest',
  169. 'Referer': location.href,
  170. 'User-Agent': navigator.userAgent,
  171. 'Accept': 'text/html,application/xhtml+xml,application/xml'
  172. },
  173. timeout: 10000,
  174. onerror: (response) => {
  175. console.error(`ERR: URL:${url}`, response);
  176. },
  177. ontimeout: (response) => {
  178. console.warn(`TIMEOUT: URL:${url}`, response);
  179. },
  180. ...obj
  181. });
  182. }
  183.  
  184. 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"}})
  185.  
  186. let features_cnblogs_1574814730 = {
  187. cnblogs_side_right: {
  188. name: "右侧吸底",
  189. match: [
  190. /www.cnblogs.com\/[^\/]*$/,
  191. /www.cnblogs.com\/(sitehome|pick|candidate|subscription|following|aggsite|cate|comment)\//,
  192. ],
  193. directlyRun: true,
  194. switchable: true,
  195. values: () => {
  196. fn = () => {
  197. const side = document.getElementById("side_right");
  198. if (side && side.clientHeight > window.innerHeight)
  199. side.style.top = `${window.innerHeight - side.clientHeight}px`;
  200. else setTimeout(fn, 200);
  201. };
  202. timeoutAfterLoad(fn, 200);
  203. },
  204. },
  205. cnblogs_menu: {
  206. name: "sidenav",
  207. match: [
  208. /www.cnblogs.com\/[^\/]*$/,
  209. /www.cnblogs.com\/(sitehome|pick|candidate|subscription|following|aggsite|cate|comment)\//,
  210. ],
  211. directlyRun: true,
  212. switchable: true,
  213. values: () => {
  214. onload(() => {
  215. const sidenav = document.getElementsByClassName("sidenav")[0];
  216. function insertNavItem(pos, id, href, title, icon) {
  217. const li = document.createElement("li");
  218. li.id = id;
  219. li.className = "sidenav-item";
  220. li.innerHTML = `<a href="${href}" title="${title}">
  221. <img src="${icon}">
  222. <span>${title}</span>
  223. </a>`;
  224. sidenav.insertAdjacentElement(pos, li);
  225. return li;
  226. }
  227. const sidenav_ing = insertNavItem(
  228. "afterBegin",
  229. "sidenav_ing",
  230. "#ing",
  231. "闪存",
  232. "https://assets.cnblogs.com/images/ing/lucky-star-3-1.png",
  233. );
  234. sidenav_ing.addEventListener("click", () => show_ing_iframe());
  235.  
  236. const sidenav_home = insertNavItem(
  237. "afterBegin",
  238. "sidenav_home",
  239. "/",
  240. "主页",
  241. document.getElementById("user_icon").src,
  242. );
  243. if (/www.cnblogs.com\/#ing*$/.test(location.href)) {
  244. sidenav_ing.className += " current-nav";
  245. } else if (/www.cnblogs.com\/[^\/]*$/.test(location.href)) {
  246. sidenav_home.className += " current-nav";
  247. }
  248.  
  249. setTimeout(() => {
  250. sidenav_home.querySelector("img").src =
  251. document.getElementById("user_icon").src;
  252. }, 320);
  253. });
  254. },
  255. },
  256. cnblogs_logo: {
  257. name: "LOGO替换",
  258. match: [
  259. /www.cnblogs.com\/[^\/]*$/,
  260. /www.cnblogs.com\/(sitehome|pick|candidate|subscription|following|aggsite|cate|comment)\//,
  261. ],
  262. directlyRun: true,
  263. switchable: true,
  264. values:
  265. ".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}",
  266. },
  267. cnblogs_ing_in_iframe: {
  268. name: "ing_in_iframe",
  269. match: [/ing.cnblogs.com/],
  270. directlyRun: true,
  271. values: () => {
  272. var style =
  273. ":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}";
  274.  
  275. if (top === self) return style;
  276.  
  277. var style =
  278. style +
  279. "#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}";
  280. var refreshHeight = () => {
  281. unsafeWindow.parent.postMessage(
  282. {
  283. type: "resizeIframe",
  284. height:
  285. document.body.scrollHeight ?? document.body.clientHeight + 220,
  286. },
  287. "*",
  288. );
  289. };
  290. const observer = new MutationObserver(function (mutations) {
  291. mutations.forEach(function (mutation) {
  292. // 遍历所有变化
  293. if (mutation.type === "childList") {
  294. refreshHeight();
  295. } else if (mutation.type === "attributes") {
  296. // 属性变化
  297. }
  298. });
  299. });
  300. onload(() => {
  301. refreshHeight();
  302.  
  303. // 观察 #main 元素
  304. observer.observe(document.getElementById("main"), {
  305. childList: true,
  306. attributes: false,
  307. subtree: true,
  308. });
  309. });
  310.  
  311. timeoutAfterLoad(() => {
  312. // if (!document.querySelector(".pager")) return
  313.  
  314. var timeout = 0;
  315. setInterval(() => {
  316. if (timeout > 0) timeout--;
  317. }, 1000);
  318. unsafeWindow.nextPage = nextPage;
  319. document.querySelectorAll(".pager").forEach((el) => el.remove());
  320.  
  321. function receiveMessage(event) {
  322. const data = event.data;
  323. switch (data.type) {
  324. case "nextPage":
  325. nextPage();
  326. break;
  327.  
  328. default:
  329. break;
  330. }
  331. }
  332. if (get("cnblogs_auto_pager_ing_switch")) {
  333. unsafeWindow.addEventListener("message", receiveMessage, false);
  334. }
  335.  
  336. function nextPage() {
  337. if (timeout > 0) return;
  338. timeout = 3;
  339.  
  340. IngListType = "All";
  341. PageIndex = 2;
  342. getPage(
  343. `/ajax/ing/GetIngList?IngListType=${IngListType}&PageIndex=${PageIndex}&PageSize=30&Tag=&_=${Date.now()}`,
  344. {
  345. onload: (response) => {
  346. try {
  347. const doc = response.responseText;
  348. document
  349. .querySelector(".feed_block")
  350. .insertAdjacentHTML("beforeend", doc);
  351.  
  352. document
  353. .querySelectorAll(".feed_loading")
  354. .forEach((el) => el.remove());
  355. document
  356. .querySelector(".feed_block")
  357. .insertAdjacentHTML(
  358. "beforeend",
  359. `<div class="feed_loading"><img align="absmiddle" src="//assets.cnblogs.com/images/loading.gif" alt=""> 正在加载数据...</div>`,
  360. );
  361. PageIndex++;
  362. } catch (e) {
  363. console.error("ERR", e, response.responseText);
  364. }
  365. },
  366. onerror: (response) => {
  367. console.error(`ERR: URL:${url}`, response);
  368. },
  369. },
  370. );
  371. }
  372. }, 400);
  373.  
  374. return style;
  375. },
  376. },
  377. cnblogs_ing: {
  378. name: "ing",
  379. match: [/www.cnblogs.com\/#ing*$/],
  380. directlyRun: true,
  381. values: () => {
  382. show_ing_iframe();
  383. if (get("cnblogs_auto_pager_ing_switch")) {
  384. setInterval(() => {
  385. if (
  386. document.body.offsetHeight - window.scrollY - window.innerHeight <
  387. window.innerHeight * 2
  388. ) {
  389. document
  390. .getElementById("ing_iframe")
  391. .contentWindow.postMessage({ type: "nextPage" }, "*");
  392. }
  393. }, 2000);
  394. }
  395. },
  396. },
  397. cnblogs_better_skin: {
  398. name: "better_skin",
  399. match: true,
  400. directlyRun: true,
  401. switchable: true,
  402. values:
  403. '.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}',
  404. },
  405. cnblogs_base: {
  406. name: "美化",
  407. match: [
  408. /www.cnblogs.com\/[^\/]*$/,
  409. /www.cnblogs.com\/(sitehome|pick|candidate|subscription|following|aggsite|cate|comment)\//,
  410. ],
  411. directlyRun: true,
  412. values:
  413. '@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}',
  414. },
  415. cnblogs_auto_pager_ing: {
  416. name: "AutoPager",
  417. match: [/www.cnblogs.com\/#ing*$/],
  418. directlyRun: true,
  419. switchable: true,
  420. values: () => {
  421. // 功能实现在ing_in_iframe中
  422. },
  423. },
  424. cnblogs_auto_pager_home: {
  425. name: "AutoPager",
  426. match: [
  427. /www.cnblogs.com\/[^\/]*$/,
  428. /www.cnblogs.com\/(sitehome|pick|candidate|subscription|following|aggsite|cate|comment)\//,
  429. ],
  430. directlyRun: true,
  431. switchable: true,
  432. values: () => {
  433. timeoutAfterLoad(() => {
  434. if (
  435. !document.querySelector(".pager") ||
  436. document.querySelector("#Autopage_number")
  437. )
  438. return;
  439.  
  440. var timeout = 0;
  441. setInterval(() => {
  442. if (timeout > 0) timeout--;
  443. }, 1000);
  444. unsafeWindow.nextPage = nextPage;
  445.  
  446. setInterval(() => {
  447. if (!document.querySelector(".pager")) return;
  448.  
  449. if (
  450. document.body.offsetHeight - window.scrollY - window.innerHeight <
  451. window.innerHeight * 2
  452. ) {
  453. nextPage();
  454. }
  455. }, 2000);
  456.  
  457. function nextPage() {
  458. if (timeout > 0) return;
  459. timeout = 3;
  460.  
  461. getPage(document.querySelector(".pager > a:nth-last-child(1)").href, {
  462. onload: (response) => {
  463. try {
  464. const doc = new DOMParser().parseFromString(
  465. response.responseText,
  466. "text/html",
  467. ); //"text/html"
  468. const articles = doc.querySelectorAll("#post_list>article");
  469. for (const article of articles) {
  470. document
  471. .querySelector("#post_list")
  472. .insertAdjacentElement("beforeend", article);
  473. }
  474. document
  475. .querySelector(".pager")
  476. .parentNode.replaceChild(
  477. doc.querySelector(".pager"),
  478. document.querySelector(".pager"),
  479. );
  480. } catch (e) {
  481. console.error("ERR", e, response.responseText);
  482. }
  483. },
  484. });
  485.  
  486. // GM_xmlhttpRequest({
  487. // url: document.querySelector(".pager > a:nth-last-child(1)").href,
  488. // method: 'GET',
  489. // overrideMimeType: `text/html; charset=${document.characterSet || document.charset || document.inputEncoding}`,
  490. // headers: {
  491. // 'x-requested-with': 'XMLHttpRequest',
  492. // 'Referer': location.href,
  493. // 'User-Agent': navigator.userAgent,
  494. // 'Accept': 'text/html,application/xhtml+xml,application/xml'
  495. // },
  496. // timeout: 10000,
  497. // onload: (response) => {
  498. // try {
  499. // const doc = (new DOMParser()).parseFromString(response.responseText, "text/html");//"text/html"
  500. // const articles = doc.querySelectorAll('#post_list>article')
  501. // for (const article of articles) {
  502. // document.querySelector('#post_list').insertAdjacentElement('beforeend', article)
  503. // }
  504. // document.querySelector('.pager').parentNode.replaceChild(doc.querySelector('.pager'), document.querySelector('.pager'))
  505.  
  506. // } catch (e) {
  507. // console.error('ERR', e, response.responseText);
  508. // }
  509. // },
  510. // onerror: (response) => {
  511. // console.error(`ERR: URL:${url}`, response);
  512. // },
  513. // ontimeout: (response) => {
  514. // console.warn(`TIMEOUT: URL:${url}`, response);
  515. // }
  516. // });
  517. }
  518. }, 400);
  519. },
  520. },
  521.  
  522. };
  523.  
  524. run(features_cnblogs_1574814730);