去 知乎 Advertisement EBook LiveItem

广告 电子书相关 包含价格相关 信息屏蔽

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         去 知乎 Advertisement EBook LiveItem
// @namespace    http://tampermonkey.net/
// @version      1.3.6
// @description  广告 电子书相关 包含价格相关  信息屏蔽
// @author       jackdizhu
// @match        *://www.zhihu.com/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
  'use strict';
  var time = null;
  var addEventListener = document.body.addEventListener
  // 清除相关信息

  function remove (el) {
    if (el) {
      if (el.style.visibility === 'hidden') {
        return false
      }
      el.style = `
      position: absolute;
      z-index: -100;
      visibility: hidden;
      `
      document.body.appendChild(el)
    }
  }

  function setHtmlStyle () {
    let $html = document.documentElement
    if ($html.style.overflow === 'hidden') {
      document.documentElement.style = `
      margin: 0;
      `
    }
    window.requestAnimationFrame(setHtmlStyle);
  }
  window.requestAnimationFrame(setHtmlStyle);
  
  let classArr = [
    '.Popover.TopstoryItem-rightButton',
    '.EBookItem',
    '.LiveItem',
    '.Pc-feedAd-container',
    '.Modal-wrapper',
    '.Pc-word-card'
  ]
  function removeAll (str) {
    var el1 = document.querySelectorAll(str);
    for (let i = 0; i < el1.length; i++) {
      const item = el1[i];
      remove(item.parentNode);
    }
  }
  var init = () => {
    for (let i = 0; i < classArr.length; i++) {
      const str = classArr[i];
      removeAll(str);
    }
  }
  var fn = function () {
      window.requestAnimationFrame(init)
  }

  addEventListener("scroll", fn, false);
  // addEventListener('click', fn, false);
})();