Advertisement
Guest User

HC Cleanup Script

a guest
Jul 23rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name     HC Cleanup
  3. // @version  1.0
  4. // @grant    none
  5. // @include https://alpha.human-conncetion.org/
  6. // ==/UserScript==
  7.  
  8. window.onload = function () {
  9.   var dudesToHide = [
  10.     "Lothar J. Finger",
  11.     "John Doe",
  12.     "Wer auch immer",
  13.     "" // Last entry without comma!
  14.   ];
  15.  
  16.   var containerNode = document.getElementById('main').querySelector('.cards');
  17.   var mutationObserver = new MutationObserver(function (mutations) {
  18.  
  19.     var cardsToCheck = containerNode.getElementsByClassName('card');
  20.  
  21.     for (var i = 0; i < cardsToCheck.length; i++) {
  22.       var item = cardsToCheck.item(i);
  23.       var header = item.getElementsByClassName('hc__author');
  24.       var authorCollection = header.item(0).getElementsByClassName('title');
  25.       var authorName = authorCollection.item(0).innerText
  26.  
  27.       // check whether author name is among the dudes
  28.       if (dudesToHide.includes(authorName)) {
  29.         item.parentNode.removeChild(item);
  30.         console.log('(⌐■_■) Removed post from: ' + authorName + ' ¯\_(ツ)_/¯');
  31.       }
  32.     }
  33.   });
  34.  
  35.   // Starts listening for changes in the content conatainer of the page.
  36.   mutationObserver.observe(containerNode, {
  37.     attributes: false,
  38.     characterData: false,
  39.     childList: true,
  40.     subtree: true,
  41.     attributeOldValue: false,
  42.     characterDataOldValue: false
  43.   });
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement