Greasy Fork

Greasy Fork is available in English.

知乎-我不感兴趣

隐藏掉你可能感兴趣及热门内容推荐

当前为 2018-02-06 提交的版本,查看 最新版本

// ==UserScript==
// @name         知乎-我不感兴趣
// @namespace
// @version      1.2.2
// @description  隐藏掉你可能感兴趣及热门内容推荐
// @author       MQ
// @match        https://www.zhihu.com/
// @grant        none
// @namespace http://greasyfork.icu/users/159603
// ==/UserScript==

(function() {
    'use strict';

    const mainFrame = document.querySelector(".TopstoryMain");

    var ob = new MutationObserver(function () {
        //console.log("change triggered");
        document.querySelectorAll(".Card.TopstoryItem").forEach(e => {
            try{
                let feature = e.querySelector(".FeedSource-firstline");
                if (feature.textContent.match(/你可能感兴趣|热门内容/)) {
                    e.hidden = true;
                    //[...e.children].forEach(inner => inner.hidden = true);
                    console.log(feature.textContent, "hide");
                }
            }catch(x){
                console.log(x, e);
            }
        });
    });

    var config = { attributes: true, childList: true };

    ob.observe(mainFrame, config);

    console.log("hooked");
}());