Unlock Weapons Forward Assault Script

unlocks guns

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Unlock Weapons Forward Assault Script
// @namespace    cs.dev
// @version      1.1
// @description  unlocks guns
// @author       CS
// @match        https://forward-assault.game-files.crazygames.com/*
// @icon         https://www.google.com/s2/favicons?domain=freeicons.io
// @grant        none
// @license      MIT
// @run-at       document-start
// ==/UserScript==

const CONFIG = {
    enableLogging: false, //this is used for enabling the console log
    visualValues: 1,//this just changes the credits and gold just to make sure everything is working correctly
};

// Weapon inventory with barrel and tracer settings
const inventoryWeapons = [
    { id: 1, name: 'AK-47', barrelEnabled:0},
    { id: 2, name: 'Vector', barrelEnabled:1},
    { id: 3, name: 'Desert Eagle', barrelEnabled:0},
    { id: 4, name: 'FAMAS', barrelEnabled:1},
    { id: 5, name: 'M4A1', barrelEnabled:1},
    { id: 6, name: 'M40', barrelEnabled:0},
    { id: 8, name: 'Five Seven', barrelEnabled:1},
    { id: 9, name: 'SPAS-12', barrelEnabled:0},
    { id: 10, name: 'MP7', barrelEnabled:1},
    { id: 12, name: 'P250', barrelEnabled:1},
    { id: 13, name: 'M98', barrelEnabled:0},
    { id: 14, name: 'Knife', barrelEnabled:0},
    { id: 15, name: 'CX-70', barrelEnabled:1},
    { id: 16, name: 'A-91', barrelEnabled:1},
    { id: 19, name: 'PP-2000', barrelEnabled:1},
    { id: 20, name: 'MP5K', barrelEnabled:1},
    { id: 21, name: 'Karambit', barrelEnabled:0},
    { id: 22, name: 'Butterfly Knife', barrelEnabled:0},
    { id: 23, name: 'Tec-9', barrelEnabled:1},
    { id: 24, name: 'M1014', barrelEnabled:0},
    { id: 25, name: 'RFB', barrelEnabled:0},
    { id: 26, name: 'Glock', barrelEnabled:1},
    { id: 27, name: 'Uzi', barrelEnabled:1},
    { id: 28, name: 'FAL', barrelEnabled:1},
    { id: 29, name: 'Hatchet', barrelEnabled:0},
    { id: 30, name: 'MP9', barrelEnabled:1},
    { id: 31, name: 'P90', barrelEnabled:0},
    { id: 32, name: 'AWP', barrelEnabled:0},
    { id: 33, name: 'Huntsman', barrelEnabled:0},
    { id: 34, name: 'Beretta', barrelEnabled:1},
    { id: 35, name: 'Brass Knuckles', barrelEnabled:0},
    { id: 36, name: 'USP 45', barrelEnabled:1},
    { id: 37, name: 'Tecmix Knife', barrelEnabled:0}
];


// Custom logging function
function enabledlog(message) {
    if (CONFIG.enableLogging) {
        console.log(message);
    }
}

const originalFetch = window.fetch;

window.fetch = async function(...args) {
    const url = args[0];
    const options = args[1] || {};



    // Handle getaccountinfoWebglV5.php
    if (!url.includes('getaccountinfoWebglV5.php')) {
        return originalFetch(...args);
    }

    const response = await originalFetch(...args);
    const clonedResponse = response.clone();
    const originalText = await clonedResponse.text();

    try {
        // Find the XML section
        const xmlStart = originalText.indexOf('<?xml');
        const xmlEnd = originalText.indexOf('</AS_CustomInfo>') + '</AS_CustomInfo>'.length;

        if (xmlStart === -1 || xmlEnd === -1) {
            enabledlog("Could not find XML section");
            return response;
        }

        // Extract the three parts
        const beforeXml = originalText.substring(0, xmlStart);
        const xmlContent = originalText.substring(xmlStart, xmlEnd);
        const afterXml = originalText.substring(xmlEnd);

        let modifiedBeforeXml = beforeXml;

        // Parse the XML
        const parser = new DOMParser();
        const xmlDoc = parser.parseFromString(xmlContent, 'application/xml');


        // Modify credits and gold just so its a visual change
        const creditsTag = xmlDoc.getElementsByTagName('credits')[0];
        if (creditsTag) {
            creditsTag.textContent = CONFIG.visualValues;
        } else {
            enabledlog("Could not find creditsTag tag");
        }
        const goldTag = xmlDoc.getElementsByTagName('gold')[0];
        if (goldTag) {
            goldTag.textContent = CONFIG.visualValues;
        } else {
            enabledlog("Could not find goldTag tag");
        }


        // Unlock all weapons and set customizations
        const weaponInfoTags = xmlDoc.getElementsByTagName('WeaponInfo');
        let weaponsUnlocked = 0;

        for (let i = 0; i < weaponInfoTags.length; i++) {
            const weaponInfo = weaponInfoTags[i];
            const typeTag = weaponInfo.getElementsByTagName('type')[0];
            const unlockedTag = weaponInfo.getElementsByTagName('unlocked')[0];
            const customizationsTag = weaponInfo.getElementsByTagName('customizations')[0];

            if (typeTag && unlockedTag && customizationsTag) {
                const weaponId = parseInt(typeTag.textContent);
                const weaponData = inventoryWeapons.find(w => w.id === weaponId);

                // Unlock weapon
                unlockedTag.textContent = '1';
                weaponsUnlocked++;

                // Set customizations if weapon data exists
                if (weaponData) {
                    const barrel = weaponData.barrelEnabled;
                    customizationsTag.textContent = `Barrel*U-${barrel}*E-${barrel}_Camo*U-*E-$0`;
                }
            }
        }

        enabledlog(`Unlocked and customized ${weaponsUnlocked} weapons`);

        // Serialize back to string
        const serializer = new XMLSerializer();
        const modifiedXml = serializer.serializeToString(xmlDoc);

        enabledlog(xmlDoc);
        // Reconstruct the full response
        const modifiedText = modifiedBeforeXml + modifiedXml + afterXml;

        enabledlog("Response modified successfully");

        return new Response(modifiedText, {
            status: response.status,
            statusText: response.statusText,
            headers: response.headers
        });

    } catch (error) {
        enabledlog("Error modifying data");
        return response;
    }
};