Always Win Gambling Den Script

Always win in the Gambling Den on Dead Frontier

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Always Win Gambling Den Script
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Always win in the Gambling Den on Dead Frontier
// @author       Lucky11
// @match        https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=49
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    /* ---------------------------
       Always-win server hack overrides
       ---------------------------*/

    // Safe no-op fallbacks for globals that may be defined by the page
    const nf = window.nf || new Intl.NumberFormat('en-US');
    const cardBackgrounds = window.cardBackgrounds || (window.cardBackgrounds = []);
    const cardBackgroundsRef = cardBackgrounds; // reference in case page uses it
    const playSound = window.playSound || function() {};
    const moveCards = window.moveCards || function() {};
    const lockInput = window.lockInput || function() {};
    let pageLock = typeof window.pageLock !== 'undefined' ? window.pageLock : false;
    const hrV = typeof window.hrV !== 'undefined' ? window.hrV : '9_0_13_3';

    // Override switchCards to force a win
    window.switchCards = function(cardButton) {
        try {
            let playingCards = [...document.querySelectorAll('.playingCard')];
            for (let playingCard of playingCards) {
                try { playingCard.disabled = true; } catch (e) {}
            }

            // hacked server parameters
            var betAMT = parseInt(document.getElementById('betAmt').value) || 0;

            // Get current cash from the server and double it with bug elements
            var heldCashDiv = document.querySelector('.opElem.heldCash');
            var heldCashSpan = document.querySelector('.heldCash.cashhack');
            var curCash = 0;

            if (heldCashDiv && heldCashDiv.dataset && heldCashDiv.dataset.cash) {
                curCash = parseInt(heldCashDiv.dataset.cash.replace(/[^0-9]/g, '')) || curCash;
            }
            if (heldCashSpan && heldCashSpan.dataset && heldCashSpan.dataset.cash) {
                curCash = parseInt(heldCashSpan.dataset.cash.replace(/[^0-9]/g, '')) || curCash;
            }

            var newCashAmount = curCash + betAMT * 2;

            var cashDisplay = "Cash: $" + nf.format(newCashAmount);
            if (heldCashDiv) {
                try {
                    heldCashDiv.textContent = cashDisplay;
                    heldCashDiv.dataset.cash = cashDisplay;
                } catch (e) {}
            }
            if (heldCashSpan) {
                try {
                    heldCashSpan.textContent = cashDisplay;
                    heldCashSpan.dataset.cash = cashDisplay;
                } catch (e) {}
            }

            try { playSound("gamble"); } catch (e) {}
            try {
                if (cardButton && cardButton.childNodes && cardButton.childNodes[0]) {
                    cardButton.childNodes[0].src = cardBackgrounds[0];
                    cardButton.childNodes[0].alt = "Queen";
                    cardButton.childNodes[0].title = "Queen";
                }
            } catch (e) {}
            try {
                playingCards.splice(playingCards.indexOf(cardButton), 1);
            } catch (e) {}
            try {
                const msgEl = document.getElementById('playerMessage');
                if (msgEl) msgEl.textContent = "You got lucky that time, enjoy your winnings.";
            } catch (e) {}
            try { cardBackgrounds.splice(0, 1); } catch (e) {}

            setTimeout(function() {
                try {
                    let secondCardPosition = Math.round(Math.random());
                    if (playingCards[0] && playingCards[0].childNodes && playingCards[0].childNodes[0]) {
                        playingCards[0].childNodes[0].src = cardBackgrounds[secondCardPosition];
                        playingCards[0].childNodes[0].alt = "Jack";
                        playingCards[0].childNodes[0].title = "Jack";
                        cardBackgrounds.splice(secondCardPosition, 1);
                    }
                    if (playingCards[1] && playingCards[1].childNodes && playingCards[1].childNodes[0]) {
                        playingCards[1].childNodes[0].src = cardBackgrounds[0];
                        playingCards[1].childNodes[0].alt = "Jack";
                        playingCards[1].childNodes[0].title = "Jack";
                    }
                    try { setupDen(); } catch (e) {}
                } catch (e) {}
            }, 3000);
        } catch (e) {
            console.error('switchCards override error', e);
        }
    };

    // Override server with bad request info to deduct bet then allow the forced-win flow
    window.placeBet = function() {
        try {
            if (!pageLock) {
                var amt = parseInt(document.getElementById('betAmt').value) || 0;

                // Get current cash from the bug elements
                var heldCashDiv = document.querySelector('.opElem.heldCash');
                var heldCashSpan = document.querySelector('.heldCash.cashhack');
                var curCash = 0;

                if (heldCashDiv && heldCashDiv.dataset && heldCashDiv.dataset.cash) {
                    curCash = parseInt(heldCashDiv.dataset.cash.replace(/[^0-9]/g, '')) || curCash;
                }
                if (heldCashSpan && heldCashSpan.dataset && heldCashSpan.dataset.cash) {
                    curCash = parseInt(heldCashSpan.dataset.cash.replace(/[^0-9]/g, '')) || curCash;
                }

                // Check bet amount against available cash without triggering anti cheat
                if (amt >= 100 && amt <= curCash && amt <= 10000000) {
                    pageLock = true;
                    try { lockInput(); } catch (e) {}
                    curCash -= amt; // Deduct the bet amount from total allowed cash pool

                    // Update cash on the server
                    var cash = "Cash: $" + nf.format(curCash);
                    if (heldCashDiv) {
                        try {
                            heldCashDiv.textContent = cash;
                            heldCashDiv.dataset.cash = cash;
                        } catch (e) {}
                    }
                    if (heldCashSpan) {
                        try {
                            heldCashSpan.textContent = cash;
                            heldCashSpan.dataset.cash = cash;
                        } catch (e) {}
                    }

                    try { moveCards(); } catch (e) {}
                } else {
                    pageLock = true;
                    try {
                        document.getElementById('playerMessage').textContent = "You don't have that amount of cash.";
                        setTimeout(setupDen, 3000);
                    } catch (e) {}
                }
            }
        } catch (e) {
            console.error('placeBet override error', e);
        }
    };

    function setupDen() {
        try {
            var pm = document.getElementById('playerMessage');
            if (pm) pm.textContent = "Bet must be between $100 and $10,000,000.";

            cardBackgroundsRef[0] = "hotrods/hotrods_v" + hrV + "/HTML5/images/gamblingden/card_queen.png";
            cardBackgroundsRef[1] = "hotrods/hotrods_v" + hrV + "/HTML5/images/gamblingden/card_jack1.png";
            cardBackgroundsRef[2] = "hotrods/hotrods_v" + hrV + "/HTML5/images/gamblingden/card_jack2.png";

            var heldCashDiv = document.querySelector('.opElem.heldCash');
            var heldCashSpan = document.querySelector('.heldCash.cashhack');
            var curCash = 0;

            if (heldCashDiv && heldCashDiv.dataset && heldCashDiv.dataset.cash) {
                curCash = parseInt(heldCashDiv.dataset.cash.replace(/[^0-9]/g, '')) || curCash;
            }
            if (heldCashSpan && heldCashSpan.dataset && heldCashSpan.dataset.cash) {
                curCash = parseInt(heldCashSpan.dataset.cash.replace(/[^0-9]/g, '')) || curCash;
            }

            var cashDisplay = "Cash: $" + nf.format(curCash);

            if (heldCashDiv) {
                try {
                    heldCashDiv.textContent = cashDisplay;
                    heldCashDiv.dataset.cash = cashDisplay;
                } catch (e) {}
            }
            if (heldCashSpan) {
                try {
                    heldCashSpan.textContent = cashDisplay;
                    heldCashSpan.dataset.cash = cashDisplay;
                } catch (e) {}
            }

            // Set the maximum gambling value server side
            var maxGamblingValue = Math.min(10000000, curCash || 10000000);
            try { document.getElementById('betAmt').max = maxGamblingValue; } catch (e) {}

            pageLock = false;
            try { lockInput(); } catch (e) {}
        } catch (e) {
            console.error('setupDen error', e);
        }
    }

    /* ---------------------------
       Gold-tint visual-only code
       ---------------------------*/

    // Utility: safely apply and revert a CSS filter on an element
    function applyTemporaryFilter(el, filterValue, durationMs) {
        try {
            const original = el.style.filter || '';
            el.style.filter = filterValue;
            setTimeout(() => {
                try { el.style.filter = original; } catch (e) {}
            }, durationMs);
        } catch (e) {
            console.error('applyTemporaryFilter error', e);
        }
    }

    // Replace img with a tinted canvas and revert after duration
    function replaceImgWithGoldCanvas(img, durationMs) {
        try {
            const canvas = document.createElement('canvas');
            const ctx = canvas.getContext('2d');
            canvas.width = img.naturalWidth || img.width || 100;
            canvas.height = img.naturalHeight || img.height || 140;
            ctx.drawImage(img, 0, 0, canvas.width, canvas.height);

            // Apply a gold multiply overlay
            ctx.globalCompositeOperation = 'multiply';
            ctx.fillStyle = 'rgba(212,175,55,0.95)';
            ctx.fillRect(0, 0, canvas.width, canvas.height);

            // Add subtle highlight
            ctx.globalCompositeOperation = 'screen';
            const grad = ctx.createLinearGradient(0, 0, 0, canvas.height);
            grad.addColorStop(0, 'rgba(255,255,224,0.15)');
            grad.addColorStop(1, 'rgba(0,0,0,0)');
            ctx.fillStyle = grad;
            ctx.fillRect(0, 0, canvas.width, canvas.height);

            // Restore default composite
            ctx.globalCompositeOperation = 'source-over';

            // Preserve some attributes and replace
            canvas.className = img.className;
            canvas.id = img.id ? img.id + '__goldTint' : '';
            canvas.style.cssText = img.style.cssText;

            const parent = img.parentNode;
            if (!parent) return;
            parent.replaceChild(canvas, img);

            // Revert after durationMs
            setTimeout(() => {
                try {
                    if (canvas.parentNode) canvas.parentNode.replaceChild(img, canvas);
                } catch (e) {}
            }, durationMs);
        } catch (e) {
            console.error('replaceImgWithGoldCanvas error', e);
        }
    }

    // Main function: change elements that reference the specific image
    function changeCardBackToGoldOnce() {
        try {
            const targetPath = 'hotrods/hotrods_v' + hrV + '/HTML5/images/gamblingden/card_back.png';
            const duration = 500; // ms

            // 1) Image <img src="...card_back.png">
            const imgs = Array.from(document.querySelectorAll('img'));
            imgs.forEach(img => {
                try {
                    const src = img.src || '';
                    if (src.includes(targetPath)) {
                        const supportsFilter = typeof CSS !== 'undefined';
                        if (supportsFilter) {
                            applyTemporaryFilter(img, 'sepia(0.7) hue-rotate(10deg) saturate(2.8) brightness(1.15) contrast(1.02)', duration);
                        } else {
                            replaceImgWithGoldCanvas(img, duration);
                        }
                    }
                } catch (e) {}
            });

            // 2) Elements with CSS background-image referencing card_back.png
            const all = Array.from(document.querySelectorAll('*'));
            all.forEach(el => {
                try {
                    const style = getComputedStyle(el);
                    const bg = style.backgroundImage || '';
                    if (bg.includes(targetPath)) {
                        applyTemporaryFilter(el, 'sepia(0.7) hue-rotate(10deg) saturate(2.8) brightness(1.15) contrast(1.02)', duration);
                    }
                } catch (e) {}
            });
        } catch (e) {
            console.error('changeCardBackToGoldOnce error', e);
        }
    }

    // Run once on load and whenever the DOM changes (to catch dynamic replacements)
    function setupMutationWatcherForGoldTint() {
        changeCardBackToGoldOnce();
        const observer = new MutationObserver((mutations) => {
            // Debounce calls slightly
            clearTimeout(window.__goldTintDebounce);
            window.__goldTintDebounce = setTimeout(changeCardBackToGoldOnce, 40);
        });
        observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['src', 'style', 'class'] });
    }

    // Initialize both features when DOM ready
    function init() {
        try {
            setupDen();
        } catch (e) {}
        try {
            setupMutationWatcherForGoldTint();
        } catch (e) {}
    }

    if (document.readyState === 'complete' || document.readyState === 'interactive') {
        init();
    } else {
        window.addEventListener('DOMContentLoaded', init);
    }

})();