Merge++

Best and only free Farm Merge Valley script

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension 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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Merge++
// @namespace    http://tampermonkey.net/
// @version      2.17
// @description  Best and only free Farm Merge Valley script
// @author       vk.com/downcasted
// @match        *://*.discordsays.com/*
// @match        *://farm-merge-valley.game-files.crazygames.com/farm-merge-valley/*
// @match        *://playfmv-*.devvit.net/*
// @icon         https://files.catbox.moe/d5dxaj.png
// @discord      https://discord.gg/PtF4maDP9D
// @license      GPL
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const originalOpen = XMLHttpRequest.prototype.open;
    const originalSend = XMLHttpRequest.prototype.send;

    XMLHttpRequest.prototype.open = function(method, url, ...args) {
        this._url = url;
        return originalOpen.call(this, method, url, ...args);
    };

    XMLHttpRequest.prototype.send = function(data) {
        const xhr = this;
        if (this._url && this._url.includes("jsonpack")) {
            const originalDesc = Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype, 'responseText');
            Object.defineProperty(xhr, 'responseText', {
                get: function() {
                    const original = originalDesc.get.call(this);

                    if (this.readyState === 4 && original) {
                        try {
                            const jsonpack = JSON.parse(original);
                            console.log('Original jsonpack:', jsonpack);

                            if (jsonpack.lucky_merge_config) {
                                jsonpack.lucky_merge_config.CHANCE = 100;
                            }

                            if (jsonpack.crate_regeneration_config) {
                                jsonpack.crate_regeneration_config.MAX_AMOUNT = 100;
                                jsonpack.crate_regeneration_config.AMOUNT_PER_INTERVAL = 100;
                                jsonpack.crate_regeneration_config.SPAWN_INTERVAL = 1;
                            }

                            if (jsonpack.energy_regeneration_config) {
                                jsonpack.energy_regeneration_config.MAX_AMOUNT = 100;
                                jsonpack.energy_regeneration_config.AMOUNT_PER_INTERVAL = 100;
                                jsonpack.energy_regeneration_config.SPAWN_INTERVAL = 1;
                            }

                            if (jsonpack.marketplace_items_config) {
                                const shop = jsonpack.marketplace_items_config;
                                for (const item in shop.items) {
                                    let itemrec = shop.items[item];
                                    if (itemrec.payment.type == "iap") {
                                        itemrec.payment = {type: "inventory", key: "gems", amount: 0};
                                    } else {
                                        itemrec.payment.amount = 0;
                                    }

                                    if (itemrec.id == "energy_80") {
                                        itemrec.reward.data.key = "coins";
                                        itemrec.reward.data.amount = 1200;
                                    } else if (itemrec.id == "gems_3500") {
                                        itemrec.image = "bg_marketplace_fb_blackfriday03";
                                        itemrec.reward.data.key = "gems";
                                        itemrec.reward.data.amount = 3500;
                                    }
                                }
                            }
                            return JSON.stringify(jsonpack);

                        } catch (e) {
                            return original;
                        }
                    }
                    return original;
                },
                configurable: true
            });

            Object.defineProperty(xhr, 'response', {
                get: function() {
                    return this.responseText;
                },
                configurable: true
            });
        }

        return originalSend.call(this, data);
    };
})();