const portal = document.getElementById('portal'); const norm = document.getElementById('norm'); const status = document.getElementById('status'); chrome.storage.sync.get({ portal: '', norm: 0 }, cfg => { portal.value = cfg.portal; norm.value = cfg.norm || ''; }); document.getElementById('save').onclick = async () => { let p = portal.value.trim(); if (p) { try { p = new URL(p.includes('://') ? p : 'https://' + p).origin + '/'; } catch { status.textContent = 'Адрес портала не похож на адрес'; return; } } await chrome.storage.sync.set({ portal: p, norm: Math.max(0, Number(norm.value) || 0) }); portal.value = p; status.textContent = 'Сохранено'; };