skynin

DOU user blocker

Jan 9th, 2021 (edited)
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name     DOU user blocker
  3. // @version  5
  4. // @grant    none
  5. // ==/UserScript==
  6.  
  7. // DEBUG console.log('init DOUblocker');
  8.  
  9. function DOUblocker() {
  10.  
  11. // DEBUG console.log('run DOUblocker');
  12.  
  13. // Example .../users/userone/ .../users/second-user/
  14.     var blockedUsers = ['userone', 'second-user'];
  15.  
  16.     for (let bUser of blockedUsers) {
  17.         blockIt(bUser);
  18.     }
  19.  
  20.     function blockIt(bUser) {
  21.         for (let oneComment of document.querySelectorAll(`.b-comment .b-post-author a.avatar[href*='${bUser}']`)) {
  22.             let parentElem = oneComment.parentElement;
  23.             let maxParent = 5;
  24.  
  25.             while (parentElem && maxParent) {
  26.                 if (parentElem.className.match('b-comment')) {
  27.                     parentElem.style.display = "none"; // or parentElem.innerHTML = bUser;
  28.                   // DEBUG console.log(`block ${bUser}`);
  29.                     break;
  30.                 }
  31.  
  32.                 parentElem = parentElem.parentElement;
  33.                 --maxParent;
  34.             }
  35.         }
  36.     }
  37. }
  38. // document.addEventListener("DOMContentLoaded", DOUblocker);
  39. DOUblocker();
Add Comment
Please, Sign In to add comment