csdn纯净版

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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);
})();