From 97b517386c64b0ac450b5b36ca2a0e93edc1b6c6 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Sun, 18 Jun 2023 18:20:13 +0800 Subject: [PATCH] :sparkles: GPT4-Mobile --- src-tauri/src/inject/component.js | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src-tauri/src/inject/component.js b/src-tauri/src/inject/component.js index ba9824c..31ee045 100644 --- a/src-tauri/src/inject/component.js +++ b/src-tauri/src/inject/component.js @@ -146,4 +146,36 @@ document.addEventListener('DOMContentLoaded', () => { } window.pakeToast = pakeToast; + + // chatgpt supports unlimited times of GPT4-Mobile + if (window.location.hostname === 'chat.openai.com') { + const originFetch = fetch; + window.fetch = (url, options) => { + return originFetch(url, options).then(async (response) => { + if (url.indexOf('/backend-api/models') === -1) { + return response; + } + const responseClone = response.clone(); + let res = await responseClone.json(); + res.models = res.models.map((m) => { + m.tags = m.tags.filter((t) => { + return t !== 'mobile'; + }); + if (m.slug === 'gpt-4-mobile') { + res.categories.push({ + browsing_model: null, + category: 'gpt_4', + code_interpreter_model: null, + default_model: 'gpt-4-mobile', + human_category_name: 'GPT-4-Mobile', + plugins_model: null, + subscription_level: 'plus', + }); + } + return m; + }); + return new Response(JSON.stringify(res), response); + }); + }; + } });