Add Suno extension diagnostics
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name ChatGPT to Suno Prompt Copier
|
||||
// @namespace local.suno-helper
|
||||
// @version 0.7.3
|
||||
// @version 0.7.4
|
||||
// @description Copy structured ChatGPT song prompt versions into Suno fields.
|
||||
// @author local
|
||||
// @match https://chatgpt.com/*
|
||||
@@ -27,6 +27,7 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
const SCRIPT_VERSION = "0.7.4";
|
||||
const STORAGE_KEY = "chatgptSunoPromptSlots";
|
||||
const SLOT_COUNT = 2;
|
||||
const isChatGPT = location.hostname.includes("chatgpt.com") || location.hostname.includes("chat.openai.com");
|
||||
@@ -205,7 +206,7 @@
|
||||
if (mode) panel.classList.add(mode);
|
||||
panel.innerHTML = `
|
||||
<div class="cgs-head">
|
||||
<span>${escapeHtml(title)}</span>
|
||||
<span>${escapeHtml(title)} <span class="cgs-muted">v${SCRIPT_VERSION}</span></span>
|
||||
<button class="cgs-btn" type="button" data-cgs-toggle>_</button>
|
||||
</div>
|
||||
<div class="cgs-body"></div>
|
||||
@@ -1077,6 +1078,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function readCompanionHealth() {
|
||||
const response = await fetch("http://127.0.0.1:17873/health", {
|
||||
method: "GET",
|
||||
cache: "no-store",
|
||||
});
|
||||
const text = await response.text();
|
||||
if (!response.ok) {
|
||||
throw new Error(`${response.status} ${response.statusText}: ${text.slice(0, 160)}`);
|
||||
}
|
||||
return tryParseJson(text) || {};
|
||||
}
|
||||
|
||||
async function bootSuno() {
|
||||
const body = createPanel("Suno Prompt Paste");
|
||||
const slots = await readSlots();
|
||||
@@ -1103,6 +1116,9 @@
|
||||
<div class="cgs-row">
|
||||
<button class="cgs-btn cgs-wide" type="button" data-cgs-test-companion>연결 테스트</button>
|
||||
</div>
|
||||
<div class="cgs-row">
|
||||
<button class="cgs-btn cgs-wide" type="button" data-cgs-copy-diagnostics>진단 복사</button>
|
||||
</div>
|
||||
<div class="cgs-row">
|
||||
<button class="cgs-btn cgs-primary cgs-wide" type="button" data-cgs-process-library>WAV + 메타데이터 다운</button>
|
||||
</div>
|
||||
@@ -1211,6 +1227,40 @@
|
||||
body.querySelector("[data-cgs-test-companion]").addEventListener("click", async () => {
|
||||
await testCompanion(body);
|
||||
});
|
||||
|
||||
body.querySelector("[data-cgs-copy-diagnostics]").addEventListener("click", async () => {
|
||||
if (!libraryTracks.length) {
|
||||
libraryTracks = scanSunoLibraryTracks();
|
||||
renderLibraryTrackSelect();
|
||||
}
|
||||
const selectedIndex = Number(libraryTrackSelect.value || 0);
|
||||
const selectedTrack = libraryTracks[selectedIndex];
|
||||
let health = {};
|
||||
let healthError = "";
|
||||
try {
|
||||
health = await readCompanionHealth();
|
||||
} catch (error) {
|
||||
healthError = error.message || String(error);
|
||||
}
|
||||
const payload = {
|
||||
scriptVersion: SCRIPT_VERSION,
|
||||
location: location.href,
|
||||
detectedTracks: libraryTracks.length,
|
||||
visibleRows: getVisibleLibraryRows().length,
|
||||
selectedIndex,
|
||||
selectedTrack: selectedTrack ? {
|
||||
id: selectedTrack.id || "",
|
||||
title: selectedTrack.title || "",
|
||||
hasWavUrl: Boolean(selectedTrack.wavUrl),
|
||||
hasImageUrl: Boolean(selectedTrack.imageUrl),
|
||||
hasLyrics: Boolean(selectedTrack.lyrics),
|
||||
} : null,
|
||||
capturedSunoResponses: capturedSunoResponses.length,
|
||||
companion: healthError ? { ok: false, error: healthError } : health,
|
||||
};
|
||||
GM_setClipboard(JSON.stringify(payload, null, 2), "text");
|
||||
setStatus(body, `진단 복사 완료: v${SCRIPT_VERSION}, 감지 ${libraryTracks.length}곡, 로컬 ${healthError ? "실패" : "OK"}`);
|
||||
});
|
||||
}
|
||||
|
||||
function safeBootSuno() {
|
||||
|
||||
Reference in New Issue
Block a user