Raw Source
RamiEjailat / Story Continues Auto-Clicker

// ==UserScript==
// @name         Story Continues Auto-Clicker
// @description  Automatically clicks elements matching specific classes or IDs.
// @author       Rami S Ejailat
// @copyright    RamiEjailat (https://openuserjs.org/users/RamiEjailat)
// @updateURL    https://openuserjs.org/meta/RamiEjailat/Global_Auto-Clicker_by_ClassID.meta.js
// @downloadURL  https://openuserjs.org/install/RamiEjailat/Global_Auto-Clicker_by_ClassID.user.js
// @license      MIT
// @version      20260716
// @namespace    http://tampermonkey.net/
// @match        *://*/*
// @grant        none
// @icon         https://cdn-icons-png.flaticon.com/64/12690/12690694.png
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    const targetSelectors = [
        '[class*="story-continues"]', '[id*="story-continues"]',
        '[class*="readmore-button"]', '[id*="readmore-button"]'
    ];

    function triggerClick() {
        targetSelectors.forEach(selector => {
            const elements = document.querySelectorAll(selector);
            elements.forEach(el => {
                // Find the nearest clickable element (button, a, or div if you prefer)
                const clickableParent = el.closest('button, a, div[role="button"]');
                const target = clickableParent || el;

                // Ensure it's visible before clicking
                if (target && target.offsetParent !== null) {
                    target.click();
                    console.log(`[Auto-Clicker] Clicked: ${selector}`);
                }
            });
        });
    }

    // Use MutationObserver for performance: only runs when the DOM updates
    const observer = new MutationObserver(triggerClick);
    observer.observe(document.body, { childList: true, subtree: true });

    // Initial check
    triggerClick();
})();