简书纯净版

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

目前为 2021-08-26 提交的版本。查看 最新版本

// ==UserScript==
// @name         简书纯净版
// @description  简书纯净版-只保留文字与评论
// @version      0.1
// @author       tomiaa
// @match      *://www.jianshu.com/*
// @namespace    http://tampermonkey.net/


// ==/UserScript==
; (() => {
  const $ = id => document.querySelector(id);
  console.clear();
  const config = {
    'default': {
      remove: [
        /* 头部 */
        '._1nZg8v',
        '._1F7CTF',
        '._1jKNin',
        '._1OyPqC',
        /* 左侧 */
        '._3Pnjry',

        '._2OwGUo', // 右侧
        /* 底部 */
        '._13lIbp',
        '.d0hShY',

      ],
      css: `
      ._gp-ck > section:nth-of-type(n+2){
        display: none;
      }
      ._1Jdfvb{
        margin-right: unset;
      }
      
      `
    }
  }
  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);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址