Advertisement
Guest User

DRACH_HIDER

a guest
Aug 8th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name     DRACH_HIDER
  3. // @version  1
  4. // @match https://2ch.hk/*
  5. // @match http://2ch.hk/*
  6. // @require  https://code.jquery.com/jquery-3.3.1.slim.min.js
  7. // ==/UserScript==
  8.  
  9. //!Posters you want to hide
  10. let ludiHoroshie = ['!!sW.cQVB3Lk'];
  11.  
  12.  
  13. //Hide the poster's posts
  14. let tripPosters = document.getElementsByClassName('postertrip');
  15.  
  16. for (let vsevishnii of tripPosters) {
  17.   if (ludiHoroshie.includes(vsevishnii.textContent) && vsevishnii.closest('.post-wrapper') !== null) {
  18.     vsevishnii.closest('.post-wrapper').style.display = 'none';
  19.   } else if (ludiHoroshie.includes(vsevishnii.textContent) && vsevishnii.closest('.oppost-wrapper') !== null) {
  20.     vsevishnii.closest('.thread').style.display = 'none';
  21.   }
  22. }
  23.  
  24. //Hide the poster's replies
  25. ////Remember hidden poster's post ids and posts he/she replied to
  26. let godnota = [];
  27. let prosvetlennie = [];
  28.  
  29. for (let vsevishnii of tripPosters) {
  30.   if (ludiHoroshie.includes(vsevishnii.textContent)) {
  31.     godnota.push($(vsevishnii).closest('.post.reply').data('num'));
  32.  
  33.     if ($(vsevishnii).parent().siblings('.post-message').children('.post-reply-link').length > 0) {
  34.       for (let reply of $(vsevishnii).parent().siblings('.post-message').children('.post-reply-link')) {
  35.             prosvetlennie.push($(reply).data('num'));
  36.         }
  37.     }
  38.   }
  39. }
  40.  
  41. ////Find posts the poster replied to and hide his/her replies
  42. ////!Copypasted sleep function (Required because for some reason replies don't load before this script is executed)
  43. function sleep(ms) {
  44.   return new Promise(resolve => setTimeout(resolve, ms));
  45. }
  46.  
  47. let posters = document.getElementsByClassName('post-wrapper');
  48.  
  49. async function demo() {
  50.   console.log('Taking a break...');
  51.   await sleep(2000);
  52.   console.log('Two second later');
  53.  
  54.   for (let zabludshii of posters) {
  55.     if (prosvetlennie.includes($(zabludshii).children('.post.reply').data('num'))) {
  56.       for (let reply of $(zabludshii).find('.ABU-refmap').find('.post-reply-link')) {
  57.         if (godnota.includes($(reply).data('num'))) {
  58.           reply.style.display = 'none';
  59.         }
  60.       }
  61.     }
  62.   }
  63. }
  64.  
  65. demo();
  66.  
  67. //Hide replies to the poster's posts
  68. for (let voproshayushii of posters) {
  69.   let molbi = $(voproshayushii).find('.post-message').children('.post-reply-link');
  70.   for (let molba of molbi) {
  71.     if (godnota.includes($(molba).data('num'))) {
  72.       $(molba).hide();
  73.     }
  74.   }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement