From a7a54d35324cb17c60c4c2f61c1a710fccfec1c0 Mon Sep 17 00:00:00 2001 From: "DESKTOP-KSVGT20\\shkim" Date: Fri, 1 May 2026 17:54:57 +0900 Subject: [PATCH] Restrict Suno library detection to current user rows --- chatgpt-suno-tampermonkey.user.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/chatgpt-suno-tampermonkey.user.js b/chatgpt-suno-tampermonkey.user.js index b3e61bd..34db6af 100644 --- a/chatgpt-suno-tampermonkey.user.js +++ b/chatgpt-suno-tampermonkey.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name ChatGPT to Suno Prompt Copier // @namespace local.suno-helper -// @version 0.4.1 +// @version 0.4.2 // @description Copy structured ChatGPT song prompt versions into Suno fields. // @author local // @match https://chatgpt.com/* @@ -595,6 +595,10 @@ const style = firstValue(object, ["gpt_description_prompt", "style", "tags", "description"]); const model = firstValue(object, ["model_name", "model", "major_model_version"]); const createdAt = firstValue(object, ["created_at", "createdAt"]); + const owner = firstValue(object, ["username", "user_name", "userName", "handle", "user_handle", "userHandle", "display_name", "displayName"]); + const ownerFromUser = object.user && typeof object.user === "object" + ? firstValue(object.user, ["username", "user_name", "userName", "handle", "display_name", "displayName"]) + : ""; return { id, title, @@ -602,6 +606,7 @@ style, model, createdAt, + owner: owner || ownerFromUser, audioUrl, wavUrl, imageUrl, @@ -627,6 +632,12 @@ .trim(); } + function getCurrentSunoUsername() { + const text = document.body.innerText || ""; + const match = /([A-Za-z0-9_.-]{3,40})\s+\d+\s+credits/i.exec(text); + return match?.[1] || ""; + } + function getVisibleLibraryRows() { const rows = []; const seen = new Set(); @@ -662,7 +673,7 @@ } function trackMatchesVisibleRows(track, rows) { - if (!rows.length) return true; + if (!rows.length) return false; const title = normalizeMatchText(track.title); const style = normalizeMatchText(track.style || track.lyrics || ""); if (!title || title.length > 160) return false; @@ -674,6 +685,11 @@ }); } + function trackMatchesCurrentUser(track, username) { + if (!username || !track.owner) return true; + return normalizeMatchText(track.owner) === normalizeMatchText(username); + } + function scanSunoLibraryTracks() { const sources = readSunoDataSources(); const objects = sources.flatMap((item) => flattenObjects(item)); @@ -706,8 +722,10 @@ } const visibleRows = getVisibleLibraryRows(); + const currentUser = getCurrentSunoUsername(); return [...tracks.values()] .filter((track) => track.id || track.audioUrl || track.imageUrl) + .filter((track) => trackMatchesCurrentUser(track, currentUser)) .filter((track) => trackMatchesVisibleRows(track, visibleRows)) .sort((a, b) => String(a.title).localeCompare(String(b.title), "ko")); }