极致净化 CSDN 社区

完美阅读体验,去除广告、推荐等一系列和阅读无关的内容

  1. // ==UserScript==
  2. // @name 极致净化 CSDN 社区
  3. // @namespace https://evgo2017.com/purify-page
  4. // @version 0.1
  5. // @description 完美阅读体验,去除广告、推荐等一系列和阅读无关的内容
  6. // @author evgo2017
  7. // @license GNU GPLv2
  8. // @match https://bbs.csdn.net/topics/*
  9. // @icon https://g.csdnimg.cn/static/logo/favicon32.ico
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. const maxRetryCount = 5; // 最大重试次数
  17.  
  18. // 移除区域
  19. remove('顶部导航栏', `.ccloud-tool-bar`)
  20. remove('右侧导航栏', `#right-floor-user-content_562`)
  21. remove('下方悬浮评论条', `.commentToolbar`)
  22. remove('右侧二维码、客服、返回顶部', `.csdn-side-toolbar`)
  23. remove('给本贴投票', `.rates-outer`)
  24. remove('下一篇', `.upDownPage`)
  25. remove('相关推荐', `.recommendList`)
  26. remove('页面底部', `.public_pc_right_footer2020`)
  27.  
  28. // 最大化阅读区域
  29. setTimeout(() => {
  30. $(`.home_wrap`).style.paddingTop = '0'
  31. $(`.cloud-maintainer`).style.margin = '0'
  32. $(`.cloud-maintainer`).style.setProperty('width', '100%', 'important')
  33. $(`.detail-container`).style.setProperty('width', '100%', 'important')
  34. $(`html`).style.paddingRight = '17px'
  35. }, 1000)
  36.  
  37. // Helper
  38. function remove(label, selector, userOption = {}, count = 1) {
  39. const option = Object.assign({ repeat: false, getDom: (dom) => dom, }, userOption)
  40. const dom = option.getDom($(selector))
  41. if (dom) {
  42. dom.remove()
  43. console.log(`${label},%c已移除%c。(第 ${count} 次处理)`, "color: red; font-weight: bold", "color: black")
  44. if (option.repeat) {
  45. setTimeout(() => { remove(label, selector, option, count + 1) }, 1000)
  46. }
  47. } else {
  48. if (count < maxRetryCount) {
  49. console.log(`${label},未找到。(第 ${count} 次处理)`)
  50. setTimeout(() => { remove(label, selector, option, count + 1) }, 1000)
  51. } else {
  52. console.log(`${label},%c停止查找%c。(第 ${count} 次处理)`, "color: orange; font-weight: bold", "color: black")
  53. }
  54. }
  55. }
  56. function $ (selector) {
  57. return document.querySelector(selector)
  58. }
  59. })();

QingJ © 2025

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