Greasy Fork

Greasy Fork is available in English.

知乎去广告、视频

a script to remove ads in www.zhihu.com

当前为 2020-12-25 提交的版本,查看 最新版本

// ==UserScript==
// @name           知乎去广告、视频
// @namespace   http://tampermonkey.net/
// @version         0.1
// @description   a script to remove ads in www.zhihu.com
// @author          CoderBen
// @match          https://www.zhihu.com/*
// @grant           none
// @icon            https://tse2-mm.cn.bing.net/th/id/OIP.7D-LqgunUUDXVESZYas8GAHaHa?pid=Api&rs=1
// ==/UserScript==

(function() {
    'use strict';

    removeAd()

    window.onscroll = function() {
        removeAd()
    }

    function removeAd () {
        document.querySelectorAll('.Pc-feedAd-container').forEach(function(elem) {
            elem.style.display = 'none'
        })

        document.querySelectorAll('[data-za-extra-module]').forEach(function(elem) {
           if (elem.dataset.zaExtraModule.indexOf('has_video":true') > -1) {
               elem.style.display = 'none'
               elem.parentNode.style.height = '0'
               elem.parentNode.style.border = 'none'
           }
        })
    }
})();