Dead Frontier Auto Bank Buttons & Search Recall

Bank buttons under the Browser Implants panel; with titled border; restores last search only when returning from a bank action; sets AutoBank flag

当前为 2025-04-27 提交的版本,查看 最新版本

// ==UserScript==
// @name         Dead Frontier Auto Bank Buttons & Search Recall
// @namespace    Zega
// @version      3.9
// @description  Bank buttons under the Browser Implants panel; with titled border; restores last search only when returning from a bank action; sets AutoBank flag
// @match        https://fairview.deadfrontier.com/onlinezombiemmo/index.php*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Ensure AutoBank implant flag
    if (!window.BrowserImplant_AutoBank) {
        window.BrowserImplant_AutoBank = true;
    }

    const origin     = window.location.origin;
    const path       = window.location.pathname;
    const params     = new URLSearchParams(window.location.search);
    const returnPage = params.get('originPage');
    const currentPage = params.get('page') || '';

    function makeReturnURL() {
        return returnPage
            ? `${origin}${path}?page=${returnPage}`
            : `${origin}${path}`;
    }

    // BANK PAGE HANDLER
    if (currentPage === '15' && params.has('scripts')) {
        const action = params.get('scripts');
        window.addEventListener('load', () => {
            setTimeout(() => {
                // perform the bank action
                if (action === 'withdraw') {
                    const amount = params.get('amount') || '50000';
                    const input  = document.querySelector('#withdraw');
                    const btn    = document.querySelector('#wBtn');
                    if (input && btn) {
                        input.value = amount;
                        input.setAttribute('value', amount);
                        ['input','change'].forEach(evt =>
                            input.dispatchEvent(new Event(evt, { bubbles:true }))
                        );
                        if (typeof withdraw === 'function') withdraw();
                        else btn.click();
                    }
                } else if (action === 'withdrawAll') {
                    if (typeof withdraw === 'function') withdraw(1);
                    else {
                        const allBtn = document.querySelector("button[onclick='withdraw(1);']");
                        if (allBtn) allBtn.click();
                    }
                } else if (action === 'deposit') {
                    if (typeof deposit === 'function') deposit(1);
                    else {
                        const depBtn = document.querySelector("button[onclick='deposit(1);']");
                        if (depBtn) depBtn.click();
                    }
                }
            }, 200);

            // after action, return back
            setTimeout(() => {
                // mark to restore search when returning to marketplace
                if (returnPage === '35') {
                    sessionStorage.setItem('df_auto_restore', '1');
                }
                window.location.replace(makeReturnURL());
            }, 500);
        });
        return;
    }

    // INJECT AUTO BANK BUTTONS & CONDITIONAL SEARCH RESTORE
    document.addEventListener('DOMContentLoaded', () => {
        function injectButtons() {
            const panel = document.getElementById('browser-implant-panel');
            if (!panel) return setTimeout(injectButtons, 200);
            if (document.getElementById('auto-bank-fieldset')) return;

            // If we're on Marketplace after a bank action, restore last search
            if (currentPage === '35' && sessionStorage.getItem('df_auto_restore')) {
                sessionStorage.removeItem('df_auto_restore');
                const searchInput = document.getElementById('searchField');
                const last = localStorage.getItem('lastDFsearch');
                if (searchInput && last) {
                    searchInput.value = last;
                    searchInput.dispatchEvent(new Event('input', { bubbles:true }));
                    setTimeout(() => {
                        const searchBtn = document.getElementById('makeSearch');
                        if (searchBtn) searchBtn.click();
                    }, 50);
                }
            }

            // Build the Auto Bank fieldset
            const fieldset = document.createElement('fieldset');
            fieldset.id = 'auto-bank-fieldset';
            Object.assign(fieldset.style, {
                border: '1px solid #666',
                padding: '8px 12px',
                marginTop: '8px',
                background: 'rgba(0,0,0,0.3)'
            });
            const legend = document.createElement('legend');
            legend.textContent = 'Auto Bank';
            Object.assign(legend.style, {
                color: '#ffd700',
                padding: '0 6px',
                fontSize: '13px'
            });
            fieldset.appendChild(legend);

            const btnContainer = document.createElement('div');
            btnContainer.id = 'auto-bank-btn-container';
            Object.assign(btnContainer.style, {
                display: 'flex',
                flexDirection: 'column',
                gap: '4px'
            });
            fieldset.appendChild(btnContainer);
            panel.appendChild(fieldset);

            // Helper to create and append a bank button
            function createBtn(id, label, action, amount) {
                const btn = document.createElement('button');
                btn.id = id;
                btn.textContent = label;
                Object.assign(btn.style, {
                    width: '100%',
                    padding: '4px 8px',
                    backgroundColor: '#222',
                    color: '#ffd700',
                    border: '1px solid #666',
                    borderRadius: '4px',
                    fontSize: '12px',
                    cursor: 'pointer',
                    textAlign: 'center'
                });
                btn.addEventListener('click', () => {
                    if (currentPage === '35') {
                        const inp = document.getElementById('searchField');
                        if (inp) localStorage.setItem('lastDFsearch', inp.value);
                    }
                    let url = `${origin}${path}?page=15&scripts=${action}`;
                    if (amount) url += `&amount=${amount}`;
                    // pass originPage so we know where to return
                    if (currentPage) url += `&originPage=${currentPage}`;
                    window.location.replace(url);
                });
                btnContainer.appendChild(btn);
            }

            // Add all bank action buttons
            createBtn('autoWithdraw50k',  'Withdraw 50k',   'withdraw',    '50000');
            createBtn('autoWithdraw150k', 'Withdraw 150k',  'withdraw',    '150000');
            createBtn('autoWithdraw5M',   'Withdraw 5M',    'withdraw',    '5000000');
            createBtn('autoWithdrawAll',  'Withdraw All',   'withdrawAll', null);
            createBtn('autoDepositAll',   'Deposit All',    'deposit',     null);
        }

        injectButtons();
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址