ft mute words

Hide elements based on matching text in data-trackable-context-story-type attribute using visibility: hidden

目前為 2025-06-11 提交的版本,檢視 最新版本

// ==UserScript==
// @name         ft mute words
// @description  Hide elements based on matching text in data-trackable-context-story-type attribute using visibility: hidden
// @match        *://*.ft.com/*
// @version 0.0.1.20250611200443
// @namespace https://gf.qytechs.cn/users/1435046
// ==/UserScript==
 
(function() {
  'use strict';
 
  // List of words to check for (in lowercase)
  const forbiddenWords = ['trump']; // Replace with your own words
  const forbiddenSet = new Set(forbiddenWords.map(word => word.toLowerCase()));
 
  function hideMatchingElements() {
    document.querySelectorAll('[data-trackable-context-story-type]').forEach(element => {
      const text = element.textContent.trim().toLowerCase();
      for (const word of forbiddenSet) {
        if (text.includes(word)) {
          element.style.visibility = 'hidden';
          console.log('Hid element with matching whole word:', regex, '\nOriginal text:', text);
          break;
        }
      }
    });
  }
 
  // Run once when DOM is ready
  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', hideMatchingElements);
  } else {
    hideMatchingElements();
  }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址