EasyCNBLOGS

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

נכון ליום 17-12-2023. ראה הגרסה האחרונה.

  1. // ==UserScript==
  2. // @name EasyCNBLOGS
  3. // @description 这是一款促进博客园极致简洁和高效的插件。免费共享大量创新功能,如:净化页面等。让我们的学习体验无比简洁、专注、高效、畅快。
  4. // @version 5.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. }
  49. .post {
  50. border: unset !important;
  51. border-bottom-width: unset !important;
  52. border-right-width: unset !important;
  53. padding: unset !important;
  54. margin-bottom: unset !important;
  55. width: 80%;
  56. }
  57. .postText, .postBody {
  58. padding-right: unset !important;
  59. padding-left: unset !important;
  60. padding-bottom: unset !important;
  61. padding-top: unset !important;
  62. border-bottom: unset !important;
  63. }
  64.  
  65. /*调整标题*/
  66. span[role="heading"] {
  67. display: flex;
  68. justify-content: center;
  69. margin-top: 35px !important;
  70. margin-bottom: 20px !important;
  71. color: black !important;
  72. font-size: 33px !important;
  73. font-family: 'PingFang SC','Microsoft YaHei','SimHei','Arial','SimSun';
  74. font-weight: bold;
  75. }
  76.  
  77. /*调整文章信息栏*/
  78. .newinfo {
  79. background: #f8f8f8;
  80. border-radius: 4px;
  81. font-size: unset !important;
  82. display: flex;
  83. margin-bottom: 32px;
  84. align-items: center;
  85. }
  86. .newinfo a[href^="https://www.cnblogs.com/"] {
  87. margin-right: 23px;
  88. }
  89.  
  90. /*调整头像*/
  91. .newinfoimg {
  92. border-radius: 4px;
  93. width: 28px;
  94. height: 28px;
  95. margin: 6px;
  96. margin-right: 33px;
  97. }
  98. `;
  99.  
  100. //净化页面
  101. const purifyPage = function() {
  102. GM_addStyle(purify_style_pc);
  103. };
  104.  
  105. //超净化页面
  106. const purifyPageSuper = function() {
  107. const p = $(".post");
  108. $('body').innerHTML = "";
  109. $('body').appendChild(p);
  110. };
  111.  
  112. //调整标题
  113. const beautyTitle = function() {
  114. $('.post').insertBefore($('span[role="heading"]'), $('.post').childNodes[0]);
  115. };
  116.  
  117. //调整文章信息栏
  118. const beautyInfo = function() {
  119. const ninfo = document.createElement('div');
  120. ninfo.classList.add('newinfo');
  121. const ninfoimg = document.createElement('img');
  122. ninfoimg.classList.add('newinfoimg');
  123. ninfoimg.src = $('link[rel="shortcut icon"]').href;
  124. const info_user = $('.postDesc a[href^="https://www.cnblogs.com/"]') || $('.postfoot a[href^="https://www.cnblogs.com/"]') ;
  125. const info_date = $('.postDesc #post-date') || $('.postfoot #post-date');
  126. ninfo.append(ninfoimg);
  127. ninfo.append(info_user);
  128. ninfo.append(info_date);
  129. $('.post').insertBefore(ninfo, $('.post').childNodes[1]);
  130. };
  131.  
  132. document.addEventListener("DOMContentLoaded", function() {
  133. purifyPageSuper();
  134. beautyTitle();
  135. beautyInfo();
  136. });
  137.  
  138. purifyPage();
  139.  
  140. })();