NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Hide and Refresh on Reddit Homepage // @namespace https://tampermonkey.net/ // @version 0.1 // @description Hides next page button and adds "hide all and refresh" button // @author dzonc // @match https://www.reddit.com/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // Function to hide all posts (unchanged from previous script) const hideAll = function() { console.log('hiding'); const linkElements = document.querySelectorAll('.link'); for (const linkElement of linkElements) { const hideButton = linkElement.querySelector('form[action="/post/hide"] a[data-event-action="hide"]'); if (hideButton) { hideButton.click(); } } }; // Function to add "hide all and refresh" button const addButton = function() { const siteTable = document.querySelector('#siteTable'); if (siteTable) { console.log('found #siteTable'); // Create new button const hideAllButton = document.createElement('a'); hideAllButton.textContent = 'Hide All and Refresh'; hideAllButton.href = 'javascript:void(0)'; hideAllButton.style.background = 'rgb(125 0 0)'; hideAllButton.style.display = 'flex'; hideAllButton.style.justifyContent = 'center'; hideAllButton.style.width = '70%'; hideAllButton.style.padding = '1rem'; hideAllButton.style.fontSize = '1rem'; hideAllButton.style.color = 'white'; hideAllButton.style.margin = '1rem auto'; // Add event listener to refresh after hiding posts hideAllButton.addEventListener('click', function() { window.scrollTo(0, 0); hideAll(); setTimeout(function() { window.location.reload(); }, 50); // Reload after 50 milliseconds }); // Insert button immediately after #siteTable siteTable.insertAdjacentElement('afterend', hideAllButton); } }; // Run the addButton function when the page loads addButton(); })();