屏蔽知乎首页的所有推荐内容和热搜栏的火狐插件

KW6VUOPXGPXGSHC4PIUZMZ4QJZBQ3ICGAPYNED2XICVLYZQ37WOQC

Dependencies

Change contents

message = 'init'
timestamp = '2026-02-06T18:24:17.167041907Z'
[[authors]]
key = '51vRw7nuTkQZMxpJ8CtV1bmLNFyPngpPee8WQt1bZnJM'
# Dependencies
[2] SFLWNKAGBKTECFFYTKBIHJSMTBSCJR5GZG23437PV6SX2IO4QAXQC #
# Hunks
1. File addition: "style.css" in "" "UTF-8"
up 2.1, new 0:33
+
/* 知乎推荐内容屏蔽样式 */
+
+
/* 隐藏推荐标签页的内容区域 */
+
.Topstory-recommend {
+
display: none !important;
+
}
+
+
/* 隐藏推荐标签本身(可选,如果你想完全移除推荐标签) */
+
.TopstoryTabs-link[href="/"] {
+
display: none !important;
+
}
+
+
/* 隐藏带有推荐标记的卡片 */
+
[data-za-detail-view-path-module="TopstoryRecommend"] {
+
display: none !important;
+
}
+
+
/* 隐藏首页推荐的热门内容 */
+
.Topstory-hot {
+
display: none !important;
+
}
+
+
/* 隐藏推荐广告 */
+
.Pc-card,
+
.Pc-feedAd,
+
.Pc-feedAd-container {
+
display: none !important;
+
}
+
+
/* 隐藏右侧栏的推荐内容 */
+
.Topstory-mainColumnCard .Card:has(.HotList) {
+
display: none !important;
+
}
+
+
/* 隐藏知乎盐选推荐 */
+
.KfeCollection-PcColle498 {
+
display: none !important;
+
}
+
+
/* 隐藏视频推荐 */
+
.Topstory-videoRecommend {
+
display: none !important;
+
}
+
+
/* 隐藏右侧"大家都在搜" */
+
.HotSearchCard {
+
display: none !important;
+
}
+
+
/* 隐藏右侧"推荐关注" */
+
.Card:has(.ZDI--UserPlusFill24) {
+
display: none !important;
+
}
2. File addition: "manifest.json" in "" "UTF-8"
up 2.1, new 1098:1135
+
{
+
"manifest_version": 2,
+
"name": "知乎推荐屏蔽器",
+
"version": "1.0.0",
+
"description": "屏蔽知乎首页的所有推荐内容,让你专注于关注的内容",
+
"browser_specific_settings": {
+
"gecko": {
+
"id": "zhihu-blocker@dzming.li",
+
"data_collection_permissions": {
+
"required": ["none"]
+
}
+
}
+
},
+
"permissions": [
+
"activeTab"
+
],
+
"content_scripts": [
+
{
+
"matches": ["*://www.zhihu.com/*"],
+
"js": ["content.js"],
+
"css": ["style.css"],
+
"run_at": "document_start"
+
}
+
]
+
}
3. File addition: "content.js" in "" "UTF-8"
up 2.1, new 1701:1735
+
// 知乎推荐内容屏蔽器
+
(function() {
+
'use strict';
+
+
// 屏蔽推荐 feed 中的内容
+
function blockRecommendations() {
+
// 检查是否在首页
+
if (!window.location.pathname.match(/^\/?$|^\/follow$/)) {
+
return;
+
}
+
+
// 获取当前激活的标签
+
const activeTab = document.querySelector('.Topstory-tabs .TopstoryTabs-link.is-active');
+
+
// 如果当前是"推荐"标签,隐藏所有内容
+
if (activeTab && activeTab.textContent.includes('推荐')) {
+
hideRecommendFeed();
+
}
+
+
// 隐藏推荐标签下的所有卡片中带有"推荐"标记的内容
+
hideRecommendedCards();
+
}
+
+
// 隐藏推荐 feed
+
function hideRecommendFeed() {
+
const feedList = document.querySelector('.Topstory-recommend .TopstoryMain');
+
if (feedList) {
+
feedList.style.display = 'none';
+
}
+
}
+
+
// 隐藏带有推荐标记的卡片
+
function hideRecommendedCards() {
+
// 隐藏首页推荐的内容项
+
const cards = document.querySelectorAll('.Card.TopstoryItem');
+
cards.forEach(card => {
+
// 检查是否有"推荐"来源标记
+
const sourceTag = card.querySelector('.FeedSource');
+
if (sourceTag && sourceTag.textContent.includes('推荐')) {
+
card.style.display = 'none';
+
}
+
});
+
+
// 隐藏整个推荐 feed 区域
+
const recommendSection = document.querySelector('[data-za-detail-view-path-module="TopstoryRecommend"]');
+
if (recommendSection) {
+
recommendSection.style.display = 'none';
+
}
+
}
+
+
// 自动切换到"关注"标签
+
function switchToFollowTab() {
+
// 只在首页执行
+
if (!window.location.pathname.match(/^\/?$/)) {
+
return;
+
}
+
+
const followTab = document.querySelector('.Topstory-tabs .TopstoryTabs-link[href="/follow"]');
+
if (followTab && !followTab.classList.contains('is-active')) {
+
followTab.click();
+
}
+
}
+
+
// 使用 MutationObserver 监听 DOM 变化
+
function observeDOM() {
+
const observer = new MutationObserver((mutations) => {
+
blockRecommendations();
+
});
+
+
observer.observe(document.body, {
+
childList: true,
+
subtree: true
+
});
+
}
+
+
// 页面加载完成后执行
+
function init() {
+
// 先尝试切换到关注标签
+
switchToFollowTab();
+
+
// 屏蔽推荐内容
+
blockRecommendations();
+
+
// 监听 DOM 变化以处理动态加载的内容
+
observeDOM();
+
}
+
+
// 确保 DOM 加载完成
+
if (document.readyState === 'loading') {
+
document.addEventListener('DOMContentLoaded', init);
+
} else {
+
init();
+
}
+
+
// 同时也在 window.load 时再次执行,确保所有动态内容都被处理
+
window.addEventListener('load', () => {
+
setTimeout(init, 500);
+
});
+
})();