Created
June 29, 2023 11:17
-
-
Save bee1850/7cc3a55fbb635c092cf825faa6b3e481 to your computer and use it in GitHub Desktop.
Tampermonkey - Automatically opens spoilers on DoomWorld forum threads
This file contains 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 DoomWorld Instant DeSpoiler | |
// @namespace https://www.doomworld.com/ | |
// @version 1.0 | |
// @description Automatically opens spoilers on DoomWorld forum threads | |
// @author @uaf on discord | |
// @match https://www.doomworld.com/forum/topic/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Function to find and click spoilers | |
function clickSpoilers() { | |
var spoilers = document.querySelectorAll('.ipsSpoiler_header.ipsSpoiler_closed'); | |
spoilers.forEach(function(spoiler) { | |
spoiler.click(); | |
}); | |
} | |
// Execute the function on page load | |
window.addEventListener('load', function() { | |
clickSpoilers(); | |
}); | |
// Execute the function when new content is loaded (e.g., infinite scroll) | |
var observer = new MutationObserver(function(mutationsList) { | |
for (var mutation of mutationsList) { | |
if (mutation.type === 'childList') { | |
clickSpoilers(); | |
} | |
} | |
}); | |
observer.observe(document.body, { childList: true, subtree: true }); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment