Torn Blackjack Helper

Basic strategy overlay for Torn Blackjack

目前為 2025-06-13 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Torn Blackjack Helper
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Basic strategy overlay for Torn Blackjack
// @author       ChatGPT
// @match        https://www.torn.com/pda.php*step=blackjack*
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';
    
    // CSS untuk overlay
    GM_addStyle(`
        #bj-helper-overlay {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background-color: rgba(0, 0, 0, 0.85);
            color: #FFD700;
            padding: 15px;
            border-radius: 10px;
            border: 2px solid #FFD700;
            font-size: 20px;
            font-weight: bold;
            font-family: Arial, sans-serif;
            text-align: center;
            z-index: 9999;
            box-shadow: 0 4px 8px rgba(0,0,0,0.5);
            min-width: 180px;
            min-height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        #bj-helper-advice {
            text-shadow: 0 0 5px #000;
        }
    `);

    // Strategy Tables (sama seperti sebelumnya)
    const hardStrategy = { /* ... */ };
    const softStrategy = { /* ... */ };
    const pairStrategy = { /* ... */ };

    // Utility Functions (sama seperti sebelumnya)
    function parseCardValue(card) { /* ... */ }
    function getDealerUpcard() { /* ... */ }
    function getPlayerHand() { /* ... */ }
    function isPair(hand) { /* ... */ }
    function isSoft(hand) { /* ... */ }
    function handTotal(hand) { /* ... */ }
    function lookupDecision(dealer, hand) { /* ... */ }
    function matchStrategy(strat, dealer) { /* ... */ }

    // Fungsi utama
    function initBlackjackHelper() {
        // Buat overlay jika belum ada
        if (!document.getElementById('bj-helper-overlay')) {
            const overlay = document.createElement('div');
            overlay.id = 'bj-helper-overlay';
            overlay.innerHTML = '<div id="bj-helper-advice">---</div>';
            document.body.appendChild(overlay);
        }

        // Update setiap 1 detik
        setInterval(() => {
            try {
                const dealerCard = getDealerUpcard();
                const playerHand = getPlayerHand();
                
                if (!dealerCard || playerHand.length < 2) {
                    updateAdvice('---');
                    return;
                }
                
                const decision = lookupDecision(dealerCard, playerHand);
                updateAdvice(decision);
            } catch (e) {
                console.error('BJ Helper Error:', e);
            }
        }, 1000);
    }

    function updateAdvice(decision) {
        const adviceEl = document.getElementById('bj-helper-advice');
        if (adviceEl) adviceEl.textContent = decision;
    }

    // Tunggu hingga halaman siap
    if (document.readyState === 'complete') {
        initBlackjackHelper();
    } else {
        window.addEventListener('load', initBlackjackHelper);
    }
})();