Skip to content

Instantly share code, notes, and snippets.

@rf5860
Last active May 23, 2023 15:07
Show Gist options
  • Save rf5860/c7173a7b88e525cee0cdd0d2f8429376 to your computer and use it in GitHub Desktop.
Save rf5860/c7173a7b88e525cee0cdd0d2f8429376 to your computer and use it in GitHub Desktop.
Fandom Wiki Auto Expander
// ==UserScript==
// @name Fandom Wiki Auto Expander
// @version 0.1
// @description Auto-expand collapsible elements on fandom wiki
// @author rjf89
// @match https://deadcells.fandom.com/wiki/*
// @icon https://static.wikia.nocookie.net/deadcells_gamepedia_en/images/4/4a/Site-favicon.ico/revision/latest?cb=20210601142619
// ==/UserScript==
(function() {
'use strict';
let observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (typeof mutation.addedNodes == "undefined" || mutation.addedNodes.length == 0) return;
console.log(mutation.addedNodes);
[...mutation.addedNodes]
.flatMap(e => e.querySelectorAll && [e, ...e.querySelectorAll(".mw-collapsible-text")] || [])
.filter(e => e.classList && e.classList.contains("mw-collapsible-text"))
.forEach(e => e.click());
})
});
observer.observe(document.body, {
childList: true, subtree: true
, attributes: false
, characterData: false
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment