diff --git a/src/Jellyfin.Plugin.Multilang/Configuration/configPage.html b/src/Jellyfin.Plugin.Multilang/Configuration/configPage.html index 1c181ee..e9c73cd 100644 --- a/src/Jellyfin.Plugin.Multilang/Configuration/configPage.html +++ b/src/Jellyfin.Plugin.Multilang/Configuration/configPage.html @@ -157,6 +157,22 @@
+ + @@ -1030,6 +1046,14 @@ document.getElementById("ml-cache-refresh").addEventListener("click", loadCacheDiagnostics); document.getElementById("ml-cache-clear").addEventListener("click", clearCacheEntries); document.getElementById("ml-refresh-activity-refresh").addEventListener("click", loadRefreshDiagnostics); + document.getElementById("ml-debug-open").addEventListener("click", function () { + var itemId = document.getElementById("ml-debug-item-id").value.trim(); + if (!itemId) { + M.setStatus(status, "Enter a Jellyfin item ID.", true); + return; + } + window.open(M.debugUrl(itemId, document.getElementById("ml-debug-user-id").value.trim()), "_blank", "noopener"); + }); document.getElementById("ml-export-open").addEventListener("click", function () { loadExportInfo(); syncAssetCheckboxes(); M.showModal("ml-export-modal"); }); document.getElementById("ml-import-open").addEventListener("click", function () { loadExportInfo(); syncAssetCheckboxes(); M.showModal("ml-import-modal"); }); document.getElementById("ml-cleanup-open").addEventListener("click", function () { document.getElementById("ml-cleanup-confirm").checked = false; M.showModal("ml-cleanup-modal"); }); diff --git a/src/Jellyfin.Plugin.Multilang/Configuration/debugPage.html b/src/Jellyfin.Plugin.Multilang/Configuration/debugPage.html index 66a915c..f2b5e29 100644 --- a/src/Jellyfin.Plugin.Multilang/Configuration/debugPage.html +++ b/src/Jellyfin.Plugin.Multilang/Configuration/debugPage.html @@ -9,7 +9,7 @@ @@ -44,12 +44,17 @@ return match ? decodeURIComponent(match[1]) : ""; } + function targetUserId() { + return new URLSearchParams(location.search).get("userId") || ""; + } + function endpoint() { var id = encodeURIComponent(itemId()); var locale = document.documentElement.lang || navigator.language || ""; var suffix = locale ? "?mlLocale=" + encodeURIComponent(locale) : ""; - return mode.value === "stored" - ? "/Multilang/Debug/" + id + if (mode.value === "stored") return "/Multilang/Debug/" + id; + return targetUserId() + ? "/Multilang/Debug/" + id + "/" + encodeURIComponent(targetUserId()) + suffix : "/Multilang/Debug/" + id + "/self" + suffix; } @@ -193,7 +198,7 @@ async function load() { M.setStatus(status, "Loading..."); - meta.textContent = "Item: " + itemId() + " | " + mode.options[mode.selectedIndex].text; + meta.textContent = "Item: " + itemId() + " | " + mode.options[mode.selectedIndex].text + (targetUserId() ? " | User: " + targetUserId() : ""); try { var data = await M.get(endpoint()); lastJson = JSON.stringify(data, null, 2); diff --git a/src/Jellyfin.Plugin.Multilang/Configuration/shared.js b/src/Jellyfin.Plugin.Multilang/Configuration/shared.js index 048f38c..64737a6 100644 --- a/src/Jellyfin.Plugin.Multilang/Configuration/shared.js +++ b/src/Jellyfin.Plugin.Multilang/Configuration/shared.js @@ -1,4 +1,11 @@ (function () { + if (!Element.prototype.replaceChildren) { + Element.prototype.replaceChildren = function () { + this.textContent = ""; + for (let index = 0; index < arguments.length; index++) this.appendChild(arguments[index]); + }; + } + const basePath = () => { const path = window.location.pathname || ""; const marker = "/web/"; @@ -39,6 +46,15 @@ return h; } + function debugUrl(itemId, userId) { + const query = new URLSearchParams(); + const t = token() || new URLSearchParams(location.search).get("token") || new URLSearchParams(location.search).get("api_key") || ""; + if (t) query.set("token", t); + if (userId) query.set("userId", userId); + const suffix = query.toString(); + return `${basePath()}/Multilang/DebugUi/${encodeURIComponent(String(itemId || "").trim())}${suffix ? `?${suffix}` : ""}`; + } + async function request(path, options) { const response = await fetch(`${basePath()}${path}`, { cache: "no-store", @@ -144,6 +160,7 @@ get: (path) => request(path), post: (path, body) => request(path, { method: "POST", body: JSON.stringify(body) }), basePath, + debugUrl, authHeaders, splitList, setStatus, diff --git a/src/Jellyfin.Plugin.Multilang/Configuration/userRulesPage.html b/src/Jellyfin.Plugin.Multilang/Configuration/userRulesPage.html index 6206164..7a5b590 100644 --- a/src/Jellyfin.Plugin.Multilang/Configuration/userRulesPage.html +++ b/src/Jellyfin.Plugin.Multilang/Configuration/userRulesPage.html @@ -39,6 +39,18 @@ + + @@ -1264,6 +1276,14 @@ state.rules.SortLocale = $("ml-sort-locale").value || "Auto"; renderSortLocaleAutoText(); }); + $("ml-debug-open").addEventListener("click", function () { + var itemId = $("ml-debug-item-id").value.trim(); + if (!itemId) { + M.setStatus(status, "Enter a Jellyfin item ID.", true); + return; + } + window.open(M.debugUrl(itemId), "_blank", "noopener"); + }); $("ml-user-export").addEventListener("click", function () { downloadUserExport().catch(function (err) { M.setStatus(status, String(err), true); }); }); diff --git a/src/Jellyfin.Plugin.Multilang/Jellyfin.Plugin.Multilang.csproj b/src/Jellyfin.Plugin.Multilang/Jellyfin.Plugin.Multilang.csproj index 7f84afe..6c347e8 100644 --- a/src/Jellyfin.Plugin.Multilang/Jellyfin.Plugin.Multilang.csproj +++ b/src/Jellyfin.Plugin.Multilang/Jellyfin.Plugin.Multilang.csproj @@ -7,9 +7,9 @@