From 0e9e91bf60d24ddc5da7652b0efea81dd5213a0d Mon Sep 17 00:00:00 2001 From: Dan Jones Date: Sat, 21 Sep 2024 09:41:01 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=96=20Reddit=20expando:=20auto=20make?= =?UTF-8?q?=20thumbs=20expandable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- old-reddit-expando.user.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/old-reddit-expando.user.js b/old-reddit-expando.user.js index c88ff39..1eea2a4 100644 --- a/old-reddit-expando.user.js +++ b/old-reddit-expando.user.js @@ -3,7 +3,7 @@ // @namespace danielrayjones // @description Allow removal of visited links on Amazon Giveaway Listing // @include https://old.reddit.com* -// @version 1.0.2 +// @version 1.0.3 // ==/UserScript== (function() { @@ -15,15 +15,17 @@ let para = document.createElement('p'); let exButton = document.createElement('button'); - exButton.innerText = 'Expand images'; + exButton.innerText = 'Expand'; exButton = para.appendChild(exButton); exButton.addEventListener('click', () => document.querySelectorAll('.expando-button.collapsed').forEach(e => e.click())); let deButton = document.createElement('button'); - deButton.innerText = 'Collapse images'; + deButton.innerText = 'Collapse'; deButton = para.appendChild(deButton); deButton.addEventListener('click', () => document.querySelectorAll('.expando-button.expanded').forEach(e => e.click())); + para = listing.insertBefore(para, listing.firstChild); + const proxyThumbClicks = function(evt) { let thing = evt.target; while (!thing.classList.contains('thing') && thing != document.body) { @@ -40,10 +42,5 @@ return false; }; - let icoButton = document.createElement('button'); - icoButton.innerText = 'Thumb expands'; - icoButton = para.appendChild(icoButton); - icoButton.addEventListener('click', () => listing.querySelectorAll('.thumbnail').forEach(e => e.addEventListener('click', proxyThumbClicks))); - - para = listing.insertBefore(para, listing.firstChild); + listing.querySelectorAll('.thumbnail').forEach(e => e.addEventListener('click', proxyThumbClicks)); })();