Guest User

ignore scruffy

a guest
Feb 13th, 2021
300
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name Worster's ModIgnore for RPGCodex
  3. // @version 1
  4. // @match https://rpgcodex.net/forums/*
  5. // @grant none
  6. // ==/UserScript==
  7.  
  8. // hide posts, threads, alerts, profile posts by ignored member (such as when they create a new thread)
  9. var hideAlert = document.createElement('style');
  10. hideAlert.type = 'text/css';
  11. hideAlert.innerHTML = 'li[data-author="Scruffy"] { display: none !important; }';
  12. document.getElementsByTagName('head')[0].appendChild(hideAlert);
  13.  
  14. // hide quotes by ignored member
  15. var hideQuote = document.createElement('style');
  16. hideQuote.type = 'text/css';
  17. hideQuote.innerHTML = 'div[data-author="Scruffy"] { display: none !important; }';
  18. document.getElementsByTagName('head')[0].appendChild(hideQuote);
  19.  
  20. // hide shoutbox messages by ignored member
  21. var hideShoutboxMessages = document.createElement('style');
  22. hideShoutboxMessages.type = 'text/css';
  23. hideShoutboxMessages.innerHTML = 'li[data-userid="9477"] { display: none !important; }';
  24. document.getElementsByTagNeme('head')[0].appendChild(hideShoutboxMessages);
  25.  
  26. // find "last post by" ignored member and replace their name with "Ignored Member"
  27. // find all "lastPostInfo", get first child, get first child, if html == "Scruffy" replace grandchild html with "Ignored Member"
  28. var lastPostInfoElems = document.getElementsByClassName("lastPostInfo");
  29. Array.from(lastPostInfoElems).forEach(elem => {
  30. let dt = elem.firstChild;
  31. if (dt.nodeName == "#text") {
  32. dt = dt.nextSibling;
  33. }
  34. if (dt.childElementCount > 0) {
  35. if (dt.firstChild.innerHTML === "Scruffy") {
  36. dt.removeChild(dt.firstChild);
  37. let newText = document.createElement("span");
  38. newText.textContent = "Ignored Member";
  39. dt.appendChild(newText);
  40. }
  41. }
  42. });
RAW Paste Data