Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Auto Collapse Wikipedia "Plot" Section
- // @namespace https://greasyfork.org/en/users/85671-jcunews
- // @version 1.0.1
- // @license AGPLv3
- // @author jcunews
- // @description https://www.reddit.com/r/userscripts/comments/n72ppa/request_collapse_the_plot_paragraph_by_default_on/
- // @match https://*.wikipedia.org/wiki/*
- // @grant none
- // ==/UserScript==
- ((a, b, c, d, l) => {
- if (a = document.querySelector("#Plot.mw-headline")) {
- b = a.nextElementSibling ? a : a.parentNode;
- b.insertAdjacentHTML("beforeend", '<a href="javascript:void(0)" style="margin-left:2em;font-size:10pt;font-weight:normal">[Expand]</a>');
- b.lastChild.onclick = function() {
- l.forEach(e => {
- e.style.display = e.dataset.display;
- });
- this.remove();
- };
- d = (c = Array.from(document.querySelectorAll(".mw-headline,.navbox"))).indexOf(a);
- if (d >= 0) {
- if (!(c = c[d + 1]).nextElementSibling) c = c.parentNode;
- } else c = null;
- l = [];
- while ((b = b.nextElementSibling) && (b !== c)) {
- l.push(b);
- b.dataset.display = b.style.display;
- b.style.display = "none";
- }
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement