免费账户GPT-4o强开插件 ChatGPT Backend API Hook

Hook ChatGPT backend API and add missing features

// ==UserScript==
// @name 免费账户GPT-4o强开插件 ChatGPT Backend API Hook
// @namespace http://tampermonkey.net/
// @version 0.5
// @description Hook ChatGPT backend API and add missing features
// @match https://chatgpt.com/*
// @grant none
// ==/UserScript==

(function() {
   'use strict';


    const mockResponse = `{
    "models": [
        {
            "slug": "text-davinci-002-render-sha",
            "max_tokens": 8191,
            "title": "Default (GPT-3.5)",
            "description": "我们最快的模型,非常适合大多数日常任务。",
            "tags": [
                "gpt3.5"
            ],
            "capabilities": {},
            "product_features": {}
        },
        {
            "slug": "gpt-4o",
            "max_tokens": 8192,
            "title": "Scallion",
            "description": "浏览、高级数据分析和 DALL·E 现已集成到 GPT-4 中",
            "tags": [
                "confidential",
                "gpt4"
            ],
            "capabilities": {},
            "product_features": {
                "attachments": {
                    "type": "retrieval",
                    "accepted_mime_types": [
                        "text/x-java",
                        "application/x-latext",
                        "text/javascript",
                        "text/x-script.python",
                        "application/pdf",
                        "text/html",
                        "text/x-php",
                        "text/x-c",
                        "text/x-csharp",
                        "application/vnd.openxmlformats-officedocument.presentationml.presentation",
                        "text/x-tex",
                        "application/json",
                        "text/plain",
                        "application/msword",
                        "text/x-ruby",
                        "text/markdown",
                        "text/x-sh",
                        "text/x-typescript",
                        "text/x-c++",
                        "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
                    ],
                    "image_mime_types": [
                        "image/jpeg",
                        "image/gif",
                        "image/webp",
                        "image/png"
                    ],
                    "can_accept_all_mime_types": true
                }
            },
            "enabled_tools": [
                "tools",
                "tools2"
            ]
        },
        {
            "slug": "auto",
            "max_tokens": 8192,
            "title": "Dynamic",
            "description": "使用合适的模型来满足我的请求",
            "tags": [
                "confidential",
                "gpt4"
            ],
            "capabilities": {},
            "product_features": {
                "attachments": {
                    "type": "retrieval",
                    "accepted_mime_types": [
                        "text/x-java",
                        "application/x-latext",
                        "text/javascript",
                        "text/x-script.python",
                        "application/pdf",
                        "text/html",
                        "text/x-php",
                        "text/x-c",
                        "text/x-csharp",
                        "application/vnd.openxmlformats-officedocument.presentationml.presentation",
                        "text/x-tex",
                        "application/json",
                        "text/plain",
                        "application/msword",
                        "text/x-ruby",
                        "text/markdown",
                        "text/x-sh",
                        "text/x-typescript",
                        "text/x-c++",
                        "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
                    ],
                    "image_mime_types": [
                        "image/jpeg",
                        "image/gif",
                        "image/webp",
                        "image/png"
                    ],
                    "can_accept_all_mime_types": true
                }
            },
            "enabled_tools": [
                "tools",
                "tools2"
            ]
        }
    ],
    "categories": [
        {
            "category": "gpt_3.5",
            "human_category_name": "GPT-3.5",
            "human_category_short_name": "3.5",
            "icon": "bolt",
            "icon_src": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xMi41NjU1IDIuMTEwN0MxMy41Njg2IDAuOTIxNiAxNS40OTU2IDEuODU3NjEgMTUuMTgxIDMuMzgxMjJMMTQuMjI3NCA4LjAwMDAzSDE5LjkyMzlDMjEuMTk5OSA4LjAwMDAzIDIxLjg5MzIgOS40OTE5NyAyMS4wNzA0IDEwLjQ2NzNMMTEuNDM0MyAyMS44ODk0QzEwLjQzMTEgMjMuMDc4NSA4LjUwNDI0IDIyLjE0MjUgOC44MTg3OSAyMC42MTg5TDkuNzcyMzYgMTZINC4wNzU4OEMyLjc5OTg3IDE2IDIuMTA2NTggMTQuNTA4MSAyLjkyOTM4IDEzLjUzMjhMMTIuNTY1NSAyLjExMDdaIiBmaWxsPSIjMjgyODI4Ii8+Cjwvc3ZnPgo=",
            "subscription_level": "free",
            "default_model": "text-davinci-002-render-sha",
            "code_interpreter_model": "text-davinci-002-render-sha-code-interpreter",
            "plugins_model": "text-davinci-002-render-sha-plugins",
            "color": "#47C761",
            "short_explainer": "非常适合用于日常任务",
            "tagline": "最快速"
        },
        {
            "category": "AG8PqS2q",
            "human_category_name": "GPT-4o",
            "human_category_short_name": "4o",
            "icon": "stars",
            "icon_src": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE5LjkxOTQgMC44OTY4ODhDMTkuODkzOCAwLjY3MDk5NCAxOS43MDI4IDAuNTAwMjMgMTkuNDc1NSAwLjVDMTkuMjQ4MSAwLjQ5OTc3IDE5LjA1NjcgMC42NzAxMzEgMTkuMDMwOCAwLjg5NTk4QzE4LjkwOTQgMS45NDc0IDE4LjU5NzIgMi42Njg3MiAxOC4xMDggMy4xNTc5NkMxNy42MTg3IDMuNjQ3MjEgMTYuODk3NCAzLjk1OTQ1IDE1Ljg0NTkgNC4wODA3MkMxNS42MjAxIDQuMTA2NzcgMTUuNDQ5OCA0LjI5ODEyIDE1LjQ1IDQuNTI1NDZDMTUuNDUwMiA0Ljc1MjggMTUuNjIxIDQuOTQzOCAxNS44NDY5IDQuOTY5MzhDMTYuODgwNSA1LjA4NjQ2IDE3LjYxODMgNS4zOTg2NCAxOC4xMiA1Ljg5MTI1QzE4LjYxODkgNi4zODExOCAxOC45MzcgNy4xMDE0NyAxOS4wMjk1IDguMTQyMzVDMTkuMDUwMSA4LjM3MzI5IDE5LjI0MzYgOC41NTAyNiAxOS40NzU1IDguNTVDMTkuNzA3MyA4LjU0OTc0IDE5LjkwMDYgOC4zNzIzNCAxOS45MjA1IDguMTQxMzVDMjAuMDA5MiA3LjExODA1IDIwLjMyNyA2LjM4MTU0IDIwLjgyOTIgNS44NzkyOUMyMS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uMzMyNCAxNi42MzI0QzE1LjYyNCAxNS4zNDEgMTcuNTE3OCAxNC41MjM0IDIwLjE0OTEgMTQuMjk1N0MyMC43NDMxIDE0LjI0NDMgMjEuMTk5MyAxMy43NDc1IDIxLjIgMTMuMTUxM0MyMS4yMDA3IDEyLjU1NTEgMjAuNzQ1NiAxMi4wNTczIDIwLjE1MTggMTIuMDA0NUMxNy40NzUxIDExLjc2NjggMTUuNjIzMSAxMC45NDg3IDE0LjM2MzMgOS42NjU1OUMxMy4wOTY1IDguMzc1NTUgMTIuMjkzNyA2LjQ3ODUyIDExLjk5MjYgMy44MjA1N1oiIGZpbGw9IiMyODI4MjgiLz4KPC9zdmc+Cg==",
            "subscription_level": "plus",
            "default_model": "gpt-4o",
            "color": "#5B41F9",
            "short_explainer": "Newest and most advanced model",
            "tagline": "智能且快速"
        },
        {
            "category": "auto",
            "human_category_name": "Dynamic",
            "human_category_short_name": "",
            "icon": "connected",
            "icon_src": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSJjdXJyZW50Q29sb3IiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTEyIDcuNDJhMjIgMjIgMCAwIDAtMi40NTMgMi4xMjdBMjIgMjIgMCAwIDAgNy40MiAxMmEyMiAyMiAwIDAgMCAyLjEyNyAyLjQ1M2MuODA3LjgwOCAxLjYzNiAxLjUyIDIuNDUzIDIuMTI4YTIyIDIyIDAgMCAwIDIuNDUzLTIuMTI4QTIyIDIyIDAgMCAwIDE2LjU4IDEyYTIyIDIyIDAgMCAwLTIuMTI3LTIuNDUzQTIyIDIyIDAgMCAwIDEyIDcuNDJtMS43NTEtMS4xNTRhMjUgMjUgMCAwIDEgMi4xMDQgMS44OCAyNSAyNSAwIDAgMSAxLjg4ID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model": "auto",
            "plugins_model": "gpt-4-plugins",
            "color": "",
            "short_explainer": "为改善速度和智能程度而进行了优化。",
            "tagline": ""
        }
    ]
}`;

// 保存原始的 fetch 函数
const originalFetch = window.fetch;

// 重写 fetch 函数
window.fetch = async function(url, options) {
    // 如果 URL 包含 '/backend-api/models',返回模拟响应
    if (typeof url === 'string' && url.includes('/backend-api/models')) {
        return new Promise(resolve => {
            resolve(new Response(mockResponse, {
                status: 200,
                headers: { 'Content-Type': 'application/json' }
            }));
        });
    } else {
        // 否则调用原始的 fetch 函数处理其他情况下的网络请求
        return originalFetch(url, options);
    }
}
})();