🏷️ Search for custom tailnet name offers with keywords.
at master 39 lines 1.1 kB view raw
1export default defineContentScript({ 2 matches: ['https://login.tailscale.com/admin/dns*'], 3 main() { 4 browser.runtime.onMessage.addListener((message, _sender, sendResponse) => { 5 if (message.action === 'claimToken') { 6 const { tcd, token } = message; 7 fetch('https://login.tailscale.com/admin/api/tcd', { 8 credentials: 'include', 9 headers: { 10 Accept: 'application/json, text/plain, */*', 11 'Accept-Language': 'en-US,en;q=0.5', 12 'Content-Type': 'application/json', 13 'Sec-Fetch-Site': 'same-origin', 14 }, 15 referrer: 'https://login.tailscale.com/admin/dns', 16 body: JSON.stringify({ tcd, token }), 17 method: 'POST', 18 mode: 'cors', 19 }) 20 .then((res) => res.json()) 21 .then((result) => { 22 if (result.error === 'invalid tailnet name offer token') { 23 sendResponse({ 24 success: false, 25 error: 'This tailnet token offer has expired.', 26 }); 27 return; 28 } else { 29 sendResponse({ success: true, result }); 30 } 31 }) 32 .catch((err) => { 33 sendResponse({ success: false, error: err.toString() }); 34 }); 35 return true; 36 } 37 }); 38 }, 39});