净化常用国内博客

纯净进行 Ctrl+C, 贯彻执行 write once run everywhere.源码:https://jsrun.net/dHsKp

  1. // ==UserScript==
  2. // @name 净化常用国内博客
  3. // @namespace https://github.com/jackkke
  4. // @namespace https://gitee.com/jackkke
  5. // @version 1.5
  6. // @description 纯净进行 Ctrl+C, 贯彻执行 write once run everywhere.源码:https://jsrun.net/dHsKp
  7. // @author jackkke hangao1204@hotmail.com
  8. // @match *://blog.csdn.net/*
  9. // @match *://www.cnblogs.com/*
  10. // @match *://www.jianshu.com/*
  11. // @match *://juejin.cn/*
  12. // @match *://www.oschina.net/*
  13. // @match *://segmentfault.com/*
  14. // @match *://www.jb51.net/*
  15. // ==/UserScript==
  16. (function () {
  17. 'use strict';
  18. let blogSiteDb = {
  19. csdn: {
  20. siteId: 'csdn',
  21. remove_class: ['blog_container_aside', 'insert-baidu-box', 'first-recommend-box', 'second-recommend-box', 'blog-footer-bottom', 'template-box', 'recommend-nps-box', 'tool-QRcode', 'kind_person', 'csdn-common-logo-advert', 'toolbar-advert'],
  22. remove_id: ['asideHotArticle', 'asideNewComments', 'asideArchive', 'asideNewNps', 'asideSearchArticle',],
  23. remove_more: ['.csdn-side-toolbar a:not(:last-child)',],
  24. pro_styles: []
  25. },
  26. 'cnblogs': {
  27. siteId: 'cnblogs',
  28. remove_class: [],
  29. remove_id: ['cnblogs_c1', 'under_post_card1', 'under_post_card2', 'sideBar'],
  30. remove_more: [],
  31. pro_styles: ['#mainContent{margin: 0;}', '.forFlow{margin: 15px;}']
  32. },
  33. 'jianshu': {
  34. siteId: 'jianshu',
  35. remove_class: ['_13lIbp', 'ouvJEz:last-of-type', '_1jKNin'],
  36. remove_id: [],
  37. remove_more: ['footer', 'footer ~ div', 'aside',],
  38. pro_styles: []
  39. },
  40. 'juejin': {
  41. siteId: 'juejin',
  42. remove_class: ['.extension', '.recommended-area', '.sidebar', '.article-suspended-panel'],
  43. remove_id: [],
  44. remove_more: [],
  45. pro_styles: []
  46. },
  47. 'oschina': {
  48. siteId: 'oschina',
  49. remove_class: ['other-articles-box', 'detail-toolbar-box', 'sidebar-box', 'codeBlock'],
  50. remove_id: ['footer'],
  51. remove_more: [],
  52. pro_styles: []
  53. },
  54. 'segmentfault': {
  55. siteId: 'segmentfault',
  56. remove_class: ['functional-area-left', 'right-side', 'recommend-list-wrap', 'border-width-2'],
  57. remove_id: ['#footer'],
  58. remove_more: [],
  59. pro_styles: []
  60. },
  61. 'jb51': {
  62. siteId: 'jb51',
  63. remove_class: ['xgcomm', 'main-right', 'art_xg'],
  64. remove_id: ['footer', 'ewm', 'right-share'],
  65. remove_more: [],
  66. pro_styles: []
  67. }
  68. };
  69. let handle = function (host, type) {
  70. const hosts = host.split('.');
  71. const id = hosts[hosts.length - 2];
  72. if (blogSiteDb.hasOwnProperty(id)) {
  73. console.log('refine current site [' + id + '] by jackkke');
  74. if (type === 'style') {
  75. handleCss(blogSiteDb[id])
  76. } else if (type === 'javascript') {
  77. handleJs(blogSiteDb[id])
  78. } else {
  79. console.error('处理类型有误!')
  80. }
  81. }
  82. };
  83. let handleCss = function (db) {
  84. let style = document.createElement('style');
  85. db.remove_class.forEach(function (css) {
  86. style.appendChild(document.createTextNode('.' + css + '{display: none!important;}'))
  87. });
  88. db.remove_id.forEach(function (id) {
  89. style.appendChild(document.createTextNode('#' + id + '{display: none!important;}'))
  90. });
  91. db.remove_more.forEach(function (more) {
  92. style.appendChild(document.createTextNode(more + '{display: none!important;}'))
  93. });
  94. db.pro_styles.forEach(function (pro_style) {
  95. style.appendChild(document.createTextNode(pro_style))
  96. });
  97. document.getElementsByTagName('head')[0].appendChild(style)
  98. };
  99. let handleJs = function (db) {
  100. db.remove_class.forEach(function (css) {
  101. let elements = document.getElementsByClassName(css);
  102. if (elements && elements.length > 0) {
  103. Array.prototype.forEach.call(elements, function (element) {
  104. element.remove()
  105. })
  106. }
  107. });
  108. db.remove_id.forEach(function (id) {
  109. document.getElementById(id).remove()
  110. })
  111. };
  112. handle(location.host, 'style');
  113.  
  114. function newLoadHandler() {
  115. handle(location.host, 'javascript')
  116. }
  117. var oldLoadHandler = window.onload;
  118. window.onload = function () {
  119. if (oldLoadHandler) {
  120. oldLoadHandler()
  121. }
  122. newLoadHandler()
  123. }
  124. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址