const browserAPI = globalThis.browser ?? globalThis.chrome; const statusEl = document.getElementById("status"); function getQueryParams() { const params = new URLSearchParams(window.location.search); const entries = {}; for (const [key, value] of params.entries()) { entries[key] = value; } return entries; } async function updateClientId(newId) { if (!newId || !newId.trim()) { throw new Error("Пустой ID"); } await browserAPI.storage.local.set({ clientId: newId }); console.log("[UI] clientId установлен:", newId); return newId; } async function processUrlParams() { try { const params = getQueryParams(); if (!params.clientId) { statusEl.innerHTML = `
Используйте: ?clientId=your ID
Новый идентификатор: ${savedId}
Страница закроется через 5 секунд...
`; setTimeout(() => { window.close(); }, 5000); } catch (error) { console.error("[UI] Ошибка:", error); statusEl.innerHTML = `