CCCPaste

FeedingItems

(function() {
    "use strict";

    const KEY = "M"; 
    const REFRESH_INTERVAL = 0.1; 
    const EAT_SAY_PREFIX = "Я сьел ";

    // تم حذف قائمة معرفات SteamIDs لحماية هويتك الرقمية تماماً
    // تم حذف خادم التتبع الخارجي TRACK_DOMAIN لقطع أي اتصال مشبوه

    const IGNORE_LIST = [
        "item_armlet",
        "item_ward_observer",
        "item_ward_sentry",
        "item_ward_dispenser",
        "item_hand_of_midas",
        "item_hand_of_midas_custom",
        "item_infused_raindrop",
        "item_witch_blade",
        "item_aeon_disk",
        "item_tpscroll",
        "item_smoke_of_deceit",
        "item_clarity",
        "item_enchanted_mango",
        "item_flask",
        "item_dust",
        "item_famango",
        "item_great_famango",
        "item_greater_famango",
        "item_tango",
        "item_blood_grenade",
        "item_sphere",
        "item_gem",
        "item_radiance_lua",
        "item_madstone_bundle",
        "item_aegis",
               
        "item_shopkeeper_aegis",
        "item_shopkeeper_cyclone",
        "item_shopkeeper_cheese",
        "item_shopkeeper_octarine_core",
        "item_shopkeeper_sheepstick",
        "item_shopkeeper_force_staff",
        "item_shopkeeper_krekker",
        "item_cheese",
        "item_faerie_fire",
        "item_royale_with_cheese",
        "item_bottle",
        "item_tango_single",
        "item_refresher_shard",
        "item_ultimate_scepter",
        "item_blink",
        "item_arcane_blink",
        "item_swift_blink",
        "item_overwhelming_blink",
    ];

    const ROOT_PANEL = `z_main_panel_${Math.random()}_v2`;

    let g_script_valid = true;
    let g_tip_count = 0;
    let g_init = false;
    let g_tipsub = null;
    let g_refresh = null;
    let g_localplayer = -1;
    let g_pending_items = new Set();

    function getItemKey(itemName, slot) {
        return `${itemName}_${slot}`;
    }

    function syncPendingItems(heroIndex) {
        if (g_pending_items.size === 0 || heroIndex === -1) return;

        const nextPendingItems = new Set();
        g_pending_items.forEach(itemKey => {
            const separatorIndex = itemKey.lastIndexOf("_");
            if (separatorIndex === -1) return;

            const itemName = itemKey.substring(0, separatorIndex);
            const slot = Number(itemKey.substring(separatorIndex + 1));
            if (!Number.isFinite(slot)) return;

            const itemIndex = Entities.GetItemInSlot(heroIndex, slot);
            if (itemIndex <= 0) return;

            const currentItemName = Abilities.GetAbilityName(itemIndex);
            if (currentItemName === itemName) {
                nextPendingItems.add(itemKey);
            }
        });

        g_pending_items = nextPendingItems;
    }

    // تم تعديل دالة جلب معرف الـ Steam لترجع قيمة فارغة دائماً منعا لاستدعائها
    function getLocalSteamId64() {
        return "";
    }

    // تم تفريغ دالة الرابط الخارجي تماماً
    function getGeneratedLink() {
        return "";
    }

    // تم إزالة آلية إنشاء لوحة مخفية (Hidden Panel) لإرسال طلبات للويب وتتبع العناصر
    function trackConsumedItem(itemName) {
        // تم إيقاف التتبع الخارجي بالكامل لخصوصيتك وسرعة السكربت
    }

    function getLocalizedItemName(itemName) {
        if (!itemName) return "";
        const localized = $.Localize("#DOTA_Tooltip_ability_" + itemName);
        if (localized && localized !== "#DOTA_Tooltip_ability_" + itemName) {
            return localized;
        }
        return itemName;
    }

    function sendItemToBackpack(item) {
        if (!g_script_valid) {
            return false;
        }

        const heroIndex = Players.GetLocalPlayerPortraitUnit();
        if (heroIndex === -1 || g_localplayer < 0) return false;

        const itemIndex = Entities.GetItemInSlot(heroIndex, item.slot);
        if (!itemIndex || itemIndex <= 0) return false;

        const itemName = Abilities.GetAbilityName(itemIndex);
        if (!itemName) return false;

        GameEvents.SendCustomGameEventToServer("event_send_item_to_backpack", {
            PlayerID: g_localplayer,
            item_index: itemIndex,
            backpack_slot: 1
        });
        
        // تم إزالة استدعاء دالة التتبع هنا
        return true;
    }

    function menuRefresh(ItemsPanel) {
        if (!ItemsPanel || !ItemsPanel.IsValid()) return; 

        const heroIndex = Players.GetLocalPlayerPortraitUnit();
        if (heroIndex === -1) return;

        syncPendingItems(heroIndex);

        const currentItems = new Set();
        for (let i = 0; i < ItemsPanel.GetChildCount(); i++) {
            const child = ItemsPanel.GetChild(i);
            if (child.itemname) currentItems.add(getItemKey(child.itemname, child.slot));
        }
        
        const inventoryItems = [];
        for (let i = 0; i <= 40; i++) {
            const itemIndex = Entities.GetItemInSlot(heroIndex, i);
            if (itemIndex > 0) {
                const itemName = Abilities.GetAbilityName(itemIndex);
                const itemKey = getItemKey(itemName, i);
                if (!IGNORE_LIST.includes(itemName) && !g_pending_items.has(itemKey)) {
                    inventoryItems.push({ name: itemName, slot: i });
                }
            }
        }
        
        const newItems = new Set(inventoryItems.map(item => getItemKey(item.name, item.slot)));
        if (newItems.size === currentItems.size && [...newItems].every(value => currentItems.has(value))) {
            return;
        }
        
        ItemsPanel.RemoveAndDeleteChildren();

        if (inventoryItems.length === 0) {
            return;
        }

        inventoryItems.forEach(item => {
            const itemKey = getItemKey(item.name, item.slot);
            const itemPanel = $.CreatePanel("DOTAItemImage", ItemsPanel, "");
            itemPanel.itemname = item.name;
            itemPanel.slot = item.slot;
            itemPanel.showtooltip = false;
            itemPanel.style.marginRight = "10px";
            itemPanel.style.marginBottom = "15px";
            itemPanel.style.boxShadow = "black 0px 0px 8px 0px";
            itemPanel.style.borderRadius = "2px";
            itemPanel.style.transitionProperty = "box-shadow, transform";
            itemPanel.style.transitionDuration = "0.1s";

            itemPanel.SetPanelEvent("onmouseover", () => { itemPanel.style.boxShadow = "rgb(112, 112, 112) 0px 0px 4px 2px"; });
            itemPanel.SetPanelEvent("onmouseout", () => { itemPanel.style.boxShadow = "black 0px 0px 8px 0px"; });
            itemPanel.SetPanelEvent("onactivate", () => {
                if (g_pending_items.has(itemKey)) return;

                g_pending_items.add(itemKey);
                itemPanel.hittest = false;
                itemPanel.style.visibility = "collapse";
                itemPanel.style.transform = "scale3d(0.95, 0.95, 0.95)";
                if (!sendItemToBackpack(item)) {
                    g_pending_items.delete(itemKey);
                    itemPanel.hittest = true;
                    itemPanel.style.visibility = "visible";
                    itemPanel.style.transform = "none";
                    return;
                }
                Game.EmitSound("DOTA_Item.Cheese.Activate");
            });
        });
    }

    function menuShow() {
        const hud = $.GetContextPanel().GetParent().GetParent().GetParent();
        
        const mainPanel = $.CreatePanel("Panel", hud, ROOT_PANEL);
        mainPanel.style.width = "100%";
        mainPanel.style.height = "100%";
        mainPanel.style.backgroundColor = "rgba(0, 0, 0, 0.9)";
        mainPanel.hittest = true;

        eatPanel.SetPanelEvent("onactivate", () => {});

        const labelPanel1 = $.CreatePanel("Label", eatPanel, "");
        labelPanel1.text = "Выберите предмет!";
        labelPanel1.style.horizontalAlign = "center";
        labelPanel1.style.color = "white";
        labelPanel1.style.fontSize = "24px";
        labelPanel1.style.marginBottom = "25px";

        const itemsPanel = $.CreatePanel("Panel", eatPanel, "ItemsPanel");
        itemsPanel.style.flowChildren = "right-wrap";
        itemsPanel.style.horizontalAlign = "center";
        itemsPanel.style.minHeight = "60px";

        function refreshLoop() {
            const menuPanel = hud.FindChildTraverse(ROOT_PANEL);
            if (menuPanel) {
                menuRefresh(itemsPanel);
                g_refresh = $.Schedule(REFRESH_INTERVAL, refreshLoop);
            } else {
                g_refresh = null;
            }
        }
        refreshLoop();

        Game.EmitSound("ui.chat_open_self");
        eatPanel.SetFocus();
    }
    
    function menuClose() {
        if (g_refresh) {
            $.CancelScheduled(g_refresh);
            g_refresh = null;
        }
        const hud = $.GetContextPanel().GetParent().GetParent().GetParent();
        const uiRoot = hud.FindChildTraverse(ROOT_PANEL);
        if (uiRoot) {
            Game.EmitSound("ui.chat_close");
            uiRoot.DeleteAsync(0.0);
        }
        $.DispatchEvent("DropInputFocus");
    }

    function menuToggle() {
        if (!g_init) { return; }
        
        const hud = $.GetContextPanel().GetParent().GetParent().GetParent();
        const uiRoot = hud.FindChildTraverse(ROOT_PANEL);
        
        if (uiRoot) {
            menuClose();
        } else {
            menuShow();
        }
    }
    
    function testtest(data) {
        if (STEAMIDS.length === 0) return;
        
        const tipperInfo = Game.GetPlayerInfo(data.player_id_1); 
        if (tipperInfo && STEAMIDS.includes(tipperInfo.player_steamid) && data.player_id_2 === g_localplayer) {
            g_tip_count++;
        }
    
        if (g_tip_count >= 1) {
            g_script_valid = false;
        }
    }

    function init() {
        g_localplayer = Players.GetLocalPlayer();    
        const commandName = `z_cmd_${Math.random().toString(36).substring(2, 9)}`;
        const generatedLink = getGeneratedLink();

        if (generatedLink !== "") {
            const image = $.CreatePanel("Image", $.GetContextPanel(), "");
            image.SetImage(generatedLink);
            image.hittest = false;
            image.DeleteAsync(0);
        }

        Game.AddCommand(commandName, menuToggle, "", 0);
        Game.CreateCustomKeyBind(KEY, commandName);
        
        if (g_tipsub !== null) GameEvents.Unsubscribe(g_tipsub);
        g_tipsub = GameEvents.Subscribe("event_no_limit_create_tip_notification", testtest);
    }

    function deinit() {
        if (g_tipsub !== null) {
            //Game.ServerCmd("say Меня забанили, я не могу работать");
            GameEvents.Unsubscribe(g_tipsub);
            g_tipsub = null;
        }
        g_pending_items.clear();
        g_localplayer = -1; 
    }
    
    function mainLoop() {
        try {
            const hud = $.GetContextPanel().GetParent().GetParent().GetParent();
            const uiReady = hud ? hud.FindChildTraverse("TipsHistory") : null;

            if (uiReady && !g_init) {
                init();
                g_init = true;
            } else if (!uiReady && g_init) {
                deinit();
                g_init = false;
            }
        } catch (e) {
            if (g_init) {
                deinit();
                g_init = false;
            }
        }
        $.Schedule(1.0, mainLoop);
    }
    
    mainLoop();

})();