gnmdcsdn

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         gnmdcsdn
// @namespace    http://tampermonkey.net/
// @description  友好阅读 CSDN,你不干净,我帮你干净; 搭配 Dark Reader 体验更佳: https://chrome.google.com/webstore/detail/eimadpbcbfnmbkopoojfekhnkhdbieeh
// @author       You
// @match         *://*.csdn.net/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=csdn.com
// @grant        none
// @version 1.0.9
// @license MIT
// ==/UserScript==
(function () {
    "use strict";
    // 复制当前文章内容
    const title = document.querySelector('#articleContentId').innerHTML;
    const content = document.querySelector('#content_views').innerHTML;

    // 停止当前页面的所有加载
    window.stop();

    // 打开文档流
    document.open();

    // 写入新的 HTML 内容
    document.write(`
  <!DOCTYPE html>
  <html>
    <head>
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/github-markdown.min.css">
      <style>
        body {
          font-family: Arial, sans-serif;
          max-width: 70ch!important;
          margin: 0 auto!important;
          padding:4em 0;
        }
        img{
          height:auto!important;
          width:auto!important;
          aspect-ratio:auto!important;

        }
      </style>
    </head>
    <body class="container markdown-body">
    <h1>${title}</h1>
    ${content}
    </body>
  </html>
`);

    // 关闭文档流,使新内容生效
    document.close();
})();