// The one question a site ever gets asked: may it use the key (or the // wallet)? "Always allow" is remembered; the site is not asked again. const q = new URLSearchParams(location.search); const origin = q.get('origin') || ''; const kind = q.get('kind') === 'pay' ? 'pay' : 'sign'; const $ = (id) => document.getElementById(id); $('origin').textContent = origin.replace(/^https:\/\//, ''); $('what').textContent = kind === 'pay' ? 'Let this site use your wallet?' : 'Let this site use your nostr key?'; $('detail').textContent = kind === 'pay' ? 'It will be able to see your balance, create invoices and send payments without asking, within the limit you set on the wallet connection.' : 'It will be able to see your public key, sign as you and read your private messages, without asking again.'; const answer = async (choice) => { for (const b of document.querySelectorAll('button')) b.disabled = true; await chrome.runtime.sendMessage({ type: 'answer', id: q.get('id'), origin, kind, choice }); window.close(); }; $('allow').onclick = () => answer('always'); $('deny').onclick = () => answer('deny'); $('never').onclick = () => answer('never'); $('allow').focus();