极致净化简书文章页

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

  1. // ==UserScript==
  2. // @name 极致净化简书文章页
  3. // @namespace https://evgo2017.com/purify-page
  4. // @version 0.12
  5. // @description 完美阅读体验,去除广告、推荐等一系列和阅读无关的内容
  6. // @author evgo2017
  7. // @license GNU GPLv2
  8. // @match https://www.jianshu.com/p/*
  9. // @icon https://cdn2.jianshu.io/assets/favicons/favicon-e743bfb1821442341c3ab15bdbe804f7ad97676bd07a770ccc9483473aa76f06.ico
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. const maxRetryCount = 5; // 最大重试次数
  17.  
  18. setTimeout(() => {
  19.  
  20. // 移除区域
  21. remove('顶部导航栏', `header`,{ repeat: true })
  22. remove('边栏', `aside`,{ repeat: true })
  23. remove('左侧分享', `._3Pnjry`,{ repeat: true })
  24.  
  25. remove('下方点赞、文章分类', `._1kCBjS`)
  26. remove('更多精彩内容,就在简书APP、赞赏支持', `._13lIbp`)
  27. remove('下方作者信息', `.d0hShY`, { getDom: (dom) => { if (dom) { dom.innerHTML = ''; dom.style.padding = 0 } } })
  28.  
  29. remove('下方广告', `._3VRLsv ._11TSfs`, { getDom: (dom) => { if (dom) { return dom.parentElement } }} )
  30. remove('下方广告', `._3VRLsv .adad_container`, { repeat: true })
  31.  
  32. remove('好文要顶、关注我、收藏该文、文章分享', `footer`)
  33. remove('分类、上一篇下一篇', `#blog_post_info_block`)
  34. remove('专栏收入、推荐阅读', `#note-page-comment`, { getDom: (dom) => dom ? dom.nextSibling : null })
  35. remove('回到顶部', `.ant-back-top`, { repeat: true })
  36.  
  37. removes('广告供应商', `.adModule`)
  38.  
  39. remove('下方广告', `._3VRLsv`, { repeat: true, getDom: (dom) => {
  40. if (dom) {
  41. return [...dom.querySelectorAll('_gp-ck>.ouvJEz')].slice(1)
  42. }
  43. }})
  44.  
  45. remove('悬浮广告窗', `html`, { repeat: true, getDom: (dom) => {
  46. if (dom) {
  47. return [...dom.querySelectorAll('body>div'), ...dom.querySelectorAll('body>div>div')].filter(d => {
  48. return window.getComputedStyle(d, null).zIndex > 2147483640
  49. })
  50. }
  51. }})
  52.  
  53. // 最大化阅读区域
  54. const mainArea = $('._3VRLsv')
  55. mainArea.style.boxSizing = 'border-box'
  56. mainArea.style.margin = '0'
  57. mainArea.style.width = '100%'
  58. $('._gp-ck').style.width = '100%'
  59.  
  60. $('._2xr8G8').style.position = 'static'; // 评论点赞固定在最后,不 fixed
  61. }, 1000)
  62.  
  63. // Helper
  64. function removes(label, selector, userOption = {}, count = 1) {
  65. const option = Object.assign({ repeat: false }, userOption)
  66. const doms = document.querySelectorAll(selector)
  67. if (doms.length > 0) {
  68. for (let i = 0, len = doms.length; i < len; i++) {
  69. doms[i].remove()
  70. console.log(`${label},%c已移除%c。(第 ${count} 次处理)`, "color: red; font-weight: bold", "color: black")
  71. }
  72. if (option.repeat) {
  73. setTimeout(() => { remove(label, selector, option, count + 1) }, 1000)
  74. }
  75. } else {
  76. if (count < maxRetryCount) {
  77. console.log(`${label},未找到。(第 ${count} 次处理)`)
  78. setTimeout(() => { removes(label, selector, option, count + 1) }, 1000)
  79. } else {
  80. console.log(`${label},%c停止查找%c。(第 ${count} 次处理)`, "color: orange; font-weight: bold", "color: black")
  81. }
  82. }
  83. }
  84. function remove(label, selector, userOption = {}, count = 1) {
  85. const option = Object.assign({ repeat: false, getDom: (dom) => dom, }, userOption)
  86. const dom = option.getDom($(selector))
  87. if (dom && (Array.isArray(dom) ? dom.length > 0 : true )) {
  88. if (Array.isArray(dom)) {
  89. dom.forEach(d => d.remove())
  90. } else {
  91. dom.remove()
  92. }
  93. console.log(`${label},%c已移除%c。(第 ${count} 次处理)`, "color: red; font-weight: bold", "color: black")
  94. if (option.repeat) {
  95. setTimeout(() => { remove(label, selector, option, count + 1) }, 1000)
  96. }
  97. } else {
  98. if (count < maxRetryCount) {
  99. console.log(`${label},未找到。(第 ${count} 次处理)`)
  100. setTimeout(() => { remove(label, selector, option, count + 1) }, 1000)
  101. } else {
  102. console.log(`${label},%c停止查找%c。(第 ${count} 次处理)`, "color: orange; font-weight: bold", "color: black")
  103. }
  104. }
  105. }
  106. function $ (selector) {
  107. return document.querySelector(selector)
  108. }
  109. })();

QingJ © 2025

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