Advertisement
Guest User

Untitled

a guest
Mar 29th, 2023
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        4chan vtuber fan mark adder
  3. // @match       https://boards.4channel.org/*
  4. // ==/UserScript==
  5. (function() {
  6.  
  7.     const replacements = [
  8.         { regex: /\bpomu\b/ig, value: '🧚🍂$&' },
  9.         { regex: /\b(ewiwa|elira)\b/ig, value: '🌤️$&' },
  10.         { regex: /\b(finana|feesh)\b/ig, value: '🐠$&' },
  11.     ];
  12.  
  13.  
  14.     function handleChildNodes(e) {
  15.         for (const n of e.childNodes) {
  16.             if (n.nodeType === 3) {
  17.                 for (const r of replacements) {
  18.                     n.nodeValue = n.nodeValue.replace(r.regex, r.value);
  19.                 }
  20.             } else if (n.nodeType === 1) {
  21.                 handleChildNodes(n)
  22.             }
  23.         }
  24.     }
  25.  
  26.     function addEmoji() {
  27.         for (const e of document.querySelectorAll(".postMessage")) {
  28.             if (e.modded != true) {
  29.                 e.modded = true;
  30.                 handleChildNodes(e);
  31.             }
  32.         }
  33.     }
  34.  
  35.     // identify an element to observe
  36.     const target = document.querySelector(".thread");
  37.  
  38.     // create a new instance of `MutationObserver` named `observer`,
  39.     // passing it a callback function
  40.     const observer = new MutationObserver(() => {
  41.         addEmoji();
  42.     });
  43.  
  44.     observer.observe(target, {
  45.         subtree: true,
  46.         childList: true
  47.     });
  48.  
  49.     addEmoji();
  50.  
  51. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement