Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name DRACH_HIDER
- // @version 1
- // @match https://2ch.hk/*
- // @match http://2ch.hk/*
- // @require https://code.jquery.com/jquery-3.3.1.slim.min.js
- // ==/UserScript==
- //!Posters you want to hide
- let ludiHoroshie = ['!!sW.cQVB3Lk'];
- //Hide the poster's posts
- let tripPosters = document.getElementsByClassName('postertrip');
- for (let vsevishnii of tripPosters) {
- if (ludiHoroshie.includes(vsevishnii.textContent) && vsevishnii.closest('.post-wrapper') !== null) {
- vsevishnii.closest('.post-wrapper').style.display = 'none';
- } else if (ludiHoroshie.includes(vsevishnii.textContent) && vsevishnii.closest('.oppost-wrapper') !== null) {
- vsevishnii.closest('.thread').style.display = 'none';
- }
- }
- //Hide the poster's replies
- ////Remember hidden poster's post ids and posts he/she replied to
- let godnota = [];
- let prosvetlennie = [];
- for (let vsevishnii of tripPosters) {
- if (ludiHoroshie.includes(vsevishnii.textContent)) {
- godnota.push($(vsevishnii).closest('.post.reply').data('num'));
- if ($(vsevishnii).parent().siblings('.post-message').children('.post-reply-link').length > 0) {
- for (let reply of $(vsevishnii).parent().siblings('.post-message').children('.post-reply-link')) {
- prosvetlennie.push($(reply).data('num'));
- }
- }
- }
- }
- ////Find posts the poster replied to and hide his/her replies
- ////!Copypasted sleep function (Required because for some reason replies don't load before this script is executed)
- function sleep(ms) {
- return new Promise(resolve => setTimeout(resolve, ms));
- }
- let posters = document.getElementsByClassName('post-wrapper');
- async function demo() {
- console.log('Taking a break...');
- await sleep(2000);
- console.log('Two second later');
- for (let zabludshii of posters) {
- if (prosvetlennie.includes($(zabludshii).children('.post.reply').data('num'))) {
- for (let reply of $(zabludshii).find('.ABU-refmap').find('.post-reply-link')) {
- if (godnota.includes($(reply).data('num'))) {
- reply.style.display = 'none';
- }
- }
- }
- }
- }
- demo();
- //Hide replies to the poster's posts
- for (let voproshayushii of posters) {
- let molbi = $(voproshayushii).find('.post-message').children('.post-reply-link');
- for (let molba of molbi) {
- if (godnota.includes($(molba).data('num'))) {
- $(molba).hide();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement