deactivist / Deactivist

// ==UserScript==
// @name         Deactivist
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Free yourself from virtue signalling, attention seekers and stuff you just don't want to hear about.
// @author       The Deactivist Group
// @match       *://*/*
// @license    MIT
// ==/UserScript==

(function deactivist() {
  'use strict';

  let timer = 0;

  function htmlToElement(html) {
      var template = document.createElement('template');
      html = html.trim(); // Never return a text node of whitespace as the result
      template.innerHTML = html;
      return template.content.firstChild;
  }

  const WORDS = [
      "lgbt",
      "margot",
      "stop bzdurom",
      "tęczow",
      "transpłcio",
      "tolerancj",
      "queer",
      "oko.press",
      "racist",
    "homophob",
    "homofob",
    "rasist",
    "krytykapolityczna",
    "woke",
    "activist",
    "climate change",
    "diversity",
    "acab",
    "blm",
    "black lives matter",
    "genderfluid"
  ];



  function deactivize() {
    for (const word of WORDS) {
        const xpath = `//*[text()[contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'),'${word}')]]`;
        const matchingElements = document.evaluate(xpath, document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
        let arr = [];
        let node;
        while(node = matchingElements.iterateNext()) {
            arr.push(node);
        }
        for (const elem of arr) {
            console.log(elem);
            elem.parentNode.replaceChild(htmlToElement("<img src='https://www.kindpng.com/picc/b/205/2050115.png' height='32px' />"), elem);
           // elem.remove();
        }
    }
  }

  document.addEventListener('DOMNodeInserted', () => {
    timer && clearTimeout(timer);
    timer = setTimeout(deactivize, 500);
  });
})();