Block/Hide Words

Block/hide specified words from appearing on webpages

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

You will need to install an extension such as Tampermonkey to install this script.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name           Block/Hide Words
// @namespace      https://github.com/AbdurazaaqMohammed
// @version        1.0
// @author         Abdurazaaq Mohammed
// @description    Block/hide specified words from appearing on webpages
// @match          https://*.*/*
// @match          http://*.*/*
// @homepage       https://github.com/AbdurazaaqMohammed/userscripts
// @license        The Unlicense
// @supportURL     https://github.com/AbdurazaaqMohammed/userscripts/issues
// @grant          none
// @run-at         document-start
// ==/UserScript==
(function() {
  'use strict';

  // List of words to be blocked
  const blockedWords = ["word1", "word2", "word3"]; // You can add as many words as you want. Just ensure they are inside quotes ("") and separateed by commas (,).

  function replaceBlockedWords(node) {
    if (node.nodeType === Node.TEXT_NODE) {
      let text = node.nodeValue;
      blockedWords.forEach(word => { text = text.replaceAll(word, ''); });
       // You can type anything you want the words to be replaced with inside the quote.
       // If you want to replace different sets of words with different words just create another list (copy and paste the const blockedWords line) and copy and paste the blockedWords.forEach line below the existing one in this function replacing both blockedWords with whatever name you want.
      node.nodeValue = text;
    } else {
      node.childNodes.forEach(replaceBlockedWords);
    }
  }


  const observer = new MutationObserver(mutations => {
    mutations.forEach(mutation => {
      mutation.addedNodes.forEach(node => replaceBlockedWords(node));
    });
  });

  const intervalId = setInterval(function() { // make sure it loads, when you do document-start sometimes it doesn't load
    if(document.body.childNodes) {
      document.body.childNodes.forEach(replaceBlockedWords);
      observer.observe(document.body, { childList: true, subtree: true });
      clearInterval(intervalId);
    }
  }, 100);
})();