Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Hide Posts By Reply Count
- // @namespace http://tampermonkey.net/
- // @version 2024-01-03
- // @description Hide posts which have fewer than x replies
- // @author You
- // @match *.4chan.org/*/thread/*
- // @match *://4chan.org/*/thread/*
- // @match *.4channel.org/*/thread/*
- // @match *://4channel.org/*/thread/*
- // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // Your code here...
- let hideToggle = false;
- const style = document.createElement('style');
- document.addEventListener("keypress", (e) => {
- if (e.key == "h" && document.activeElement.tagName != "TEXTAREA") {
- if (!hideToggle) {
- let minReplyCount = prompt("Min reply count", "0");
- if (!isNaN(minReplyCount) && minReplyCount > 0) {
- hideToggle = true;
- document.head.appendChild(style);
- style.type = 'text/css';
- style.appendChild(document.createTextNode(".dialog > * {display: block !important;} .inline > * {display: block !important;}"));
- [].slice.call(document.getElementsByClassName('container')).forEach(el => {
- if (el.childElementCount < minReplyCount && el.parentElement.parentElement.parentElement.parentElement.className != "dialog")
- el.parentElement.parentElement.parentElement.style.display = "none";
- });
- } else {
- console.log("invalid value");
- }
- } else {
- hideToggle = false;
- style.remove();
- const minReplyCount = 2;
- [].slice.call(document.getElementsByClassName('container')).forEach(el => {
- el.parentElement.parentElement.parentElement.style.display = "";
- });
- }
- }
- });
- })();
Add Comment
Please, Sign In to add comment