Created
February 28, 2019 17:51
-
-
Save rf5860/9d97e17ff479174088c4ac99a1acad41 to your computer and use it in GitHub Desktop.
RES Image Auto Expand UserScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name RES Image Auto Expand | |
// @author rjf89 | |
// @namespace RESImageAutoExpand | |
// @description Automatically expands images in Reddit when using the RES plugin. | |
// @include https://reddit.com/r/* | |
// @include https://*.reddit.com/r/* | |
// @version 1.0 | |
// ==/UserScript== | |
(function() { | |
"use strict"; | |
document.querySelectorAll('a.expando-button.toggleImage.image').forEach(m => m.click()) | |
new MutationObserver(ms => | |
ms | |
.flatMap(m => [...m.target.querySelectorAll('a.expando-button.toggleImage.image'), ...m.addedNodes, m.target]) | |
.filter(m => m.nodeType == 1) | |
.filter(m => m.classList && m.classList.contains('expando-button')) | |
.filter(m => m.classList && m.classList.contains('toggleImage')) | |
.filter(m => m.classList && m.classList.contains('image')) | |
.filter(m => m.classList && !m.classList.contains('video')) | |
.filter(m => m.classList && m.classList.contains('collapsed')) | |
.filter(m => m.classList && m.classList.contains('collapsedExpando')) | |
.forEach(m => m.click()) | |
).observe(document, { childList: true, subtree: true }); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment