Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Hide Old Reddit Frontpage Old Posts
- // @namespace https://greasyfork.org/en/users/85671-jcunews
- // @version 1.0.3
- // @license AGPLv3
- // @author jcunews
- // @description https://www.reddit.com/r/GreaseMonkey/comments/l5i3mw/request_script_that_removes_hides_stale_reddit/
- // @match https://*.reddit.com/
- // @match https://*.reddit.com/?*
- // @match https://*.reddit.com/hot/*
- // @match https://*.reddit.com/new/*
- // @match https://*.reddit.com/rising/*
- // @match https://*.reddit.com/controversial/*
- // @match https://*.reddit.com/top/*
- // @match https://*.reddit.com/gilded/*
- // @grant none
- // ==/UserScript==
- ((ele, link) => {
- var maxAgeHours = 20;
- var maxUpVotes = 100;
- var maxComments = 50;
- if (!(ele = document.querySelector(".tabmenu"))) return;
- ele.appendChild(link = document.createElement("A")).textContent = "[Hide Olds]";
- link.style.marginLeft = "1em";
- link.href = "#";
- link.onclick = () => {
- var now = new Date;
- Array.from(document.querySelectorAll(".sitetable .thing")).forEach(
- (post, index) => {
- var
- posttime = new Date(parseInt(post.dataset.timestamp)),
- eleVotes = post.querySelector(".score.unvoted"),
- comments = post.dataset.commentsCount,
- eleHide = post.querySelector(".hide-button a");
- if (isNaN(posttime) || !eleVotes || !comments || !eleHide) return;
- if (
- ((now - posttime) > maxAgeHours * 60*60*1000) ||
- (parseInt(eleVotes.title) > maxUpVotes) ||
- (parseInt(comments) > maxComments)
- ) eleHide.click()
- }
- );
- return false
- }
- })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement