P2P Trade on Telegram Web app PC unlocker

include *:* is necessary because mini applications in Telegram are displayed within an IFRAME and have their own distinct addresses, separate from Telegram.This code bypasses the verification of these applications, making them believe you are using an Android device, thereby enabling their functionality on a PC.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         P2P Trade on Telegram Web app PC unlocker
// @include *:*
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  include *:* is necessary because mini applications in Telegram are displayed within an IFRAME and have their own distinct addresses, separate from Telegram.This code bypasses the verification of these applications, making them believe you are using an Android device, thereby enabling their functionality on a PC.
// @author       Atamg
// @grant            GM_getResourceText
// @connect          *
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
// @include *:* is necessary because mini applications in Telegram are displayed within an IFRAME and have their own distinct addresses, separate from Telegram.
// This code bypasses the verification of these applications, making them believe you are using an Android device, thereby enabling their functionality on a PC.
// @license MIT
const customConsole = {
  log: function() {
    // Оставьте эту функцию пустой, чтобы отключить все логи
    // или замените её на оригинальную функцию console.log
    // console.log.apply(console, arguments);
  }
};
// Переназначаем console на нашу обертку

//unsafeWindow.console = customConsole;
//window.console = customConsole;
// bypass the platform through proxying to open via the telegram web version
if (unsafeWindow && unsafeWindow.Telegram && unsafeWindow.Telegram.WebApp) {
    unsafeWindow.Telegram.WebApp = new Proxy(unsafeWindow.Telegram.WebApp, {
        get(target, prop) {
            // Перехватываем обращение к свойству 'platform'

            if (prop === 'platform') {
                return 'android';
            }
            // Перехватываем вызовы методов
            if (typeof target[prop] === 'function') {
                return function(...args) {
                    console.log(`Method ${prop} called with arguments:`, args);

                    // Изменяем поведение метода 'exampleMethod'
                    if (prop === 'exampleMethod') {
                        // Модифицируем аргументы или выполняем другие действия
                        args[0] = 'modified argument';
                    }

                    // Вызываем оригинальный метод
                    return target[prop].apply(this, args);
                };
            }

            return target[prop];
        }
    });
}

    // bypass the platform through proxying to open via the telegram web version
if (unsafeWindow && unsafeWindow.Telegram && unsafeWindow.Telegram.WebView) {
    unsafeWindow.Telegram.WebView = new Proxy(unsafeWindow.Telegram.WebView, {
        get(target, prop) {
            // Перехватываем обращение к свойству 'platform'

            if (prop === 'initParams') {
                return 'android';
            }
            // Перехватываем вызовы методов
            if (typeof target[prop] === 'function') {
                return function(...args) {
                    console.log(`Method ${prop} called with arguments:`, args);

                    // Изменяем поведение метода 'exampleMethod'
                    if (prop === 'exampleMethod') {
                        // Модифицируем аргументы или выполняем другие действия
                        args[0] = 'modified argument';
                    }

                    // Вызываем оригинальный метод
                    return target[prop].apply(this, args);
                };
            }

            return target[prop];
        }
    });
}


})();