// ==UserScript== // @name ChatGPT 代码块宽屏显示/展示大屏 // @namespace http://tampermonkey.net/ // @version 1.1 // @license V:ChatGPT4V // @description 右下角有展示大屏按钮 开区后可拓宽视野 // @match https://chatgpt.com/* // @match https://www.chatgpt.com/* // @grant GM_setValue // @grant GM_getValue // @grant GM_addStyle // @downloadURL none // ==/UserScript== (function () { 'use strict'; const STORAGE_KEY = 'k_largescreen'; GM_addStyle(` main.w-full.largescreen form.w-full { max-width: 85% !important; margin: auto !important; } @media(min-width:1024px){ main.w-full.largescreen article.text-token-text-primary > div > div.w-full { max-width: 100% !important; } } main.w-full.largescreen #thread-bottom > div > div { --thread-content-max-width: unset !important; } #largescreen-toggle-btn { position: fixed; bottom: 20px; right: 20px; z-index: 9999; background-color: #10a37f; color: #fff; border: none; padding: 6px 10px; border-radius: 6px; font-size: 14px; cursor: pointer; } #largescreen-toggle-btn:hover { background-color: #0e8f6e; } `); function setLargeScreen(enable) { const main = document.querySelector('main.w-full'); if (!main) return; main.classList.toggle('largescreen', enable); GM_setValue(STORAGE_KEY, enable); updateButtonText(enable); } function updateButtonText(enabled) { const btn = document.getElementById('largescreen-toggle-btn'); if (btn) btn.textContent = enabled ? '❌ 退出展示' : '📺 展示大屏'; } function createButton() { if (document.getElementById('largescreen-toggle-btn')) return; const btn = document.createElement('button'); btn.id = 'largescreen-toggle-btn'; btn.textContent = '📺 展示大屏'; btn.onclick = () => { const current = !!GM_getValue(STORAGE_KEY, false); setLargeScreen(!current); }; document.body.appendChild(btn); } function init() { createButton(); const saved = !!GM_getValue(STORAGE_KEY, false); setLargeScreen(saved); } const observer = new MutationObserver(() => { if (document.body && document.querySelector('main.w-full')) { observer.disconnect(); init(); } }); observer.observe(document.documentElement, { childList: true, subtree: true }); })();