Home / eCommerce / JS Tickera Auto Click (PassieVol)
Duplicate Snippet

Embed Snippet on Your Site

JS Tickera Auto Click (PassieVol)

JS Tickera Auto Click (PassieVol)

Code Preview
php
<?php
// == Voelgoed Auto-Click Seating Map Button ==
// Priority: Vanilla JS -> jQuery (fallback)
// Always ensures button is clicked once it appears, regardless of timing.
(function() {
    var MAX_ATTEMPTS = 20; // Limit retries to avoid performance issues
    var attemptCount = 0;
    var clicked = false;
    // Function: Attempt to click button (vanilla JS)
    function tryClick(trigger) {
        var btn = document.querySelector(".tc_seating_map_button");
        console.log(`[VG DEBUG] [${trigger}] Button present:`, !!btn);
        if (btn) {
            btn.click();
            console.log(`[VG DEBUG] [${trigger}] Clicked .tc_seating_map_button`);
            clicked = true;
            return true;
        }
        return false;
    }
    // Polling function with requestAnimationFrame (smooth and efficient)
    function rafLoop() {
        if (clicked || attemptCount >= MAX_ATTEMPTS) return;
        attemptCount++;
        if (!tryClick(`RAF Attempt #${attemptCount}`)) {
            requestAnimationFrame(rafLoop);
        }
    }
    // Vanilla JS event listeners
    document.addEventListener('DOMContentLoaded', function() {
        tryClick('DOMContentLoaded');
        rafLoop();
    });
    window.addEventListener('load', function() {
        tryClick('window.onload');
    });
    // MutationObserver for dynamic DOM changes
    var observer = new MutationObserver(function(mutations, obs) {
        if (tryClick('MutationObserver')) {
            obs.disconnect(); // Stop once clicked
        }
    });
    observer.observe(document.body, { childList: true, subtree: true });
    // Safety disconnect after 10s
    setTimeout(function() { observer.disconnect(); }, 10000);
    // === jQuery fallback ===
    function jqueryFallback() {
        if (typeof window.jQuery !== "undefined") {
            try {
                window.jQuery(function($) {
                    console.log("[VG DEBUG] jQuery fallback active");
                    var jqAttempts = 0;
                    var interval = setInterval(function() {
                        jqAttempts++;
                        if (tryClick(`jQuery Poll #${jqAttempts}`) || jqAttempts > MAX_ATTEMPTS) {
                            clearInterval(interval);
                        }
                    }, 200);
                });
            } catch (e) {
                console.warn("[VG DEBUG] jQuery fallback failed:", e);
            }
        } else {
            console.warn("[VG DEBUG] jQuery not found, skipping fallback.");
        }
    }
    // Delay jQuery fallback to run last
    setTimeout(jqueryFallback, 1500);
})();

Comments

Add a Comment