Guest User

Untitled

a guest
Aug 29th, 2026
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         FOK!Rust
  3. // @namespace    https://forum.fok.nl/
  4. // @version      1.3.1
  5. // @description  Verbergt MikeyTT-reacties en quotes op FOK!.
  6. // @match        *://forum.fok.nl/*
  7. // @run-at       document-end
  8. // @noframes
  9. // @grant        none
  10. // ==/UserScript==
  11.  
  12. (function () {
  13.   "use strict";
  14.  
  15.   var BLOCKED_USER = "mikeytt";
  16.   var HIDDEN_ATTRIBUTE = "data-fok-rust-hidden";
  17.   var POST_SELECTOR = ".post[data-member], .post [data-member][data-postid]";
  18.   var observer = null;
  19.  
  20.   function normalizeUserName(value) {
  21.     return String(value || "").replace(/^\s+|\s+$/g, "").toLowerCase();
  22.   }
  23.  
  24.   function isBlockedName(value) {
  25.     return normalizeUserName(value) === BLOCKED_USER;
  26.   }
  27.  
  28.   function matchesSelector(element, selector) {
  29.     var matches = element.matches
  30.       || element.msMatchesSelector
  31.       || element.webkitMatchesSelector;
  32.  
  33.     return matches ? matches.call(element, selector) : false;
  34.   }
  35.  
  36.   function closestByClass(element, className) {
  37.     while (element && element.nodeType === 1) {
  38.       if ((" " + element.className + " ").indexOf(" " + className + " ") !== -1) {
  39.         return element;
  40.       }
  41.  
  42.       element = element.parentNode;
  43.     }
  44.  
  45.     return null;
  46.   }
  47.  
  48.   function getPostElement(element) {
  49.     if ((" " + element.className + " ").indexOf(" post ") !== -1) {
  50.       return element;
  51.     }
  52.  
  53.     return closestByClass(element, "post");
  54.   }
  55.  
  56.   function getMemberName(post) {
  57.     var nested = post.querySelector("[data-member][data-postid]");
  58.     return post.getAttribute("data-member")
  59.       || (nested ? nested.getAttribute("data-member") : "")
  60.       || "";
  61.   }
  62.  
  63.   function getPostContent(post) {
  64.     return post.querySelector(".postmain_right.contents");
  65.   }
  66.  
  67.   function getQuotedMemberNames(post) {
  68.     var content = getPostContent(post);
  69.     var quotedMembers = [];
  70.     var blockquotes;
  71.     var boldTexts;
  72.     var profileLinks;
  73.     var blockquoteIndex;
  74.     var boldIndex;
  75.     var linkIndex;
  76.     var boldText;
  77.     var match;
  78.  
  79.     if (!content) {
  80.       return quotedMembers;
  81.     }
  82.  
  83.     blockquotes = content.querySelectorAll("blockquote");
  84.  
  85.     for (blockquoteIndex = 0; blockquoteIndex < blockquotes.length; blockquoteIndex += 1) {
  86.       boldTexts = blockquotes[blockquoteIndex].querySelectorAll("b");
  87.  
  88.       for (boldIndex = 0; boldIndex < boldTexts.length; boldIndex += 1) {
  89.         boldText = boldTexts[boldIndex];
  90.         profileLinks = boldText.querySelectorAll('a[href*="/user/profile/"]');
  91.  
  92.         for (linkIndex = 0; linkIndex < profileLinks.length; linkIndex += 1) {
  93.           quotedMembers.push(profileLinks[linkIndex].textContent);
  94.         }
  95.  
  96.         match = boldText.textContent.match(/\bschreef\s+(.+?)\s+het volgende:/i);
  97.         if (match) {
  98.           quotedMembers.push(match[1]);
  99.         }
  100.       }
  101.     }
  102.  
  103.     return quotedMembers;
  104.   }
  105.  
  106.   function hasBlockedQuote(post) {
  107.     var quotedMembers = getQuotedMemberNames(post);
  108.     var i;
  109.  
  110.     for (i = 0; i < quotedMembers.length; i += 1) {
  111.       if (isBlockedName(quotedMembers[i])) {
  112.         return true;
  113.       }
  114.     }
  115.  
  116.     return false;
  117.   }
  118.  
  119.   function hideElement(element) {
  120.     element.setAttribute(HIDDEN_ATTRIBUTE, "true");
  121.     element.style.setProperty("display", "none", "important");
  122.   }
  123.  
  124.   function processPost(post) {
  125.     if (isBlockedName(getMemberName(post)) || hasBlockedQuote(post)) {
  126.       hideElement(post);
  127.     }
  128.   }
  129.  
  130.   function pushUnique(items, item) {
  131.     if (item && items.indexOf(item) === -1) {
  132.       items.push(item);
  133.     }
  134.   }
  135.  
  136.   function findPosts(root) {
  137.     var matches = [];
  138.     var elements;
  139.     var i;
  140.     var post;
  141.  
  142.     if (root && root.nodeType === 1 && matchesSelector(root, POST_SELECTOR)) {
  143.       pushUnique(matches, getPostElement(root));
  144.     }
  145.  
  146.     if (root && root.querySelectorAll) {
  147.       elements = root.querySelectorAll(POST_SELECTOR);
  148.  
  149.       for (i = 0; i < elements.length; i += 1) {
  150.         post = getPostElement(elements[i]);
  151.         pushUnique(matches, post);
  152.       }
  153.     }
  154.  
  155.     return matches;
  156.   }
  157.  
  158.   function applyBlockList(root) {
  159.     var posts = findPosts(root || document);
  160.     var i;
  161.  
  162.     for (i = 0; i < posts.length; i += 1) {
  163.       processPost(posts[i]);
  164.     }
  165.   }
  166.  
  167.   function startObserver() {
  168.     if (observer || typeof MutationObserver === "undefined") {
  169.       return;
  170.     }
  171.  
  172.     observer = new MutationObserver(function (mutations) {
  173.       var mutationIndex;
  174.       var nodeIndex;
  175.       var addedNodes;
  176.  
  177.       for (mutationIndex = 0; mutationIndex < mutations.length; mutationIndex += 1) {
  178.         addedNodes = mutations[mutationIndex].addedNodes;
  179.  
  180.         for (nodeIndex = 0; nodeIndex < addedNodes.length; nodeIndex += 1) {
  181.           applyBlockList(addedNodes[nodeIndex]);
  182.         }
  183.       }
  184.     });
  185.  
  186.     observer.observe(document.documentElement, {
  187.       childList: true,
  188.       subtree: true
  189.     });
  190.   }
  191.  
  192.   function init() {
  193.     if (!document.body) {
  194.       window.setTimeout(init, 50);
  195.       return;
  196.     }
  197.  
  198.     applyBlockList(document);
  199.     startObserver();
  200.   }
  201.  
  202.   try {
  203.     init();
  204.   } catch (error) {
  205.     console.error("FOK!Rust kon niet starten.", error);
  206.   }
  207. })();
Advertisement
Add Comment
Please, Sign In to add comment