Skip to content

Instantly share code, notes, and snippets.

@bee1850
Created June 29, 2023 11:17
Show Gist options
  • Save bee1850/7cc3a55fbb635c092cf825faa6b3e481 to your computer and use it in GitHub Desktop.
Save bee1850/7cc3a55fbb635c092cf825faa6b3e481 to your computer and use it in GitHub Desktop.
Tampermonkey - Automatically opens spoilers on DoomWorld forum threads
// ==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