您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
切换 OpenAI GPT-4 使用的模型(gpt-4 和 gpt-4-mobile)。
当前为
// ==UserScript== // @name GPT4 Model Switcher // @namespace https://github.com/LShang001 // @description 切换 OpenAI GPT-4 使用的模型(gpt-4 和 gpt-4-mobile)。 // @author LShang // @license MIT // @match https://chat.openai.com/* // @match https://chat.zhile.io/* // @version 4.0 // @grant none // ==/UserScript== (function () { 'use strict'; // 初始化脚本启动状态和使用模型 let isScriptEnabled = localStorage.getItem('isScriptEnabled') === 'true'; let modelInUse = isScriptEnabled ? 'gpt-4-mobile' : 'gpt-4'; // 创建和插入 CSS 样式 const style = document.createElement('style'); style.innerHTML = ` /* 设置开关的样式 */ `; document.head.appendChild(style); // 创建切换按钮 const toggleButton = document.createElement('label'); toggleButton.className = 'toggle-button'; // 创建并添加显示模型名称的文本 const toggleText = document.createElement('span'); toggleText.textContent = 'Model: ' + modelInUse; toggleButton.appendChild(toggleText); // 创建并添加切换输入元素 const toggleInput = document.createElement('input'); toggleInput.type = 'checkbox'; toggleInput.checked = isScriptEnabled; toggleInput.addEventListener('change', toggleScript); toggleButton.appendChild(toggleInput); // 创建并添加滑块元素 const slider = document.createElement('span'); slider.className = 'slider'; toggleButton.appendChild(slider); // 将切换按钮添加到页面中 document.body.appendChild(toggleButton); // 切换脚本状态的函数 function toggleScript() { isScriptEnabled = !isScriptEnabled; localStorage.setItem('isScriptEnabled', isScriptEnabled); modelInUse = isScriptEnabled ? 'gpt-4-mobile' : 'gpt-4'; toggleText.textContent = 'Model: ' + modelInUse; } // 保存原始的 fetch 函数 const originalFetch = window.fetch; // 修改的 fetch 函数 function modifiedFetch(url, init) { if (!isScriptEnabled) { return originalFetch(url, init); } try { if (init && init.method === 'POST' && init.body && init.headers['Content-Type'] === 'application/json') { let data = JSON.parse(init.body); if (data.hasOwnProperty('model')) { if (data.model === 'gpt-4' || data.model === 'gpt-4-mobile') { data.model = modelInUse; init.body = JSON.stringify(data); } else { // 如果模型不是 'gpt-4' 或 'gpt-4-mobile',则不进行切换,并更新显示的模型名称 toggleText.textContent = 'Model: ' + data.model; } } } return originalFetch(url, init); } catch (e) { console.error('在处理请求时出现错误:', e); return originalFetch(url, init); } } // 在页面加载完成后替换 fetch 函数 window.addEventListener('load', () => { window.fetch = modifiedFetch; }); })();