CSDN 优化

优化 CSDN 体验

  1. // ==UserScript==
  2. // @name CSDN 优化
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3.2
  5. // @description 优化 CSDN 体验
  6. // @author share121
  7. // @match https://blog.csdn.net/*/article/details/*
  8. // @icon https://g.csdnimg.cn/static/logo/favicon32.ico
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. window.addEventListener(
  14. 'copy',
  15. e => (e.stopImmediatePropagation?.(), e.stopPropagation(), !1),
  16. !0
  17. )
  18. setTimeout(() => {
  19. document
  20. .querySelectorAll('a')
  21. .forEach(e =>
  22. e.addEventListener(
  23. 'click',
  24. a => (
  25. a.stopImmediatePropagation?.(),
  26. a.stopPropagation(),
  27. (e.target = '_blank'),
  28. !1
  29. ),
  30. !0
  31. )
  32. )
  33. }, 500)
  34. document.querySelectorAll('pre, code').forEach(e => {
  35. e.style.cssText +=
  36. '-webkit-touch-callout:auto;-webkit-user-select:auto;-khtml-user-select:auto;-moz-user-select:auto;-ms-user-select:auto;user-select:auto;'
  37. })
  38. document.querySelectorAll('.hljs-button.signin').forEach(e => {
  39. e.onclick = a => {
  40. a.stopPropagation()
  41. navigator.clipboard.writeText(e.parentNode.innerText).then(() => {
  42. e.dataset.title = '复制成功'
  43. setTimeout(() => {
  44. e.dataset.title = '复制'
  45. }, 3000)
  46. })
  47. }
  48. e.dataset.title = '复制'
  49. })
  50. let tmp = setInterval(() => {
  51. let button = document.querySelector('#passportbox > span')
  52. if (button) {
  53. clearInterval(tmp)
  54. button.click()
  55. }
  56. })
  57. document.querySelector('#article_content').style.height = 'auto'
  58. document.querySelector('.hide-article-box.hide-article-pos')?.remove()
  59. document.querySelector('#blogExtensionBox')?.remove()
  60. document.querySelectorAll('.look-more-preCode').forEach(e => e.click())
  61. document
  62. .querySelectorAll('.newcomment-list .ellipsis')
  63. .forEach(e => e.classList.remove('ellipsis'))