Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Pagebound: auto-reveal spoilers
- // @match https://pagebound.co/*
- // @run-at document-idle
- // @grant none
- // ==/UserScript==
- (function () {
- 'use strict';
- const SPOILER_BUTTON_SELECTOR = 'div[aria-hidden="true"].blur-md + button';
- const clickedButtons = new WeakSet();
- let scanScheduled = false;
- function isOnFeedPage() {
- return location.pathname.startsWith('/feed');
- }
- function clickUnclickedSpoilerButtons() {
- scanScheduled = false;
- if (!isOnFeedPage()) return;
- document.querySelectorAll(SPOILER_BUTTON_SELECTOR).forEach((button) => {
- if (clickedButtons.has(button)) return;
- clickedButtons.add(button);
- button.click();
- });
- }
- function scheduleScan() {
- if (scanScheduled) return;
- scanScheduled = true;
- requestAnimationFrame(clickUnclickedSpoilerButtons);
- }
- new MutationObserver(scheduleScan).observe(document.body, {
- childList: true,
- subtree: true,
- });
- scheduleScan();
- })();
Add Comment
Please, Sign In to add comment