csdn纯净版

csdn纯净版-只保留文字与评论

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         csdn纯净版
// @description  csdn纯净版-只保留文字与评论
// @version      0.3
// @author       tomiaa
// @match      *://blog.csdn.net/*
// @namespace    http://tampermonkey.net/


// ==/UserScript==
; (() => {
  const $ = id => document.querySelector(id);
  console.clear();
  const config = {
    'default': {
      remove: [
        /* 左侧 */
        '#asideSearchArticle',
        '#asideHotArticle',
        '#asideCategory',
        '#asideNewNps',
        '#asideArchive',
        '.aside-box-footer',
        '#asideNewComments',

        '.blog-tags-box',
        '.article-type-img',
        '.c-gray',
        '#blogColumnPayAdvert',
        '#health-companies',
        '.tool-QRcode',
        '.toolbar-advert',



        /* 右侧 */
        '#asideArchive',
        '.csdn-side-toolbar',


        '#copyright-box', // 底部
        '.recommend-box', // 推荐文章
        '.recommend-tit-mod',
        '.template-box',

        '.comment-sofa-flag',
        

        '#footerRightAds',


      ],
      css: `
      .more-toolbox-active .left-toolbox{
        transform: translateX(-34.4%) !important;
        left: 50% !important;
      }
      body{
        background: #f6f0da !important;
      }
      `,
    }
  }
  class Clear {

    constructor(config) {
      this.config = config;
      this.domain = '';
      this.query = null;
      this.init();
    }

    init() {
      // const currentHref = location.href.split('?');
      // this.domain = currentHref[0];
      this.domain = 'default'
      // this.query = currentHref[1];
      console.log(this.domain);

      this.removeToHidden(this.config?.[this.domain]?.remove);
      this.addCss(this.config?.[this.domain]?.css);
      this.remove(this.config?.[this.domain]?.remove);
      this.config?.[this.domain]?.fn?.();

    }

    remove(arr = []) {
      arr.map(item => $(item)).forEach(item => {
        item?.remove();
      })
    }

    removeToHidden(arr = []) {
      if (!arr.length) return;
      this.addCss(arr.join(',') + `{    
        display: none !important;
      }`)
    }

    addCss(css = '') {
      if (!css) return;
      let style = document.createElement('style')
      style.innerHTML = css;
      document.documentElement.appendChild(style);
    }

  }
  new Clear(config);
})();