From d9c83fd08457b009348de53848f41b33165031c2 Mon Sep 17 00:00:00 2001 From: lencx Date: Thu, 1 Jun 2023 19:15:35 +0800 Subject: [PATCH] feat: GPT-4-Mobile --- scripts/chat.js | 35 ++++++++++++++++++++++++++++++++++- scripts/manifest.json | 2 +- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/scripts/chat.js b/scripts/chat.js index 9fad542..9e1643d 100644 --- a/scripts/chat.js +++ b/scripts/chat.js @@ -1,6 +1,6 @@ /** * @name chat.js - * @version 0.1.0 + * @version 0.1.1 * @url https://github.com/lencx/ChatGPT/tree/main/scripts/chat.js */ @@ -25,6 +25,7 @@ function chatInit() { }); document.addEventListener('visibilitychange', focusOnInput); + gpt4Mobile(); } function observeMutations(mutationsList) { @@ -115,6 +116,38 @@ function chatInit() { }; } + function gpt4Mobile() { + 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); + }); + }; + } + init(); } diff --git a/scripts/manifest.json b/scripts/manifest.json index 77ee9c8..fb201a8 100644 --- a/scripts/manifest.json +++ b/scripts/manifest.json @@ -6,7 +6,7 @@ "scripts": [ { "name": "core.js", - "version": "0.1.0" + "version": "0.1.1" }, { "name": "cmd.js",