// ==UserScript== // @name RPS Comment Auto-Expander // @namespace Violentmonkey Scripts // @match https://www.rockpapershotgun.com/* // @grant none // @version 1 // @author AshEnke // @license MIT // @description Auto-expands truncated comments on Rock Paper Shotgun, and optionally auto expand replies as well // @downloadURL none // ==/UserScript== (function() { 'use strict'; const CONFIG = { DEBUG: false, // Enable debug logging EXPAND_REPLIES: true // Enable auto-expanding of reply threads }; const log = CONFIG.DEBUG ? (...args) => console.log('[RPS Comment Expander]', ...args) : () => {}; function expandContent(shadowRoot) { // Expand main comments const seeMoreSpans = Array.from(shadowRoot.querySelectorAll('span')) .filter(span => span.textContent.trim() === 'See more'); seeMoreSpans.forEach(span => { log('Expanding comment'); span.click(); }); // Expand replies if enabled if (CONFIG.EXPAND_REPLIES) { const replyButtons = Array.from(shadowRoot.querySelectorAll('span')) .filter(span => span.className.startsWith('Button__contentWrapper') && (span.textContent.includes('reply') || span.textContent.includes('replies')) ); replyButtons.forEach(button => { log('Expanding replies'); button.click(); }); return seeMoreSpans.length > 0 || replyButtons.length > 0; } return seeMoreSpans.length > 0; } function initialize() { const owComponent = document.querySelector('#comments > div > *'); if (!owComponent || !owComponent.shadowRoot) { setTimeout(initialize, 1000); return; } log('Found OpenWeb component'); // Initial expansion expandContent(owComponent.shadowRoot); // Watch for new comments and replies new MutationObserver(() => expandContent(owComponent.shadowRoot)) .observe(owComponent.shadowRoot, { childList: true, subtree: true }); } // Start looking for comments when the page is ready if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', initialize); } else { initialize(); } })();