gnmdcsdn

友好阅读 CSDN,你不干净,我帮你干净; 搭配 Dark Reader 体验更佳: https://chrome.google.com/webstore/detail/eimadpbcbfnmbkopoojfekhnkhdbieeh

  1. // ==UserScript==
  2. // @name gnmdcsdn
  3. // @namespace http://tampermonkey.net/
  4. // @description 友好阅读 CSDN,你不干净,我帮你干净; 搭配 Dark Reader 体验更佳: https://chrome.google.com/webstore/detail/eimadpbcbfnmbkopoojfekhnkhdbieeh
  5. // @author You
  6. // @match *://*.csdn.net/*
  7. // @icon https://www.google.com/s2/favicons?sz=64&domain=csdn.com
  8. // @grant none
  9. // @version 1.0.9
  10. // @license MIT
  11. // ==/UserScript==
  12. (function () {
  13. "use strict";
  14. // 复制当前文章内容
  15. const title = document.querySelector('#articleContentId').innerHTML;
  16. const content = document.querySelector('#content_views').innerHTML;
  17.  
  18. // 停止当前页面的所有加载
  19. window.stop();
  20.  
  21. // 打开文档流
  22. document.open();
  23.  
  24. // 写入新的 HTML 内容
  25. document.write(`
  26. <!DOCTYPE html>
  27. <html>
  28. <head>
  29. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@5.6.0/github-markdown.min.css">
  30. <style>
  31. body {
  32. font-family: Arial, sans-serif;
  33. max-width: 70ch!important;
  34. margin: 0 auto!important;
  35. padding:4em 0;
  36. }
  37. img{
  38. height:auto!important;
  39. width:auto!important;
  40. aspect-ratio:auto!important;
  41.  
  42. }
  43. </style>
  44. </head>
  45. <body class="container markdown-body">
  46. <h1>${title}</h1>
  47. ${content}
  48. </body>
  49. </html>
  50. `);
  51.  
  52. // 关闭文档流,使新内容生效
  53. document.close();
  54. })();