```
```
```

// ==UserScript==
// @name         codecurber with true full expand & preserve formatting
// @version      1.22
// @description  Initially folded textarea preserving original formatting, toggles to full viewport overlay expansion ignoring constraints
// @match        *://yuntian-deng-chatgpt.hf.space/*
// @match        *://yuntian-deng-o1mini.hf.space/*
// @match        *://yuntian-deng-chatgpt4.hf.space/*
// @match        *://yuntian-deng-o1.hf.space/*
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  const MAX_LINES = 10;
  const LINE_HEIGHT_PX = 19.2; // approx 1.2em * 16px

  // Add styles
  const style = document.createElement('style');
  style.textContent = `
    .textarea-container {
      position: relative;
      margin: 1em 0 2.5em;
      width: 100%;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      z-index: 1;
    }
    .code-textarea {
      width: 100% !important;
      background: #1e1e1e !important;
      color: #39ff14 !important;
      border-radius: 6px !important;
      border: 1px solid #39ff14 !important;
      padding: 10px !important;
      resize: vertical !important;
      white-space: pre !important;
      overflow-y: auto !important;
      user-select: text !important;
      box-sizing: border-box !important;
      max-height: calc(${MAX_LINES} * ${LINE_HEIGHT_PX}px) !important;
      height: calc(${MAX_LINES} * ${LINE_HEIGHT_PX}px) !important;
      transition: box-shadow 0.3s ease;
      position: relative;
      z-index: 1;
    }

.fold-toggle-button {
  background: #f00;
  border: 3px solid #39ff14;
  color: #39ff14;
  padding: 6px 20px;
  font-family: 'Press Start 2P', monospace;
  text-shadow:
    1px 1px 0 #000,
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000;
  border-radius: 4px;
  box-shadow:
    inset 0 0 2px #39ff14,
    0 0 12px #39ff1444;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.fold-toggle-button:hover {
  background: #39ff14;
  color: #0f0;
  box-shadow:
    inset 0 0 6px #fff,
    0 0 16px #39ff14;
}

.folded-overlay {
  background: linear-gradient(135deg, #000000cc, #003300cc);
  box-shadow:
    0 0 30px #39ff14aa inset,
    0 0 50px #0f0f0f;
  border: 5px solid #39ff14;
  border-radius: 8px;
}

.folded-overlay textarea {
  font-family: 'Press Start 2P', monospace !important;
      height: 97vh !important;
      width: 97vw !important;
  color: #39ff14;
  background: #001100;
  border: none;
  box-shadow:
    0 0 20px #39ff1499 inset;
  padding: 1em;
  border-radius: 8px;
  caret-color: #6eff44 !important;
  transition: border 0.3s ease;
}

.folded-overlay .close-button {
  user-select: none;
  box-shadow:
    0 0 10px #39ff14cc,
    inset 0 0 6px #6eff44cc;
  border-radius: 50%;
  border: 3px solid #39ff14;
  background: #002200;
  color: #39ff14;
  transition: color 0.3s ease, background 0.3s ease;
}
.folded-overlay .close-button:hover {
  background: #39ff14;
  color: #f00;
  box-shadow:
    0 0 20px #39ff44ff,
    inset 0 0 12px #39ff66ff;
}
.folded-overlay .close-button {
  position: fixed !important;
  top: 10px !important;
  right: 10px !important;
  width: 40px;
  height: 40px;
  font-size: 28px;
  line-height: 40px;
  text-align: center;
  user-select: none;
  box-shadow:
    0 0 10px #39ff14cc,
    inset 0 0 6px #6eff44cc;
  border-radius: 50%;
  border: 3px solid #39ff14;
  background: #002200;
  color: #39ff14;
  cursor: pointer;
  transition: color 0.3s ease, background 0.3s ease;
  z-index: 1000000;
}
.folded-overlay .close-button:hover {
  background: #39ff14;
  color: #f00;
  box-shadow:
    0 0 20px #39ff44ff,
    inset 0 0 12px #39ff66ff;
}
.close-button {
  position: fixed !important;
  top: 10px !important;
  right: 10px !important;
  width: 40px;
  height: 40px;
  font-size: 28px;
  line-height: 40px;
  text-align: center;
  user-select: none;
  box-shadow:
    0 0 10px #39ff14cc,
    inset 0 0 6px #6eff44cc;
  border-radius: 50%;
  border: 3px solid #39ff14;
  background: #002200;
  color: #39ff14;
  cursor: pointer;
  transition: color 0.3s ease, background 0.3s ease;
  z-index: 1000000;
}
  `;
  document.head.appendChild(style);

  // Convert code block into textarea with folding toggle and overlay expansion
  function transformCodeBlock(codeEl) {
    if (codeEl.dataset.transformed === 'true') return;

    const text = codeEl.textContent || '';
    const lines = text.split('\n').length;
    if (lines <= MAX_LINES) return;

    codeEl.dataset.transformed = 'true';

    // Create container and textarea
    const container = document.createElement('div');
    container.className = 'textarea-container';

    const ta = document.createElement('textarea');
    ta.readOnly = true;
    ta.className = 'code-textarea';
    ta.value = text;

    // Start folded (curbed)
    ta.style.maxHeight = `${MAX_LINES * LINE_HEIGHT_PX}px`;
    ta.style.height = ta.style.maxHeight;

    // Hide original code block for copy or fallback
    codeEl.style.display = 'none';

    const parent = codeEl.parentNode;
    if (!parent) return;

    parent.insertBefore(container, codeEl);
    container.appendChild(codeEl);
    container.appendChild(ta);

    // Create toggle button
    const btn = document.createElement('button');
    btn.type = 'button';
    btn.className = 'fold-toggle-button';
    btn.textContent = 'Show full code';

    btn.addEventListener('click', () => {
      // On toggle, open fullscreen overlay that ignores all container size limits
      openOverlay(ta, btn);
    });

    container.appendChild(btn);
  }

  // Open the fullscreen overlay with full textarea content
  function openOverlay(originalTA, toggleBtn) {
    // Create overlay container
    const overlay = document.createElement('div');
    overlay.className = 'folded-overlay';

    // Create large textarea filling viewport, copy value from original textarea
    const fullTA = document.createElement('textarea');
    fullTA.readOnly = true;
    fullTA.value = originalTA.value;
    // Apply styles via CSS class .folded-overlay textarea

    // Create close button
    const closeBtn = document.createElement('button');
    closeBtn.textContent = '×';
    closeBtn.className = 'close-button';
    closeBtn.title = 'Close full code view';

    // Append children
    overlay.appendChild(fullTA);
    document.body.appendChild(overlay);
    document.body.appendChild(closeBtn);

    // Focus the fullscreen textarea and scroll to top
    fullTA.focus();
    fullTA.scrollTop = 0;

    function cleanup() {
      overlay.remove();
      closeBtn.remove();
    }

    closeBtn.addEventListener('click', () => {
      cleanup();
    });

    // Allow Esc key to close overlay
    function onKey(e) {
      if (e.key === 'Escape') {
        cleanup();
        document.removeEventListener('keydown', onKey);
      }
    }
    document.addEventListener('keydown', onKey);

    // Optional: blur original textarea so no confusion
    originalTA.blur();
  }

  function foldAllCodeBlocks() {
    const chat = document.querySelector('.bubble-wrap.svelte-gjtrl6');
    if (!chat) return;
    chat.querySelectorAll('code').forEach(transformCodeBlock);
  }

  function observeChat() {
    const chat = document.querySelector('.bubble-wrap.svelte-gjtrl6');
    if (!chat) return;

    const observer = new MutationObserver(() => {
      foldAllCodeBlocks();
    });
    observer.observe(chat, { childList: true, subtree: true });
  }

  const initInt = setInterval(() => {
    if (document.querySelector('.bubble-wrap.svelte-gjtrl6')) {
      clearInterval(initInt);
      foldAllCodeBlocks();
      observeChat();
    }
  }, 300);

})();

```
```
```