Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name DRACH_HIDER
- // @version 1.Rika1
- // @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 and remember their ids
- let posters = document.getElementsByClassName('post-wrapper');
- let tripPosters = document.getElementsByClassName('postertrip');
- let godnota = [];
- for (let vsevishnii of tripPosters) {
- if (ludiHoroshie.includes(vsevishnii.textContent)) {
- godnota.push($(vsevishnii).closest('.post.reply').data('num'));
- let post = vsevishnii.closest('.post-wrapper');
- if (post !== null) {
- post.style.display = 'none';
- }
- if (vsevishnii.closest('.oppost-wrapper') !== null) {
- vsevishnii.closest('.thread').style.display = 'none';
- }
- }
- }
- // Hide links to the poster's posts inside other posts bodies
- 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();
- }
- }
- }
- // !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));
- }
- // Find posts the poster replied to and hide links to his/her replies in "Ответы:" section
- (async function() {
- console.log('Taking a break...');
- await sleep(2000);
- console.log('Two second later');
- for (let zabludshii of posters) {
- let refmap = $(zabludshii).find('.ABU-refmap');
- let links_total = 0, links_hidden = 0;
- for (let reply of refmap.find('.post-reply-link')) {
- links_total += 1;
- if (godnota.includes($(reply).data('num'))) {
- reply.style.display = 'none';
- links_hidden += 1;
- }
- }
- // hide the whole "Ответы:" section if it became empty
- if (links_hidden == links_total) {
- refmap.hide();
- }
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement