您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
过滤首页推荐的所有的知乎专栏,和知乎视频
// ==UserScript== // @name 过滤知乎首页推荐(fuck-zhihu-homepage) // @namespace https://github.com/dyingsunlight/tampermonkey // @supportURL https://github.com/dyingsunlight/tampermonkey/issues // @homepage https://github.com/dyingsunlight/tampermonkey // @source https://github.com/dyingsunlight/tampermonkey/raw/master/scripts/fuck-zhihu-zhuanlan.js // @version 0.15 // @description 过滤首页推荐的所有的知乎专栏,和知乎视频 // @author Dogfish // @match https://www.zhihu.com/ // @match https://www.zhihu.com/hot // @match https://www.zhihu.com/follow // @grant none // ==/UserScript== (function() { 'use strict'; // // let matchedCount = 0 const styles = document.createElement('style') styles.innerHTML = `.hidden { display: none }; `; document.body.appendChild(styles); // // (new MutationObserver(mutations => mutations.forEach(blockExecutor))).observe(document, { childList: true, subtree: true, characterData: false, attributes: false }); const checkedMarkClass = 'zhuanlan-checked' function blockExecutor() { const elements = document.querySelectorAll(`a[href*="zhuanlan.zhihu.com"]:not(.${checkedMarkClass})`) for (let element of elements) { element.classList.add(checkedMarkClass) const cardElement = findParentElementUntilMeetClass(element, 'Card') if (!cardElement) { console.log('cardElement not found', cardElement, element) continue } console.log('Block Zhuan Lan Amount: ', ++matchedCount) cardElement.classList.add('hidden') } } // Utils function findParentElementUntilMeetClass(element, classes) { const classList = typeof classes === 'string' ? classes.split(' ') : classes if (!Array.isArray(classList)) { throw new Error('Classes Must be an array or string!') } let next = element while (next) { if (classList.some(val => next.classList.contains(val))) { return next } if (next.parentElement) { next = next.parentElement } else { return } } } })();