diff --git a/background/service-worker.js b/background/service-worker.js index c427976..6b30f12 100644 --- a/background/service-worker.js +++ b/background/service-worker.js @@ -123,7 +123,9 @@ async function updateViaHttp(apiKey, plId, data, origin) { }); const text = await res.text(); if (typeof console !== 'undefined' && console.log) { - console.log('[Chrysalis] HTTP', res.status, plId, body, text.slice(0, 200)); + const logBody = { ...body }; + if (logBody.key) logBody.key = '[REDACTED]'; + console.log('[Chrysalis] HTTP', res.status, plId, logBody, text.slice(0, 200)); } if (!res.ok) { return { success: false, error: `HTTP ${res.status}: ${text.slice(0, 150)}` }; diff --git a/setup/setup.js b/setup/setup.js index bbb1d81..8b87500 100644 --- a/setup/setup.js +++ b/setup/setup.js @@ -697,8 +697,10 @@ }; async function findMonarchTab() { - const tabs = await chrome.tabs.query({ url: MONARCH_ORIGIN + '/*' }); - return tabs.length ? tabs[0] : null; + const tabs = await chrome.tabs.query({ url: MONARCH_ORIGINS.map((o) => o + '/*') }); + if (!tabs.length) return null; + const sorted = [...tabs].sort((a, b) => (b.lastAccessed || 0) - (a.lastAccessed || 0)); + return sorted[0] || null; } function isPLAppTab(url) {