// ==UserScript== // @name 即刻内容屏蔽器(稳定版) // @namespace http://tampermonkey.net/ // @version 2.0 // @description 屏蔽即刻网页版中指定关键字和社区的内容(防止反复出现) // @author You // @match https://web.okjike.com/* // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/554211/%E5%8D%B3%E5%88%BB%E5%86%85%E5%AE%B9%E5%B1%8F%E8%94%BD%E5%99%A8%EF%BC%88%E7%A8%B3%E5%AE%9A%E7%89%88%EF%BC%89.user.js // @updateURL https://update.greasyfork.icu/scripts/554211/%E5%8D%B3%E5%88%BB%E5%86%85%E5%AE%B9%E5%B1%8F%E8%94%BD%E5%99%A8%EF%BC%88%E7%A8%B3%E5%AE%9A%E7%89%88%EF%BC%89.meta.js // ==/UserScript== (function () { 'use strict'; const DEFAULT_CONFIG = { keywords: ['吃播'], communities: ['喵星人的日常'], enabled: true }; function getConfig() { const saved = GM_getValue('jike_blocker_config_v2'); return saved ? JSON.parse(saved) : DEFAULT_CONFIG; } function saveConfig(config) { GM_setValue('jike_blocker_config_v2', JSON.stringify(config)); } function shouldBlock(postElement) { const config = getConfig(); if (!config.enabled) return false; const contentEl = postElement.querySelector('[class*="jk-"][class*="-mipk4t"]'); if (contentEl) { const text = contentEl.textContent.toLowerCase(); for (const keyword of config.keywords) { if (text.includes(keyword.toLowerCase())) return true; } } const communityEl = postElement.querySelector('[class*="jk-"][class*="-qcm5xu"]'); if (communityEl) { const name = communityEl.textContent.trim(); if (config.communities.includes(name)) return true; } return false; } function hidePost(el) { el.style.display = 'none'; el.setAttribute('data-jike-blocked', '1'); } function processAllPosts() { const posts = document.querySelectorAll('[data-clickable-feedback="true"]'); posts.forEach(post => { if (!post.hasAttribute('data-jike-blocked') && shouldBlock(post)) { hidePost(post); } }); } function startObserver() { const observer = new MutationObserver(() => { processAllPosts(); }); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); } function startPeriodicCheck() { setInterval(() => { processAllPosts(); }, 1000); // 每秒检查一次,防止 React 把 display 改回来 } function createSettingsPanel() { const config = getConfig(); const panel = document.createElement('div'); panel.innerHTML = `