csdn纯净版

csdn纯净版-只保留文字与评论

  1. // ==UserScript==
  2. // @name csdn纯净版
  3. // @description csdn纯净版-只保留文字与评论
  4. // @version 0.3
  5. // @author tomiaa
  6. // @match *://blog.csdn.net/*
  7. // @namespace http://tampermonkey.net/
  8.  
  9.  
  10. // ==/UserScript==
  11. ; (() => {
  12. const $ = id => document.querySelector(id);
  13. console.clear();
  14. const config = {
  15. 'default': {
  16. remove: [
  17. /* 左侧 */
  18. '#asideSearchArticle',
  19. '#asideHotArticle',
  20. '#asideCategory',
  21. '#asideNewNps',
  22. '#asideArchive',
  23. '.aside-box-footer',
  24. '#asideNewComments',
  25.  
  26. '.blog-tags-box',
  27. '.article-type-img',
  28. '.c-gray',
  29. '#blogColumnPayAdvert',
  30. '#health-companies',
  31. '.tool-QRcode',
  32. '.toolbar-advert',
  33.  
  34.  
  35.  
  36. /* 右侧 */
  37. '#asideArchive',
  38. '.csdn-side-toolbar',
  39.  
  40.  
  41. '#copyright-box', // 底部
  42. '.recommend-box', // 推荐文章
  43. '.recommend-tit-mod',
  44. '.template-box',
  45.  
  46. '.comment-sofa-flag',
  47.  
  48. '#footerRightAds',
  49.  
  50.  
  51. ],
  52. css: `
  53. .more-toolbox-active .left-toolbox{
  54. transform: translateX(-34.4%) !important;
  55. left: 50% !important;
  56. }
  57. body{
  58. background: #f6f0da !important;
  59. }
  60. `,
  61. }
  62. }
  63. class Clear {
  64.  
  65. constructor(config) {
  66. this.config = config;
  67. this.domain = '';
  68. this.query = null;
  69. this.init();
  70. }
  71.  
  72. init() {
  73. // const currentHref = location.href.split('?');
  74. // this.domain = currentHref[0];
  75. this.domain = 'default'
  76. // this.query = currentHref[1];
  77. console.log(this.domain);
  78.  
  79. this.removeToHidden(this.config?.[this.domain]?.remove);
  80. this.addCss(this.config?.[this.domain]?.css);
  81. this.remove(this.config?.[this.domain]?.remove);
  82. this.config?.[this.domain]?.fn?.();
  83.  
  84. }
  85.  
  86. remove(arr = []) {
  87. arr.map(item => $(item)).forEach(item => {
  88. item?.remove();
  89. })
  90. }
  91.  
  92. removeToHidden(arr = []) {
  93. if (!arr.length) return;
  94. this.addCss(arr.join(',') + `{
  95. display: none !important;
  96. }`)
  97. }
  98.  
  99. addCss(css = '') {
  100. if (!css) return;
  101. let style = document.createElement('style')
  102. style.innerHTML = css;
  103. document.documentElement.appendChild(style);
  104. }
  105.  
  106. }
  107. new Clear(config);
  108. })();