Last active
May 23, 2023 15:07
-
-
Save rf5860/c7173a7b88e525cee0cdd0d2f8429376 to your computer and use it in GitHub Desktop.
Fandom Wiki Auto Expander
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 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