OpenAI ChatGPT新版UI切换

为未获得内测权限的用户开启新版UI,本插件预计将在新版UI正视上线后失效,ChatGPT新版UI切换

目前为 2024-05-11 提交的版本。查看 最新版本

// ==UserScript==
// @name         OpenAI ChatGPT新版UI切换
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  为未获得内测权限的用户开启新版UI,本插件预计将在新版UI正视上线后失效,ChatGPT新版UI切换
// @author       树梢上有只鸟
// @match        https://chatgpt.com/*
// @match        https://chat.openai.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=chatgpt.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 添加样式
    const addStyles = () => {
        const styleSheet = document.createElement('style');
        styleSheet.type = 'text/css';
        styleSheet.innerText = `
            .modal-overlay {
                z-index: 1500;
                position: fixed;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                background-color: rgba(0, 0, 0, 0.5);
                display: flex;
                justify-content: center;
                align-items: center;
                visibility: hidden;
                opacity: 0;
                transition: all 0.3s;
            }
            .modal {
                background-color: white;
                padding: 20px;
                border-radius: 10px;
                box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
                z-index: 1001;
                position: relative;
                min-width: 300px;
                min-height: 150px;
                width: auto;
                transition: all 0.3s;
            }
            .modal>h2 {
                margin-bottom: 10px;
            }
            .close-btn, .confirm-btn, .cancel-btn {
                cursor: pointer;
                margin-top: 20px;
                transition: all 0.3s;

            }
            .close-btn {
                position: absolute;
                top: 10px;
                right: 10px;
                font-size: 16px;
                margin: 0;
                padding: 0;
                width: 20px;
                height: 20px;
                text-align: center;
                line-height: 20px;
                border-radius: 5px;
            }
            .close-btn:hover {
                background-color: #4CAF50;
                color: #fff;
            }
            .button-container {
                display: flex;
                justify-content: space-between;
            }
            .modal button {
                padding: 10px 25px;
                margin-right: 10px;
                border-radius: 10px;
                background-color: aliceblue;
            }
            .modal button:hover {
                background-color: #4CAF50;
                color: #fff;
            }
            bold {
                font-weight: bold;
            }
        `;
        document.head.appendChild(styleSheet);
    };

    // 创建并显示弹窗
    const showModal = (currentMode) => {
        const modalOverlay = document.createElement('div');
        modalOverlay.className = 'modal-overlay';
        const modal = document.createElement('div');
        modal.className = 'modal';
        modal.innerHTML = `<h2>是否切换UI模式?</h2>
                           <p>当前已 <bold>${currentMode ? '开启' : '关闭'}</bold> 新版UI</p>
                           <p>点击确定进行切换</p>
                           <div class="button-container">
                               <button class="cancel-btn">取消</button>
                               <button class="confirm-btn">确定</button>
                           </div>
                           <span class="close-btn">&times;</span>`;

        modalOverlay.appendChild(modal);
        document.body.appendChild(modalOverlay);

        const closeBtn = modal.querySelector('.close-btn');
        const confirmBtn = modal.querySelector('.confirm-btn');
        const cancelBtn = modal.querySelector('.cancel-btn');

        // 关闭弹窗
        const closeModal = () => {
            modalOverlay.style.opacity = '0';
            setTimeout(() => modalOverlay.style.visibility = 'hidden', 300);
        };

        closeBtn.addEventListener('click', closeModal);
        cancelBtn.addEventListener('click', closeModal);

        // 确认并切换模式
        confirmBtn.addEventListener('click', function() {
            if (currentMode) {
                localStorage.setItem('STATSIG_LOCAL_STORAGE_INTERNAL_STORE_OVERRIDES_V3', '{"gates":{},"configs":{},"layers":{}}');
            } else {
                localStorage.setItem('STATSIG_LOCAL_STORAGE_INTERNAL_STORE_OVERRIDES_V3', '{"gates":{"chatgpt_fruit_juice":true},"configs":{},"layers":{}}');
            }
            location.reload();
            closeModal();
        });

        modalOverlay.style.visibility = 'visible';
        modalOverlay.style.opacity = '1';
    };

    // 按钮事件处理
    const addButton = () => {
        var button = document.createElement('button');
        button.textContent = '切换UI模式';
        button.style.position = 'fixed';
        button.style.bottom = '36px';
        button.style.right = '20px';
        button.style.zIndex = '1000';
        button.style.padding = '10px 20px';
        button.style.border = 'none';
        button.style.borderRadius = '5px';
        button.style.backgroundColor = '#4CAF50';
        button.style.color = 'white';
        button.style.cursor = 'pointer';

        button.addEventListener('click', function() {
            var currentMode = localStorage.getItem('STATSIG_LOCAL_STORAGE_INTERNAL_STORE_OVERRIDES_V3');
            var isModeEnabled = currentMode && currentMode.includes('chatgpt_fruit_juice":true');
            showModal(isModeEnabled);
        });

        document.body.appendChild(button);
    };

    window.addEventListener('load', function() {
        addStyles();
        addButton();
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址