Greasy Fork

来自缓存

Greasy Fork is available in English.

屏蔽知乎热门内容推荐

屏蔽知乎feed流的热门推荐

当前为 2018-04-18 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         屏蔽知乎热门内容推荐
// @namespace    http://tampermonkey.net/
// @version      0.13
// @description  屏蔽知乎feed流的热门推荐
// @author       Yidadaa
// @match        https://www.zhihu.com/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    let lastItemCount = 0;
    const selectItems = () => document.querySelectorAll('.TopstoryItem');
    const container = document.querySelector('.Topstory-mainColumn');
    const doRemove = () => {
        const newItems = selectItems();
        if (newItems.length !== lastItemCount) {
            Array.from(newItems)
                .filter(v => v.innerText.indexOf('热门内容') > -1)
                .forEach(v => v.style.display='none');
            lastItemCount = newItems.length;
        }
        const containerHeight = container.getBoundingClientRect().height;
        const windowHeight = window.innerHeight;
        if (containerHeight < windowHeight) {
            container.style.marginBottom = `${windowHeight - containerHeight + 100}px`;// 防止页面无法滚动,导致无法触发知乎刷新
        }
    };
    const oldListener = window.onscroll;
    window.onscroll = () => {
        if (!!oldListener) oldListener();
        doRemove();
    };
    const oldOnload = window.onload;
    window.onload = () => {
        if (!!oldOnload) oldOnload();
        doRemove();
    };
})();