EasyCNBLOGS

这是一款促进博客园极致简洁和高效的插件。免费共享大量创新功能,如:净化页面等。让我们的学习体验无比简洁、专注、高效、畅快。

目前为 2023-12-17 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name EasyCNBLOGS
  3. // @description 这是一款促进博客园极致简洁和高效的插件。免费共享大量创新功能,如:净化页面等。让我们的学习体验无比简洁、专注、高效、畅快。
  4. // @version 7.0
  5. // @author xcanwin
  6. // @namespace https://github.com/xcanwin/EasyCNBLOGS/
  7. // @supportURL https://github.com/xcanwin/EasyCNBLOGS/
  8. // @license GPL-2.0-only
  9. // @match *://www.cnblogs.com/*/p/*.html
  10. // @match *://www.cnblogs.com/*/archive/*.html
  11. // @grant GM_addStyle
  12. // @run-at document-start
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. const $ = (Selector, el) => (el || document).querySelector(Selector);
  19. const $$ = (Selector, el) => (el || document).querySelectorAll(Selector);
  20.  
  21. /*电脑端净化样式*/
  22. const purify_style_pc = `
  23. .postTitle /*隐藏[正文的][顶部的]原标题*/,
  24. #right_meun /*隐藏[正文的][右边的]栏*/,
  25. #blog_post_info_block /*隐藏[正文的][底部的]推荐关注*/,
  26. .postDesc /*隐藏[正文的][底部的]文章信息栏*/,
  27. .postfoot /*隐藏[正文的][底部的]文章信息栏2*/
  28. {
  29. display: none !important;
  30. }
  31.  
  32. /*隐藏背景*/
  33. html body {
  34. background: none !important;
  35. background-image: unset !important;
  36. background-color: unset !important;
  37. }
  38.  
  39. /*展示全屏*/
  40. body {
  41. margin-left: unset !important;
  42. margin-right: unset !important;
  43. margin-bottom: unset !important;
  44. padding: unset !important;
  45. padding-bottom: unset !important;
  46. display: flex;
  47. justify-content: center;
  48. font-size: 16px !important;
  49. }
  50. .post {
  51. border: unset !important;
  52. border-bottom-width: unset !important;
  53. border-right-width: unset !important;
  54. padding: unset !important;
  55. margin-bottom: unset !important;
  56. width: 80%;
  57. font-size: 16px !important;
  58. }
  59. .postText, .postBody {
  60. padding-right: unset !important;
  61. padding-left: unset !important;
  62. padding-bottom: unset !important;
  63. padding-top: unset !important;
  64. border-bottom: unset !important;
  65. }
  66.  
  67. /*调整标题*/
  68. span[role="heading"] {
  69. display: flex;
  70. justify-content: center;
  71. margin-top: 35px !important;
  72. margin-bottom: 20px !important;
  73. color: black !important;
  74. font-size: 33px !important;
  75. font-family: 'PingFang SC','Microsoft YaHei','SimHei','Arial','SimSun';
  76. font-weight: bold;
  77. }
  78.  
  79. /*调整文章信息栏*/
  80. .newinfo {
  81. background: #f8f8f8;
  82. border-radius: 4px;
  83. font-size: 13px !important;
  84. display: flex;
  85. margin-bottom: 32px;
  86. align-items: center;
  87. }
  88. .newinfo a[href^="https://www.cnblogs.com/"] {
  89. margin-right: 23px;
  90. }
  91.  
  92. /*调整头像*/
  93. .newinfoimg {
  94. border-radius: 4px;
  95. width: 28px;
  96. height: 28px;
  97. margin: 6px;
  98. margin-right: 33px;
  99. }
  100.  
  101. /*正文的图片居中*/
  102. .post p img {
  103. display: flex;
  104. margin-left: auto;
  105. margin-right: auto;
  106. }
  107. `;
  108.  
  109. //净化页面
  110. const purifyPage = function() {
  111. GM_addStyle(purify_style_pc);
  112. };
  113.  
  114. //超净化页面
  115. const purifyPageSuper = function() {
  116. const p = $(".post");
  117. $('body').innerHTML = "";
  118. $('body').appendChild(p);
  119. };
  120.  
  121. //调整标题
  122. const beautyTitle = function() {
  123. $('.post').insertBefore($('span[role="heading"]'), $('.post').childNodes[0]);
  124. };
  125.  
  126. //调整文章信息栏
  127. const beautyInfo = function() {
  128. const ninfo = document.createElement('div');
  129. ninfo.classList.add('newinfo');
  130. const ninfoimg = document.createElement('img');
  131. ninfoimg.classList.add('newinfoimg');
  132. ninfoimg.src = $('link[rel="shortcut icon"]').href;
  133. const info_user = $('.postDesc a[href^="https://www.cnblogs.com/"]') || $('.postfoot a[href^="https://www.cnblogs.com/"]') ;
  134. info_user.style = 'color: #404040';
  135. const info_date = $('.postDesc #post-date') || $('.postfoot #post-date');
  136. info_date.style = 'color: #969696';
  137. ninfo.append(ninfoimg);
  138. ninfo.append(info_user);
  139. ninfo.append(info_date);
  140. $('.post').insertBefore(ninfo, $('.post').childNodes[1]);
  141. };
  142.  
  143. document.addEventListener("DOMContentLoaded", function() {
  144. purifyPageSuper();
  145. beautyTitle();
  146. beautyInfo();
  147. });
  148.  
  149. purifyPage();
  150.  
  151. })();