Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name DRACH_HIDER
- // @version 2
- // @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'];
- ////!Callback wrapper is required by MutationObserver to hide auto-updated threads/posts/replies/links to posts
- var callback = function() {
- //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 = [];
- for (let vsevishnii of tripPosters) {
- if (ludiHoroshie.includes(vsevishnii.textContent)) {
- godnota.push($(vsevishnii).closest('.post.reply').data('num'));
- }
- }
- ////Find posts the poster replied to and hide his/her replies
- let posters = document.getElementsByClassName('post-wrapper');
- for (let zabludshii of posters) {
- for (let reply of $(zabludshii).find('.ABU-refmap').find('.post-reply-link')) {
- if (godnota.includes($(reply).data('num'))) {
- reply.style.display = 'none';
- }
- }
- }
- //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).contents().unwrap();
- }
- }
- }
- }
- callback();
- // Select the node that will be observed for mutations
- var targetNode = document.getElementById('posts-form');
- // Options for the observer (which mutations to observe)
- var config = { attributes: false, childList: true, subtree: true };
- // Create an observer instance linked to the callback function
- var observer = new MutationObserver(callback);
- // Start observing the target node for configured mutations
- observer.observe(targetNode, config);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement