```// ==UserScript==
// @name        GPTative Synthesizer Fixed Tone.js Loader
// @match       *://yuntian-deng-chatgpt.hf.space/*
// @grant       none
// @run-at      document-idle
// ==/UserScript==

(async () => {
  function loadToneJS() {
    return new Promise((resolve, reject) => {
      if (window.Tone) return resolve(window.Tone);
      const script = document.createElement("script");
      script.src = "https://cdn.jsdelivr.net/npm/tone@14.8.39/build/Tone.min.js";
      script.crossOrigin = "anonymous";
      script.onload = () => resolve(window.Tone);
      script.onerror = () => reject(new Error("Tone.js failed to load"));
      document.head.appendChild(script);
    });
  }

  try {
    const Tone = await loadToneJS();
    console.log("Tone.js loaded");

    window.addEventListener("click", async () => {
      if (Tone.context.state === "suspended") {
        await Tone.start();
        console.log("Tone.js AudioContext resumed on user click");
      }
    });

    // Now you may initialize GPTative Synth logic here,
    // but always ensure Tone.context is running before playing.

  } catch (e) {
    console.error("Failed to load Tone.js:", e);
  }
})();
```


fix loader in this userscript as in that first:


```
// ==UserScript==
// @name        GPTative Synthesizer - Strict Code Block Sheet Parser
// @version     3.0
// @description Parse and synthesize strictly wrapped musical sheets inside code blocks during chat generation.
// @match       *://yuntian-deng-chatgpt.hf.space/*
// @grant       none
// @run-at      document-idle
// ==/UserScript==

(() => {
  "use strict";

  const AudioContextClass = window.AudioContext || window.webkitAudioContext;
  const audioCtx = new AudioContextClass();

  const BEGIN_TAG = "[BEGIN MUSICAL SHEET]";
  const END_TAG = "[END MUSICAL SHEET]";
  const BASE_FREQ = 432;
  const FADE_TIME = 0.05;
  const TEMPO_BPM = 90;
  const BEAT_DURATION = 60 / TEMPO_BPM;

  const DURATION_MAP = { '♩': 1 * BEAT_DURATION, '♪': 0.5 * BEAT_DURATION, '♬': 0.25 * BEAT_DURATION };
  const DYNAMICS = { pp: 0.2, p: 0.4, mp: 0.6, mf: 0.75, f: 1.0, ff: 1.3 };
  const REST_SYMBOL = '∅';

  let isGenerating = false;
  let isError = false;
  let isPlaying = false;
  let currentSheet = null;

  let osc = null;
  let gainNode = null;
  let playTimeout = null;

  // ======= State detection =======
  function updateStates() {
    const genOverlay = document.querySelector('.wrap.default.full.svelte-ls20lj.generating');
    const translucentOverlay = document.querySelector('.wrap.default.minimal.svelte-ls20lj.translucent:not(.hide)');
    const errorStatus = document.querySelector('.clear-status.svelte-ls20lj .error');
    const errorToast = document.querySelector('.toast-body.error.svelte-15qa81b');

    const genActive = !!genOverlay && !!translucentOverlay;
    const errorActive = !!errorStatus || !!errorToast;

    if (genActive !== isGenerating) {
      isGenerating = genActive;
      console.log("[GPTative] Generating state:", isGenerating);
    }
    if (errorActive !== isError) {
      isError = errorActive;
      console.log("[GPTative] Error state:", isError);
    }
  }

  // ======= Extract latest fully wrapped sheet inside code blocks =======
  function extractStrictSheetFromCodeBlocks() {
    const codeBlocks = Array.from(document.querySelectorAll('pre, code'));

    for (let i = codeBlocks.length - 1; i >= 0; i--) {
      const block = codeBlocks[i];
      const text = block.textContent || "";

      const beginIdx = text.indexOf(BEGIN_TAG);
      const endIdx = text.indexOf(END_TAG);

      if (beginIdx !== -1 && endIdx !== -1 && endIdx > beginIdx) {
        // Extract content strictly inside the tags
        const sheet = text.substring(beginIdx + BEGIN_TAG.length, endIdx).trim();
        console.log("[GPTative] Extracted musical sheet:");
        console.log(sheet);
        return sheet;
      }
    }
    return null;
  }

  // ======= Parse sheet content into events =======
  function parseSheet(sheet) {
    // Split lines and filter out metadata lines (with colon)
    const lines = sheet.split('\n').map(l => l.trim()).filter(l => l.length > 0 && !l.includes(':'));

    // Join into single musical line string
    const musicStr = lines.join(' ');

    // Tokenize by spaces and filter out empty
    const tokens = musicStr.split(/\s+/).filter(t => t.length > 0);

    const events = [];
    let currentGain = 0.25;

    for (const token of tokens) {
      // Dynamics token, e.g. [mf]
      let dynMatch = token.match(/^\[(pp|p|mp|mf|f|ff)\]$/i);
      if (dynMatch) {
        const dyn = dynMatch[1].toLowerCase();
        currentGain = DYNAMICS[dyn] || 0.25;
        continue;
      }

      // Rest token
      if (token === REST_SYMBOL) {
        events.push({ freq: null, duration: BEAT_DURATION, gain: 0 });
        continue;
      }

      // Notes tokens with possible accidentals ignored, duration symbol only ♩ ♪ ♬
      // We parse by note duration character anywhere inside the token:
      let noteMatch = token.match(/[♩♪♬]/);

      if (noteMatch) {
        const durSym = noteMatch[0];
        events.push({ freq: BASE_FREQ, duration: DURATION_MAP[durSym] || BEAT_DURATION, gain: currentGain });
        continue;
      }

      // Unknown tokens ignored silently
    }

    return events;
  }

  // ======= Play parsed events sequentially ====
  function playEvents(events) {
    if (events.length === 0) return;

    let idx = 0;

    function playNext() {
      if (idx >= events.length) {
        stopSound();
        return;
      }

      const ev = events[idx++];
      if (ev.freq === null) {
        // Rest
        if (gainNode) gainNode.gain.setTargetAtTime(0, audioCtx.currentTime + 0.01, 0.01);
        playTimeout = setTimeout(playNext, ev.duration * 1000);
        return;
      }

      if (!osc) {
        osc = audioCtx.createOscillator();
        gainNode = audioCtx.createGain();
        osc.type = "triangle";
        osc.connect(gainNode);
        gainNode.connect(audioCtx.destination);
        osc.start();
        console.log("[GPTative] Oscillator started");
      }

      osc.frequency.setTargetAtTime(ev.freq, audioCtx.currentTime, 0.01);
      gainNode.gain.cancelScheduledValues(audioCtx.currentTime);
      gainNode.gain.setValueAtTime(0, audioCtx.currentTime);
      gainNode.gain.linearRampToValueAtTime(ev.gain, audioCtx.currentTime + FADE_TIME);
      gainNode.gain.setTargetAtTime(0, audioCtx.currentTime + ev.duration - FADE_TIME, FADE_TIME);

      playTimeout = setTimeout(playNext, ev.duration * 1000);
    }

    playNext();
  }

  // ======= Stop audio gracefully ====
  function stopSound() {
    if (playTimeout) clearTimeout(playTimeout);
    playTimeout = null;
    if (gainNode) {
      gainNode.gain.linearRampToValueAtTime(0, audioCtx.currentTime + FADE_TIME);
    }
    if (osc) {
      setTimeout(() => {
        osc.stop();
        osc.disconnect();
        if (gainNode) gainNode.disconnect();
        osc = null;
        gainNode = null;
        console.log("[GPTative] Oscillator stopped");
      }, FADE_TIME * 1000);
    }
  }

  // ======= Main control loop ====
  async function controlLoop() {
    updateStates();

    if (!isGenerating) {
      if (isPlaying) {
        stopSound();
        isPlaying = false;
        currentSheet = null;
      }
      return;
    }

    const sheetText = extractStrictSheetFromCodeBlocks();
    if (!sheetText) {
      if (isPlaying) {
        stopSound();
        isPlaying = false;
        currentSheet = null;
      }
      return;
    }

    if (sheetText !== currentSheet) {
      currentSheet = sheetText;
      const events = parseSheet(sheetText);

      if (isPlaying) {
        stopSound();
      }

      isPlaying = true;

      try {
        if (audioCtx.state === 'suspended') await audioCtx.resume();
      } catch {}

      playEvents(events);
    }
  }

  // ======= Observe DOM mutations for chat changes ====
  let controlTimeout = null;
  const observer = new MutationObserver(() => {
    if (controlTimeout) clearTimeout(controlTimeout);
    controlTimeout = setTimeout(controlLoop, 150);
  });

  observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['class', 'style'] });

  // Periodic fallback
  setInterval(controlLoop, 1000);

  // User interaction to resume audio context per browser autoplay policies
  window.addEventListener('click', () => {
    if (audioCtx.state === 'suspended') {
      audioCtx.resume().then(() => console.log("[GPTative] AudioContext resumed on user interaction"));
    }
  });

  console.log("[GPTative] Synthesizer userscript loaded, waiting for musical sheets...");
})();
```

output full userscript, not first one.