CSDN优化

CSDN阅读优化

  1. // ==UserScript==
  2. // @name CSDN优化
  3. // @description CSDN阅读优化
  4. // @namespace Violentmonkey Scripts
  5. // @match *://*.blog.csdn.net/*/article/details/*
  6. // @grant none
  7. // @version 1.2
  8. // ==/UserScript==
  9. ;(function() {
  10. function hide(dom) {
  11. if (!dom) {
  12. return
  13. }
  14. if (dom instanceof NodeList) {
  15. dom.forEach(function(item, index) {
  16. item.style.display = 'none'
  17. })
  18. }
  19. if (dom instanceof Node) {
  20. dom.style.display = 'none'
  21. }
  22. }
  23.  
  24. function exec(){
  25. // 文章展开
  26. hide(document.querySelector('main>.hide-article-box'))
  27. document.querySelector('main>.blog-content-box>article>div').style.height = 'auto'
  28.  
  29. // 评论展开
  30. hide(document.querySelector('.comment-list-container>.opt-box'))
  31. document.querySelector('.comment-list-container>.comment-list-box').style.maxHeight = null
  32.  
  33. // 底栏
  34. hide(document.querySelector('.pulllog-box'))
  35.  
  36. // 去除广告
  37. hide(document.querySelectorAll('.recommend-ad-box'))
  38. hide(document.querySelector('#adContent'))
  39. hide(document.querySelector('._360_interactive'))
  40. hide(document.querySelector('.fourth_column'))
  41. document.querySelectorAll('main>*').forEach(function(item, index) {
  42. var idStr = item.getAttribute('id') || ''
  43. if (idStr.indexOf('_ad') != -1) {
  44. hide(item)
  45. }
  46. })
  47. document.querySelectorAll('aside>*').forEach(function(item, index) {
  48. var classStr = item.className || ''
  49. var idStr = item.getAttribute('id') || ''
  50. if (classStr.indexOf('csdn-tracking-statistics') != -1) {
  51. hide(item)
  52. } else if (idStr == 'asideFooter') {
  53. if (item.children.length == 2) {
  54. hide(item.children[0])
  55. }
  56. }
  57. })
  58. }
  59.  
  60. window.addEventListener('load', exec, false)
  61. })()

QingJ © 2025

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