diff --git a/assets/react.svg b/assets/react.svg deleted file mode 100644 index 8e0e0f1..0000000 --- a/assets/react.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/components/Error.tsx b/components/Error.tsx index 1d95f72..75fd182 100644 --- a/components/Error.tsx +++ b/components/Error.tsx @@ -1,12 +1,12 @@ export default function Error({ error }: { error: string }) { return (
-
-

- Error -

-
-
+
+

+ Error +

+
+

{error}

diff --git a/components/ServerInfo.tsx b/components/ServerInfo.tsx index d15a5c5..dc56e6b 100644 --- a/components/ServerInfo.tsx +++ b/components/ServerInfo.tsx @@ -5,12 +5,12 @@ export default function ServerInfo({ data }: { data: ServerData }) { if (data.isBrowserResource) { return (
-
-

- Browser Resource -

-
-
+
+

+ Browser Resource +

+
+

The requested document was obtained from the local computer

@@ -22,12 +22,12 @@ export default function ServerInfo({ data }: { data: ServerData }) { if (data.isLocal) { return (
-
-

- Internal Network -

-
-
+
+

+ Internal Network +

+
+

IP Address

diff --git a/components/Spinner.tsx b/components/Spinner.tsx deleted file mode 100644 index 5e1eb1a..0000000 --- a/components/Spinner.tsx +++ /dev/null @@ -1,24 +0,0 @@ -export function Spinner({ className }: { className?: string }) { - return ( - - - - - ); - } diff --git a/entrypoints/background.ts b/entrypoints/background.ts index 57a4071..92be5f8 100644 --- a/entrypoints/background.ts +++ b/entrypoints/background.ts @@ -1,90 +1,104 @@ -import psl from 'psl'; +import psl from 'psl' + +let currentTabUrl: string | null = null + +async function resolveARecord(hostname: string): Promise { + try { + const dnsResponse = await fetch( + `https://cloudflare-dns.com/dns-query?name=${hostname}&type=A`, + { + headers: { Accept: 'application/dns-json' }, + } + ) + + if (!dnsResponse.ok) { + console.error(`DNS query failed: ${dnsResponse.status}`) + return null + } + + const dnsData = await dnsResponse.json() + return ( + dnsData.Answer?.find((entry: DNSEntry) => entry.type === 1)?.data || null + ) + } catch (error) { + console.error('Failed to fetch DNS data:', error) + return null + } +} + +async function handleTabUpdate(url: string) { + if (url === currentTabUrl) return + currentTabUrl = url + + try { + const hostname = new URL(url).hostname + const ip = await resolveARecord(hostname) + + if (!ip) { + await updateIcon(null) + return + } + + const apiResponse = await fetch(`https://ip.albert.lol/${ip}`) + const apiData = await apiResponse.json() + + await updateIcon(apiData.country || null) + } catch (error) { + console.error('Failed to handle tab update:', error) + await updateIcon(null) + } +} + +chrome.tabs.onActivated.addListener(async activeInfo => { + const tab = await chrome.tabs.get(activeInfo.tabId) + if (tab.url) await handleTabUpdate(tab.url) +}) + +chrome.tabs.onUpdated.addListener(async (_tabId, changeInfo) => { + if (changeInfo.url) await handleTabUpdate(changeInfo.url) +}) export default defineBackground({ main() { chrome.runtime.onMessage.addListener((request, _sender, sendResponse) => { if (request.type === 'FETCH_SERVER_INFO') { - (async () => { + ;(async () => { try { - const dnsResponse = await fetch(`https://dns.google/resolve?name=${request.hostname}&type=A`); - const dnsData = await dnsResponse.json(); - const ip = dnsData.Answer?.[0]?.data; - + const ip = await resolveARecord(request.hostname) if (!ip) { - sendResponse({ error: 'DNS resolution failed', data: null }); - return; + sendResponse({ error: 'DNS resolution failed', data: null }) + return } - const apiResponse = await fetch(`https://ip.albert.lol/${ip}`); - const apiData = await apiResponse.json(); + const apiResponse = await fetch(`https://ip.albert.lol/${ip}`) + const apiData = await apiResponse.json() - const parsed = psl.parse(request.hostname); - const origin = 'domain' in parsed ? parsed.domain : null; + const parsed = psl.parse(request.hostname) + const origin = 'domain' in parsed ? parsed.domain : null - await updateIcon(apiData.country); + await updateIcon(apiData.country) sendResponse({ error: null, data: { - origin: origin, + origin, ip: apiData.ip, - hostname: apiData.hostname ? apiData.hostname : "N/A", - country: apiData.country ? apiData.country : null, - city: apiData.city ? apiData.city : null, - org: apiData.org - } - }); + hostname: apiData.hostname || 'N/A', + country: apiData.country || null, + city: apiData.city || null, + org: apiData.org, + }, + }) } catch (error) { - await updateIcon(null); + await updateIcon(null) sendResponse({ error: error instanceof Error ? error.message : 'Unknown error', - data: null - }); + data: null, + }) } - })(); - return true; + })() + return true } - }); + }) }, -}); - -chrome.tabs.onActivated.addListener(async (activeInfo) => { - const tab = await chrome.tabs.get(activeInfo.tabId); - if (!tab.url) return; - - try { - const url = new URL(tab.url); - const dnsResponse = await fetch(`https://dns.google/resolve?name=${url.hostname}&type=A`); - const dnsData = await dnsResponse.json(); - const ip = dnsData.Answer?.[0]?.data; - - if (!ip) return; - - const apiResponse = await fetch(`https://ip.albert.lol/${ip}`); - const apiData = await apiResponse.json(); - - await updateIcon(apiData.country); - } catch { - await updateIcon(null); - } -}); - -chrome.tabs.onUpdated.addListener(async (_tabId, changeInfo) => { - if (!changeInfo.url) return; - - try { - const url = new URL(changeInfo.url); - const dnsResponse = await fetch(`https://dns.google/resolve?name=${url.hostname}&type=A`); - const dnsData = await dnsResponse.json(); - const ip = dnsData.Answer?.[0]?.data; - - if (!ip) return; - - const apiResponse = await fetch(`https://ip.albert.lol/${ip}`); - const apiData = await apiResponse.json(); - - await updateIcon(apiData.country); - } catch { - await updateIcon(null); - } -}); +}) diff --git a/entrypoints/content.ts b/entrypoints/content.ts deleted file mode 100644 index 264a528..0000000 --- a/entrypoints/content.ts +++ /dev/null @@ -1,6 +0,0 @@ -export default defineContentScript({ - matches: ['*://*.google.com/*'], - main() { - console.log('Hello content.'); - }, -}); diff --git a/entrypoints/popup/Popup.tsx b/entrypoints/popup/Popup.tsx index fcde764..ce6e96b 100644 --- a/entrypoints/popup/Popup.tsx +++ b/entrypoints/popup/Popup.tsx @@ -1,17 +1,8 @@ -import { Spinner } from '@/components/Spinner'; import ServerInfo from '@/components/ServerInfo'; import Error from '@/components/Error'; export default function Popup() { - const { data, loading, error } = useTabData(); - - if (loading) { - return ( -
- -
- ); - } + const { data, error } = useTabData(); if (error) { return ( diff --git a/entrypoints/popup/index.html b/entrypoints/popup/index.html index d6d892d..d42675b 100644 --- a/entrypoints/popup/index.html +++ b/entrypoints/popup/index.html @@ -1,4 +1,4 @@ - + diff --git a/hooks/useTabData.ts b/hooks/useTabData.ts index 4031d76..e32ef2e 100644 --- a/hooks/useTabData.ts +++ b/hooks/useTabData.ts @@ -1,7 +1,7 @@ export function useTabData() { - const [data, setData] = useState(null); - const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); + const [data, setData] = useState(null) + const [loading, setLoading] = useState(true) + const [error, setError] = useState(null) useEffect(() => { const fetchData = async () => { @@ -9,14 +9,13 @@ export function useTabData() { const [tab] = await chrome.tabs.query({ active: true, currentWindow: true, - }); + }) - if (!tab?.url) throw new Error('No active tab found'); + if (!tab?.url) throw new Error('No active tab found') - const url = new URL(tab.url); - const hostname = url.hostname; + const url = new URL(tab.url) + const hostname = url.hostname - // Check for browser resources if (['chrome:', 'about:', 'file:'].includes(url.protocol)) { return setData({ origin: '', @@ -26,12 +25,11 @@ export function useTabData() { city: '', org: '', isLocal: false, - isBrowserResource: true - }); + isBrowserResource: true, + }) } - // Check for internal IPs - const isInternal = isPrivateIP(hostname); + const isInternal = isPrivateIP(hostname) if (isInternal) { return setData({ origin: '', @@ -41,41 +39,39 @@ export function useTabData() { city: '', org: '', isLocal: true, - isBrowserResource: false - }); + isBrowserResource: false, + }) } const response = await chrome.runtime.sendMessage({ type: 'FETCH_SERVER_INFO', - hostname: hostname - }); + hostname: hostname, + }) if (!response) { - throw new Error('No response from background script'); + throw new Error('No response from background script') } - // Handle API errors if (response.error) { - throw new Error(response.error); + throw new Error(response.error) } - // Validate response data if (!response.data?.ip) { - throw new Error('Invalid server data received'); + throw new Error('Invalid server data received') } - setData(response.data); - setError(null); + setData(response.data) + setError(null) } catch (err) { - setError(err instanceof Error ? err.message : 'Failed to fetch data'); - setData(null); + setError(err instanceof Error ? err.message : 'Failed to fetch data') + setData(null) } finally { - setLoading(false); + setLoading(false) } - }; + } - fetchData(); - }, []); + fetchData() + }, []) - return { data, loading, error }; + return { data, loading, error } } diff --git a/public/ad.webp b/public/ad.webp new file mode 100644 index 0000000..e79f880 Binary files /dev/null and b/public/ad.webp differ diff --git a/public/ae.webp b/public/ae.webp new file mode 100644 index 0000000..8971db5 Binary files /dev/null and b/public/ae.webp differ diff --git a/public/af.webp b/public/af.webp new file mode 100644 index 0000000..b9b8626 Binary files /dev/null and b/public/af.webp differ diff --git a/public/ag.webp b/public/ag.webp new file mode 100644 index 0000000..1322475 Binary files /dev/null and b/public/ag.webp differ diff --git a/public/ai.webp b/public/ai.webp new file mode 100644 index 0000000..abbdcb5 Binary files /dev/null and b/public/ai.webp differ diff --git a/public/al.webp b/public/al.webp new file mode 100644 index 0000000..3d89160 Binary files /dev/null and b/public/al.webp differ diff --git a/public/am.webp b/public/am.webp new file mode 100644 index 0000000..a7c869b Binary files /dev/null and b/public/am.webp differ diff --git a/public/ao.webp b/public/ao.webp new file mode 100644 index 0000000..60bd866 Binary files /dev/null and b/public/ao.webp differ diff --git a/public/aq.webp b/public/aq.webp new file mode 100644 index 0000000..ac698ef Binary files /dev/null and b/public/aq.webp differ diff --git a/public/ar.webp b/public/ar.webp new file mode 100644 index 0000000..6b31871 Binary files /dev/null and b/public/ar.webp differ diff --git a/public/as.webp b/public/as.webp new file mode 100644 index 0000000..1f71b96 Binary files /dev/null and b/public/as.webp differ diff --git a/public/at.webp b/public/at.webp new file mode 100644 index 0000000..a5c882c Binary files /dev/null and b/public/at.webp differ diff --git a/public/au.webp b/public/au.webp new file mode 100644 index 0000000..fda9902 Binary files /dev/null and b/public/au.webp differ diff --git a/public/aw.webp b/public/aw.webp new file mode 100644 index 0000000..193c9e1 Binary files /dev/null and b/public/aw.webp differ diff --git a/public/ax.webp b/public/ax.webp new file mode 100644 index 0000000..a33c93f Binary files /dev/null and b/public/ax.webp differ diff --git a/public/az.webp b/public/az.webp new file mode 100644 index 0000000..45f8f7b Binary files /dev/null and b/public/az.webp differ diff --git a/public/ba.webp b/public/ba.webp new file mode 100644 index 0000000..9239054 Binary files /dev/null and b/public/ba.webp differ diff --git a/public/bb.webp b/public/bb.webp new file mode 100644 index 0000000..661c198 Binary files /dev/null and b/public/bb.webp differ diff --git a/public/bd.webp b/public/bd.webp new file mode 100644 index 0000000..7216e4e Binary files /dev/null and b/public/bd.webp differ diff --git a/public/be.webp b/public/be.webp new file mode 100644 index 0000000..5b2213b Binary files /dev/null and b/public/be.webp differ diff --git a/public/bf.webp b/public/bf.webp new file mode 100644 index 0000000..0e7e58d Binary files /dev/null and b/public/bf.webp differ diff --git a/public/bg.webp b/public/bg.webp new file mode 100644 index 0000000..197bd0c Binary files /dev/null and b/public/bg.webp differ diff --git a/public/bh.webp b/public/bh.webp new file mode 100644 index 0000000..17e5ae6 Binary files /dev/null and b/public/bh.webp differ diff --git a/public/bi.webp b/public/bi.webp new file mode 100644 index 0000000..c049a3b Binary files /dev/null and b/public/bi.webp differ diff --git a/public/bj.webp b/public/bj.webp new file mode 100644 index 0000000..f62d73f Binary files /dev/null and b/public/bj.webp differ diff --git a/public/bl.webp b/public/bl.webp new file mode 100644 index 0000000..91cabbb Binary files /dev/null and b/public/bl.webp differ diff --git a/public/bm.webp b/public/bm.webp new file mode 100644 index 0000000..79b3ee2 Binary files /dev/null and b/public/bm.webp differ diff --git a/public/bn.webp b/public/bn.webp new file mode 100644 index 0000000..bfe45ba Binary files /dev/null and b/public/bn.webp differ diff --git a/public/bo.webp b/public/bo.webp new file mode 100644 index 0000000..fe45b06 Binary files /dev/null and b/public/bo.webp differ diff --git a/public/bq.webp b/public/bq.webp new file mode 100644 index 0000000..b6234b1 Binary files /dev/null and b/public/bq.webp differ diff --git a/public/br.webp b/public/br.webp new file mode 100644 index 0000000..da70f6c Binary files /dev/null and b/public/br.webp differ diff --git a/public/bs.webp b/public/bs.webp new file mode 100644 index 0000000..72edb07 Binary files /dev/null and b/public/bs.webp differ diff --git a/public/bt.webp b/public/bt.webp new file mode 100644 index 0000000..67c7794 Binary files /dev/null and b/public/bt.webp differ diff --git a/public/bv.webp b/public/bv.webp new file mode 100644 index 0000000..0d8ffbd Binary files /dev/null and b/public/bv.webp differ diff --git a/public/bw.webp b/public/bw.webp new file mode 100644 index 0000000..2033a8b Binary files /dev/null and b/public/bw.webp differ diff --git a/public/by.webp b/public/by.webp new file mode 100644 index 0000000..194699d Binary files /dev/null and b/public/by.webp differ diff --git a/public/bz.webp b/public/bz.webp new file mode 100644 index 0000000..1edfda5 Binary files /dev/null and b/public/bz.webp differ diff --git a/public/ca.webp b/public/ca.webp new file mode 100644 index 0000000..61ecb3a Binary files /dev/null and b/public/ca.webp differ diff --git a/public/cc.webp b/public/cc.webp new file mode 100644 index 0000000..7dc5846 Binary files /dev/null and b/public/cc.webp differ diff --git a/public/cd.webp b/public/cd.webp new file mode 100644 index 0000000..d29d4f7 Binary files /dev/null and b/public/cd.webp differ diff --git a/public/cf.webp b/public/cf.webp new file mode 100644 index 0000000..9c1bb67 Binary files /dev/null and b/public/cf.webp differ diff --git a/public/cg.webp b/public/cg.webp new file mode 100644 index 0000000..3140d43 Binary files /dev/null and b/public/cg.webp differ diff --git a/public/ch.webp b/public/ch.webp new file mode 100644 index 0000000..ea350a1 Binary files /dev/null and b/public/ch.webp differ diff --git a/public/ci.webp b/public/ci.webp new file mode 100644 index 0000000..c22b978 Binary files /dev/null and b/public/ci.webp differ diff --git a/public/ck.webp b/public/ck.webp new file mode 100644 index 0000000..9c51d6c Binary files /dev/null and b/public/ck.webp differ diff --git a/public/cl.webp b/public/cl.webp new file mode 100644 index 0000000..ac0e3ed Binary files /dev/null and b/public/cl.webp differ diff --git a/public/cm.webp b/public/cm.webp new file mode 100644 index 0000000..f81585b Binary files /dev/null and b/public/cm.webp differ diff --git a/public/cn.webp b/public/cn.webp new file mode 100644 index 0000000..56fb4a0 Binary files /dev/null and b/public/cn.webp differ diff --git a/public/co.webp b/public/co.webp new file mode 100644 index 0000000..9419e5d Binary files /dev/null and b/public/co.webp differ diff --git a/public/cr.webp b/public/cr.webp new file mode 100644 index 0000000..92b0e5f Binary files /dev/null and b/public/cr.webp differ diff --git a/public/cu.webp b/public/cu.webp new file mode 100644 index 0000000..9d2da9b Binary files /dev/null and b/public/cu.webp differ diff --git a/public/cv.webp b/public/cv.webp new file mode 100644 index 0000000..2b35a77 Binary files /dev/null and b/public/cv.webp differ diff --git a/public/cw.webp b/public/cw.webp new file mode 100644 index 0000000..d776f77 Binary files /dev/null and b/public/cw.webp differ diff --git a/public/cx.webp b/public/cx.webp new file mode 100644 index 0000000..2657966 Binary files /dev/null and b/public/cx.webp differ diff --git a/public/cy.webp b/public/cy.webp new file mode 100644 index 0000000..e98a3a4 Binary files /dev/null and b/public/cy.webp differ diff --git a/public/cz.webp b/public/cz.webp new file mode 100644 index 0000000..7a12726 Binary files /dev/null and b/public/cz.webp differ diff --git a/public/de.webp b/public/de.webp new file mode 100644 index 0000000..a6cd8f1 Binary files /dev/null and b/public/de.webp differ diff --git a/public/dj.webp b/public/dj.webp new file mode 100644 index 0000000..ad151b6 Binary files /dev/null and b/public/dj.webp differ diff --git a/public/dk.webp b/public/dk.webp new file mode 100644 index 0000000..c2ad67a Binary files /dev/null and b/public/dk.webp differ diff --git a/public/dm.webp b/public/dm.webp new file mode 100644 index 0000000..f78cf0c Binary files /dev/null and b/public/dm.webp differ diff --git a/public/do.webp b/public/do.webp new file mode 100644 index 0000000..5aade76 Binary files /dev/null and b/public/do.webp differ diff --git a/public/dz.webp b/public/dz.webp new file mode 100644 index 0000000..170a8db Binary files /dev/null and b/public/dz.webp differ diff --git a/public/ec.webp b/public/ec.webp new file mode 100644 index 0000000..cbf2e23 Binary files /dev/null and b/public/ec.webp differ diff --git a/public/ee.webp b/public/ee.webp new file mode 100644 index 0000000..5ce1ca2 Binary files /dev/null and b/public/ee.webp differ diff --git a/public/eg.webp b/public/eg.webp new file mode 100644 index 0000000..d2ca937 Binary files /dev/null and b/public/eg.webp differ diff --git a/public/eh.webp b/public/eh.webp new file mode 100644 index 0000000..53e958f Binary files /dev/null and b/public/eh.webp differ diff --git a/public/er.webp b/public/er.webp new file mode 100644 index 0000000..9155690 Binary files /dev/null and b/public/er.webp differ diff --git a/public/es.webp b/public/es.webp new file mode 100644 index 0000000..0c8de25 Binary files /dev/null and b/public/es.webp differ diff --git a/public/et.webp b/public/et.webp new file mode 100644 index 0000000..3ae8c3e Binary files /dev/null and b/public/et.webp differ diff --git a/public/fi.webp b/public/fi.webp new file mode 100644 index 0000000..d836b1f Binary files /dev/null and b/public/fi.webp differ diff --git a/public/fj.webp b/public/fj.webp new file mode 100644 index 0000000..5c73313 Binary files /dev/null and b/public/fj.webp differ diff --git a/public/fk.webp b/public/fk.webp new file mode 100644 index 0000000..db964d8 Binary files /dev/null and b/public/fk.webp differ diff --git a/public/fm.webp b/public/fm.webp new file mode 100644 index 0000000..a0e97cc Binary files /dev/null and b/public/fm.webp differ diff --git a/public/fo.webp b/public/fo.webp new file mode 100644 index 0000000..2f1ebf6 Binary files /dev/null and b/public/fo.webp differ diff --git a/public/fr.webp b/public/fr.webp new file mode 100644 index 0000000..3bdc976 Binary files /dev/null and b/public/fr.webp differ diff --git a/public/ga.webp b/public/ga.webp new file mode 100644 index 0000000..6c190b2 Binary files /dev/null and b/public/ga.webp differ diff --git a/public/gb-eng.webp b/public/gb-eng.webp new file mode 100644 index 0000000..71a4034 Binary files /dev/null and b/public/gb-eng.webp differ diff --git a/public/gb-nir.webp b/public/gb-nir.webp new file mode 100644 index 0000000..6239429 Binary files /dev/null and b/public/gb-nir.webp differ diff --git a/public/gb-sct.webp b/public/gb-sct.webp new file mode 100644 index 0000000..2bab76b Binary files /dev/null and b/public/gb-sct.webp differ diff --git a/public/gb-wls.webp b/public/gb-wls.webp new file mode 100644 index 0000000..bde3861 Binary files /dev/null and b/public/gb-wls.webp differ diff --git a/public/gb.webp b/public/gb.webp new file mode 100644 index 0000000..99688cc Binary files /dev/null and b/public/gb.webp differ diff --git a/public/gd.webp b/public/gd.webp new file mode 100644 index 0000000..a47a5a9 Binary files /dev/null and b/public/gd.webp differ diff --git a/public/ge.webp b/public/ge.webp new file mode 100644 index 0000000..6115486 Binary files /dev/null and b/public/ge.webp differ diff --git a/public/gf.webp b/public/gf.webp new file mode 100644 index 0000000..4992e01 Binary files /dev/null and b/public/gf.webp differ diff --git a/public/gg.webp b/public/gg.webp new file mode 100644 index 0000000..20642c1 Binary files /dev/null and b/public/gg.webp differ diff --git a/public/gh.webp b/public/gh.webp new file mode 100644 index 0000000..4dbea72 Binary files /dev/null and b/public/gh.webp differ diff --git a/public/gi.webp b/public/gi.webp new file mode 100644 index 0000000..9dc37e3 Binary files /dev/null and b/public/gi.webp differ diff --git a/public/gl.webp b/public/gl.webp new file mode 100644 index 0000000..b930374 Binary files /dev/null and b/public/gl.webp differ diff --git a/public/gm.webp b/public/gm.webp new file mode 100644 index 0000000..0ea4098 Binary files /dev/null and b/public/gm.webp differ diff --git a/public/gn.webp b/public/gn.webp new file mode 100644 index 0000000..a81610c Binary files /dev/null and b/public/gn.webp differ diff --git a/public/gp.webp b/public/gp.webp new file mode 100644 index 0000000..f30a745 Binary files /dev/null and b/public/gp.webp differ diff --git a/public/gq.webp b/public/gq.webp new file mode 100644 index 0000000..b548248 Binary files /dev/null and b/public/gq.webp differ diff --git a/public/gr.webp b/public/gr.webp new file mode 100644 index 0000000..fe3676b Binary files /dev/null and b/public/gr.webp differ diff --git a/public/gs.webp b/public/gs.webp new file mode 100644 index 0000000..5445cc2 Binary files /dev/null and b/public/gs.webp differ diff --git a/public/gt.webp b/public/gt.webp new file mode 100644 index 0000000..efe9802 Binary files /dev/null and b/public/gt.webp differ diff --git a/public/gu.webp b/public/gu.webp new file mode 100644 index 0000000..c69b332 Binary files /dev/null and b/public/gu.webp differ diff --git a/public/gw.webp b/public/gw.webp new file mode 100644 index 0000000..9ff788c Binary files /dev/null and b/public/gw.webp differ diff --git a/public/gy.webp b/public/gy.webp new file mode 100644 index 0000000..e65e952 Binary files /dev/null and b/public/gy.webp differ diff --git a/public/hk.webp b/public/hk.webp new file mode 100644 index 0000000..4d2e00c Binary files /dev/null and b/public/hk.webp differ diff --git a/public/hm.webp b/public/hm.webp new file mode 100644 index 0000000..b2fbd1b Binary files /dev/null and b/public/hm.webp differ diff --git a/public/hn.webp b/public/hn.webp new file mode 100644 index 0000000..088eea2 Binary files /dev/null and b/public/hn.webp differ diff --git a/public/hr.webp b/public/hr.webp new file mode 100644 index 0000000..2449dbd Binary files /dev/null and b/public/hr.webp differ diff --git a/public/ht.webp b/public/ht.webp new file mode 100644 index 0000000..9503ea9 Binary files /dev/null and b/public/ht.webp differ diff --git a/public/hu.webp b/public/hu.webp new file mode 100644 index 0000000..03ceaa4 Binary files /dev/null and b/public/hu.webp differ diff --git a/public/icon/128.png b/public/icon/128.png deleted file mode 100644 index 9e35d13..0000000 Binary files a/public/icon/128.png and /dev/null differ diff --git a/public/icon/16.png b/public/icon/16.png deleted file mode 100644 index cd09f8c..0000000 Binary files a/public/icon/16.png and /dev/null differ diff --git a/public/icon/32.png b/public/icon/32.png deleted file mode 100644 index f51ce1b..0000000 Binary files a/public/icon/32.png and /dev/null differ diff --git a/public/icon/48.png b/public/icon/48.png deleted file mode 100644 index cb7a449..0000000 Binary files a/public/icon/48.png and /dev/null differ diff --git a/public/icon/96.png b/public/icon/96.png deleted file mode 100644 index c28ad52..0000000 Binary files a/public/icon/96.png and /dev/null differ diff --git a/public/id.webp b/public/id.webp new file mode 100644 index 0000000..39b7aa3 Binary files /dev/null and b/public/id.webp differ diff --git a/public/ie.webp b/public/ie.webp new file mode 100644 index 0000000..cffcba4 Binary files /dev/null and b/public/ie.webp differ diff --git a/public/il.webp b/public/il.webp new file mode 100644 index 0000000..32e5d1b Binary files /dev/null and b/public/il.webp differ diff --git a/public/im.webp b/public/im.webp new file mode 100644 index 0000000..6a57114 Binary files /dev/null and b/public/im.webp differ diff --git a/public/in.webp b/public/in.webp new file mode 100644 index 0000000..e51edbe Binary files /dev/null and b/public/in.webp differ diff --git a/public/io.webp b/public/io.webp new file mode 100644 index 0000000..845591d Binary files /dev/null and b/public/io.webp differ diff --git a/public/iq.webp b/public/iq.webp new file mode 100644 index 0000000..6fee7ba Binary files /dev/null and b/public/iq.webp differ diff --git a/public/ir.webp b/public/ir.webp new file mode 100644 index 0000000..4e3cd2d Binary files /dev/null and b/public/ir.webp differ diff --git a/public/is.webp b/public/is.webp new file mode 100644 index 0000000..cbc73cd Binary files /dev/null and b/public/is.webp differ diff --git a/public/it.webp b/public/it.webp new file mode 100644 index 0000000..a594472 Binary files /dev/null and b/public/it.webp differ diff --git a/public/je.webp b/public/je.webp new file mode 100644 index 0000000..16d40e3 Binary files /dev/null and b/public/je.webp differ diff --git a/public/jm.webp b/public/jm.webp new file mode 100644 index 0000000..a110fe7 Binary files /dev/null and b/public/jm.webp differ diff --git a/public/jo.webp b/public/jo.webp new file mode 100644 index 0000000..85b7ed3 Binary files /dev/null and b/public/jo.webp differ diff --git a/public/jp.webp b/public/jp.webp new file mode 100644 index 0000000..bb25bbe Binary files /dev/null and b/public/jp.webp differ diff --git a/public/ke.webp b/public/ke.webp new file mode 100644 index 0000000..6e8364d Binary files /dev/null and b/public/ke.webp differ diff --git a/public/kg.webp b/public/kg.webp new file mode 100644 index 0000000..27a548f Binary files /dev/null and b/public/kg.webp differ diff --git a/public/kh.webp b/public/kh.webp new file mode 100644 index 0000000..6f32322 Binary files /dev/null and b/public/kh.webp differ diff --git a/public/ki.webp b/public/ki.webp new file mode 100644 index 0000000..6becbcb Binary files /dev/null and b/public/ki.webp differ diff --git a/public/km.webp b/public/km.webp new file mode 100644 index 0000000..a42493a Binary files /dev/null and b/public/km.webp differ diff --git a/public/kn.webp b/public/kn.webp new file mode 100644 index 0000000..3a003e8 Binary files /dev/null and b/public/kn.webp differ diff --git a/public/kp.webp b/public/kp.webp new file mode 100644 index 0000000..d2db30c Binary files /dev/null and b/public/kp.webp differ diff --git a/public/kr.webp b/public/kr.webp new file mode 100644 index 0000000..d197a46 Binary files /dev/null and b/public/kr.webp differ diff --git a/public/kw.webp b/public/kw.webp new file mode 100644 index 0000000..4c61889 Binary files /dev/null and b/public/kw.webp differ diff --git a/public/ky.webp b/public/ky.webp new file mode 100644 index 0000000..9d4ae31 Binary files /dev/null and b/public/ky.webp differ diff --git a/public/kz.webp b/public/kz.webp new file mode 100644 index 0000000..3938a7c Binary files /dev/null and b/public/kz.webp differ diff --git a/public/la.webp b/public/la.webp new file mode 100644 index 0000000..e4ceacd Binary files /dev/null and b/public/la.webp differ diff --git a/public/lb.webp b/public/lb.webp new file mode 100644 index 0000000..6ba2b40 Binary files /dev/null and b/public/lb.webp differ diff --git a/public/lc.webp b/public/lc.webp new file mode 100644 index 0000000..c09748d Binary files /dev/null and b/public/lc.webp differ diff --git a/public/li.webp b/public/li.webp new file mode 100644 index 0000000..7d81fa5 Binary files /dev/null and b/public/li.webp differ diff --git a/public/lk.webp b/public/lk.webp new file mode 100644 index 0000000..3428f14 Binary files /dev/null and b/public/lk.webp differ diff --git a/public/lr.webp b/public/lr.webp new file mode 100644 index 0000000..ee57144 Binary files /dev/null and b/public/lr.webp differ diff --git a/public/ls.webp b/public/ls.webp new file mode 100644 index 0000000..fcae156 Binary files /dev/null and b/public/ls.webp differ diff --git a/public/lt.webp b/public/lt.webp new file mode 100644 index 0000000..898175b Binary files /dev/null and b/public/lt.webp differ diff --git a/public/lu.webp b/public/lu.webp new file mode 100644 index 0000000..902507f Binary files /dev/null and b/public/lu.webp differ diff --git a/public/lv.webp b/public/lv.webp new file mode 100644 index 0000000..5ccc64d Binary files /dev/null and b/public/lv.webp differ diff --git a/public/ly.webp b/public/ly.webp new file mode 100644 index 0000000..4b51215 Binary files /dev/null and b/public/ly.webp differ diff --git a/public/ma.webp b/public/ma.webp new file mode 100644 index 0000000..d2fad4b Binary files /dev/null and b/public/ma.webp differ diff --git a/public/mc.webp b/public/mc.webp new file mode 100644 index 0000000..a11c4b7 Binary files /dev/null and b/public/mc.webp differ diff --git a/public/md.webp b/public/md.webp new file mode 100644 index 0000000..ee91350 Binary files /dev/null and b/public/md.webp differ diff --git a/public/me.webp b/public/me.webp new file mode 100644 index 0000000..7ba3a14 Binary files /dev/null and b/public/me.webp differ diff --git a/public/mf.webp b/public/mf.webp new file mode 100644 index 0000000..3bdc976 Binary files /dev/null and b/public/mf.webp differ diff --git a/public/mg.webp b/public/mg.webp new file mode 100644 index 0000000..abf6882 Binary files /dev/null and b/public/mg.webp differ diff --git a/public/mh.webp b/public/mh.webp new file mode 100644 index 0000000..856b632 Binary files /dev/null and b/public/mh.webp differ diff --git a/public/mk.webp b/public/mk.webp new file mode 100644 index 0000000..28144fa Binary files /dev/null and b/public/mk.webp differ diff --git a/public/ml.webp b/public/ml.webp new file mode 100644 index 0000000..dc5c55d Binary files /dev/null and b/public/ml.webp differ diff --git a/public/mm.webp b/public/mm.webp new file mode 100644 index 0000000..6f2341d Binary files /dev/null and b/public/mm.webp differ diff --git a/public/mn.webp b/public/mn.webp new file mode 100644 index 0000000..aa11e5b Binary files /dev/null and b/public/mn.webp differ diff --git a/public/mo.webp b/public/mo.webp new file mode 100644 index 0000000..4824d07 Binary files /dev/null and b/public/mo.webp differ diff --git a/public/mp.webp b/public/mp.webp new file mode 100644 index 0000000..4c7972c Binary files /dev/null and b/public/mp.webp differ diff --git a/public/mq.webp b/public/mq.webp new file mode 100644 index 0000000..ec2fc29 Binary files /dev/null and b/public/mq.webp differ diff --git a/public/mr.webp b/public/mr.webp new file mode 100644 index 0000000..a8945e4 Binary files /dev/null and b/public/mr.webp differ diff --git a/public/ms.webp b/public/ms.webp new file mode 100644 index 0000000..2ed3bee Binary files /dev/null and b/public/ms.webp differ diff --git a/public/mt.webp b/public/mt.webp new file mode 100644 index 0000000..b2f3ff2 Binary files /dev/null and b/public/mt.webp differ diff --git a/public/mu.webp b/public/mu.webp new file mode 100644 index 0000000..7c92747 Binary files /dev/null and b/public/mu.webp differ diff --git a/public/mv.webp b/public/mv.webp new file mode 100644 index 0000000..97dcc38 Binary files /dev/null and b/public/mv.webp differ diff --git a/public/mw.webp b/public/mw.webp new file mode 100644 index 0000000..9151082 Binary files /dev/null and b/public/mw.webp differ diff --git a/public/mx.webp b/public/mx.webp new file mode 100644 index 0000000..18f618d Binary files /dev/null and b/public/mx.webp differ diff --git a/public/my.webp b/public/my.webp new file mode 100644 index 0000000..3e468cb Binary files /dev/null and b/public/my.webp differ diff --git a/public/mz.webp b/public/mz.webp new file mode 100644 index 0000000..9093a89 Binary files /dev/null and b/public/mz.webp differ diff --git a/public/na.webp b/public/na.webp new file mode 100644 index 0000000..1b82997 Binary files /dev/null and b/public/na.webp differ diff --git a/public/nc.webp b/public/nc.webp new file mode 100644 index 0000000..9f41dea Binary files /dev/null and b/public/nc.webp differ diff --git a/public/ne.webp b/public/ne.webp new file mode 100644 index 0000000..e20733b Binary files /dev/null and b/public/ne.webp differ diff --git a/public/nf.webp b/public/nf.webp new file mode 100644 index 0000000..87cac9b Binary files /dev/null and b/public/nf.webp differ diff --git a/public/ng.webp b/public/ng.webp new file mode 100644 index 0000000..d17c16c Binary files /dev/null and b/public/ng.webp differ diff --git a/public/ni.webp b/public/ni.webp new file mode 100644 index 0000000..b360825 Binary files /dev/null and b/public/ni.webp differ diff --git a/public/nl.webp b/public/nl.webp new file mode 100644 index 0000000..bb952e2 Binary files /dev/null and b/public/nl.webp differ diff --git a/public/no.webp b/public/no.webp new file mode 100644 index 0000000..0d8ffbd Binary files /dev/null and b/public/no.webp differ diff --git a/public/np.webp b/public/np.webp new file mode 100644 index 0000000..311de0c Binary files /dev/null and b/public/np.webp differ diff --git a/public/nr.webp b/public/nr.webp new file mode 100644 index 0000000..f9bfdfd Binary files /dev/null and b/public/nr.webp differ diff --git a/public/nu.webp b/public/nu.webp new file mode 100644 index 0000000..01b41b5 Binary files /dev/null and b/public/nu.webp differ diff --git a/public/nz.webp b/public/nz.webp new file mode 100644 index 0000000..2f2dcd1 Binary files /dev/null and b/public/nz.webp differ diff --git a/public/om.webp b/public/om.webp new file mode 100644 index 0000000..32a7c44 Binary files /dev/null and b/public/om.webp differ diff --git a/public/pa.webp b/public/pa.webp new file mode 100644 index 0000000..2010a50 Binary files /dev/null and b/public/pa.webp differ diff --git a/public/pe.webp b/public/pe.webp new file mode 100644 index 0000000..af4bda4 Binary files /dev/null and b/public/pe.webp differ diff --git a/public/pf.webp b/public/pf.webp new file mode 100644 index 0000000..b9962cd Binary files /dev/null and b/public/pf.webp differ diff --git a/public/pg.webp b/public/pg.webp new file mode 100644 index 0000000..2fcd901 Binary files /dev/null and b/public/pg.webp differ diff --git a/public/ph.webp b/public/ph.webp new file mode 100644 index 0000000..016e09d Binary files /dev/null and b/public/ph.webp differ diff --git a/public/pk.webp b/public/pk.webp new file mode 100644 index 0000000..7eb2a92 Binary files /dev/null and b/public/pk.webp differ diff --git a/public/pl.webp b/public/pl.webp new file mode 100644 index 0000000..5a49724 Binary files /dev/null and b/public/pl.webp differ diff --git a/public/pm.webp b/public/pm.webp new file mode 100644 index 0000000..1883d20 Binary files /dev/null and b/public/pm.webp differ diff --git a/public/pn.webp b/public/pn.webp new file mode 100644 index 0000000..b9321c8 Binary files /dev/null and b/public/pn.webp differ diff --git a/public/pr.webp b/public/pr.webp new file mode 100644 index 0000000..35b648b Binary files /dev/null and b/public/pr.webp differ diff --git a/public/ps.webp b/public/ps.webp new file mode 100644 index 0000000..3058be9 Binary files /dev/null and b/public/ps.webp differ diff --git a/public/pt.webp b/public/pt.webp new file mode 100644 index 0000000..c1349bd Binary files /dev/null and b/public/pt.webp differ diff --git a/public/pw.webp b/public/pw.webp new file mode 100644 index 0000000..7d51a5f Binary files /dev/null and b/public/pw.webp differ diff --git a/public/py.webp b/public/py.webp new file mode 100644 index 0000000..995d460 Binary files /dev/null and b/public/py.webp differ diff --git a/public/qa.webp b/public/qa.webp new file mode 100644 index 0000000..38e1051 Binary files /dev/null and b/public/qa.webp differ diff --git a/public/re.webp b/public/re.webp new file mode 100644 index 0000000..9724d7b Binary files /dev/null and b/public/re.webp differ diff --git a/public/ro.webp b/public/ro.webp new file mode 100644 index 0000000..fe4bf05 Binary files /dev/null and b/public/ro.webp differ diff --git a/public/rs.webp b/public/rs.webp new file mode 100644 index 0000000..067538b Binary files /dev/null and b/public/rs.webp differ diff --git a/public/ru.webp b/public/ru.webp new file mode 100644 index 0000000..03a91fb Binary files /dev/null and b/public/ru.webp differ diff --git a/public/rw.webp b/public/rw.webp new file mode 100644 index 0000000..f5b4779 Binary files /dev/null and b/public/rw.webp differ diff --git a/public/sa.webp b/public/sa.webp new file mode 100644 index 0000000..4c7664a Binary files /dev/null and b/public/sa.webp differ diff --git a/public/sb.webp b/public/sb.webp new file mode 100644 index 0000000..e51497e Binary files /dev/null and b/public/sb.webp differ diff --git a/public/sc.webp b/public/sc.webp new file mode 100644 index 0000000..74c051c Binary files /dev/null and b/public/sc.webp differ diff --git a/public/sd.webp b/public/sd.webp new file mode 100644 index 0000000..071821a Binary files /dev/null and b/public/sd.webp differ diff --git a/public/se.webp b/public/se.webp new file mode 100644 index 0000000..9ae150d Binary files /dev/null and b/public/se.webp differ diff --git a/public/sg.webp b/public/sg.webp new file mode 100644 index 0000000..765b5ca Binary files /dev/null and b/public/sg.webp differ diff --git a/public/sh.webp b/public/sh.webp new file mode 100644 index 0000000..b8b2710 Binary files /dev/null and b/public/sh.webp differ diff --git a/public/si.webp b/public/si.webp new file mode 100644 index 0000000..9f6153b Binary files /dev/null and b/public/si.webp differ diff --git a/public/sj.webp b/public/sj.webp new file mode 100644 index 0000000..0d8ffbd Binary files /dev/null and b/public/sj.webp differ diff --git a/public/sk.webp b/public/sk.webp new file mode 100644 index 0000000..00b6f4c Binary files /dev/null and b/public/sk.webp differ diff --git a/public/sl.webp b/public/sl.webp new file mode 100644 index 0000000..e1c29a2 Binary files /dev/null and b/public/sl.webp differ diff --git a/public/sm.webp b/public/sm.webp new file mode 100644 index 0000000..c446628 Binary files /dev/null and b/public/sm.webp differ diff --git a/public/sn.webp b/public/sn.webp new file mode 100644 index 0000000..31fa36e Binary files /dev/null and b/public/sn.webp differ diff --git a/public/so.webp b/public/so.webp new file mode 100644 index 0000000..ffd18fb Binary files /dev/null and b/public/so.webp differ diff --git a/public/sr.webp b/public/sr.webp new file mode 100644 index 0000000..6b9ba74 Binary files /dev/null and b/public/sr.webp differ diff --git a/public/ss.webp b/public/ss.webp new file mode 100644 index 0000000..c3cfc7c Binary files /dev/null and b/public/ss.webp differ diff --git a/public/st.webp b/public/st.webp new file mode 100644 index 0000000..8b6dde2 Binary files /dev/null and b/public/st.webp differ diff --git a/public/sv.webp b/public/sv.webp new file mode 100644 index 0000000..b863ee3 Binary files /dev/null and b/public/sv.webp differ diff --git a/public/sx.webp b/public/sx.webp new file mode 100644 index 0000000..6292a2f Binary files /dev/null and b/public/sx.webp differ diff --git a/public/sy.webp b/public/sy.webp new file mode 100644 index 0000000..26f38e6 Binary files /dev/null and b/public/sy.webp differ diff --git a/public/sz.webp b/public/sz.webp new file mode 100644 index 0000000..940d9af Binary files /dev/null and b/public/sz.webp differ diff --git a/public/tc.webp b/public/tc.webp new file mode 100644 index 0000000..814cca8 Binary files /dev/null and b/public/tc.webp differ diff --git a/public/td.webp b/public/td.webp new file mode 100644 index 0000000..6cd1a47 Binary files /dev/null and b/public/td.webp differ diff --git a/public/tf.webp b/public/tf.webp new file mode 100644 index 0000000..3c766e3 Binary files /dev/null and b/public/tf.webp differ diff --git a/public/tg.webp b/public/tg.webp new file mode 100644 index 0000000..b7ea0da Binary files /dev/null and b/public/tg.webp differ diff --git a/public/th.webp b/public/th.webp new file mode 100644 index 0000000..f14c3ea Binary files /dev/null and b/public/th.webp differ diff --git a/public/tj.webp b/public/tj.webp new file mode 100644 index 0000000..831ec11 Binary files /dev/null and b/public/tj.webp differ diff --git a/public/tk.webp b/public/tk.webp new file mode 100644 index 0000000..7e37adf Binary files /dev/null and b/public/tk.webp differ diff --git a/public/tl.webp b/public/tl.webp new file mode 100644 index 0000000..f42ab90 Binary files /dev/null and b/public/tl.webp differ diff --git a/public/tm.webp b/public/tm.webp new file mode 100644 index 0000000..9482a69 Binary files /dev/null and b/public/tm.webp differ diff --git a/public/tn.webp b/public/tn.webp new file mode 100644 index 0000000..4b3f278 Binary files /dev/null and b/public/tn.webp differ diff --git a/public/to.webp b/public/to.webp new file mode 100644 index 0000000..e6451b1 Binary files /dev/null and b/public/to.webp differ diff --git a/public/tr.webp b/public/tr.webp new file mode 100644 index 0000000..e23fa82 Binary files /dev/null and b/public/tr.webp differ diff --git a/public/tt.webp b/public/tt.webp new file mode 100644 index 0000000..b067b6b Binary files /dev/null and b/public/tt.webp differ diff --git a/public/tv.webp b/public/tv.webp new file mode 100644 index 0000000..f8ece9f Binary files /dev/null and b/public/tv.webp differ diff --git a/public/tw.webp b/public/tw.webp new file mode 100644 index 0000000..2f3140c Binary files /dev/null and b/public/tw.webp differ diff --git a/public/tz.webp b/public/tz.webp new file mode 100644 index 0000000..a8552eb Binary files /dev/null and b/public/tz.webp differ diff --git a/public/ua.webp b/public/ua.webp new file mode 100644 index 0000000..1d6d8c4 Binary files /dev/null and b/public/ua.webp differ diff --git a/public/ug.webp b/public/ug.webp new file mode 100644 index 0000000..9bbd643 Binary files /dev/null and b/public/ug.webp differ diff --git a/public/um.webp b/public/um.webp new file mode 100644 index 0000000..ffeb074 Binary files /dev/null and b/public/um.webp differ diff --git a/public/unknown.webp b/public/unknown.webp new file mode 100644 index 0000000..7f3aa0a Binary files /dev/null and b/public/unknown.webp differ diff --git a/public/us.webp b/public/us.webp new file mode 100644 index 0000000..ffeb074 Binary files /dev/null and b/public/us.webp differ diff --git a/public/uy.webp b/public/uy.webp new file mode 100644 index 0000000..c6ee9b7 Binary files /dev/null and b/public/uy.webp differ diff --git a/public/uz.webp b/public/uz.webp new file mode 100644 index 0000000..f03b745 Binary files /dev/null and b/public/uz.webp differ diff --git a/public/va.webp b/public/va.webp new file mode 100644 index 0000000..6bafc70 Binary files /dev/null and b/public/va.webp differ diff --git a/public/vc.webp b/public/vc.webp new file mode 100644 index 0000000..042bcb0 Binary files /dev/null and b/public/vc.webp differ diff --git a/public/ve.webp b/public/ve.webp new file mode 100644 index 0000000..6502923 Binary files /dev/null and b/public/ve.webp differ diff --git a/public/vg.webp b/public/vg.webp new file mode 100644 index 0000000..74baece Binary files /dev/null and b/public/vg.webp differ diff --git a/public/vi.webp b/public/vi.webp new file mode 100644 index 0000000..7fab911 Binary files /dev/null and b/public/vi.webp differ diff --git a/public/vn.webp b/public/vn.webp new file mode 100644 index 0000000..e7e56f3 Binary files /dev/null and b/public/vn.webp differ diff --git a/public/vu.webp b/public/vu.webp new file mode 100644 index 0000000..e0c4b91 Binary files /dev/null and b/public/vu.webp differ diff --git a/public/wf.webp b/public/wf.webp new file mode 100644 index 0000000..2dd5f82 Binary files /dev/null and b/public/wf.webp differ diff --git a/public/ws.webp b/public/ws.webp new file mode 100644 index 0000000..6ac4626 Binary files /dev/null and b/public/ws.webp differ diff --git a/public/wxt.svg b/public/wxt.svg deleted file mode 100644 index 0e76320..0000000 --- a/public/wxt.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/public/xk.webp b/public/xk.webp new file mode 100644 index 0000000..0272324 Binary files /dev/null and b/public/xk.webp differ diff --git a/public/ye.webp b/public/ye.webp new file mode 100644 index 0000000..140c4b6 Binary files /dev/null and b/public/ye.webp differ diff --git a/public/yt.webp b/public/yt.webp new file mode 100644 index 0000000..f732ba5 Binary files /dev/null and b/public/yt.webp differ diff --git a/public/za.webp b/public/za.webp new file mode 100644 index 0000000..55e607f Binary files /dev/null and b/public/za.webp differ diff --git a/public/zm.webp b/public/zm.webp new file mode 100644 index 0000000..f0dfcae Binary files /dev/null and b/public/zm.webp differ diff --git a/public/zw.webp b/public/zw.webp new file mode 100644 index 0000000..c51ba29 Binary files /dev/null and b/public/zw.webp differ diff --git a/utils/icon.ts b/utils/icon.ts index 5e7b561..cab8e9d 100644 --- a/utils/icon.ts +++ b/utils/icon.ts @@ -1,66 +1,65 @@ export async function updateIcon(countryCode: string | null) { - const validCode = countryCode?.match(/^[A-Z]{2}$/i)?.[0]?.toLowerCase() || 'unknown'; + const validCode = + countryCode?.match(/^[A-Z]{2}$/i)?.[0]?.toLowerCase() || 'unknown' + const loadImageBitmap = async (code: string): Promise => { + const url = chrome.runtime.getURL(`${code}.webp`) try { - // Existing flag image handling - const flagUrl = `https://flagcdn.com/w160/${validCode}.png`; - const response = await fetch(flagUrl); - if (!response.ok) throw new Error('Invalid flag'); - - const blob = await response.blob(); - const bitmap = await createImageBitmap(blob); - const canvas = new OffscreenCanvas(128, 128); - const ctx = canvas.getContext('2d')!; - - const ratio = Math.min( - canvas.width / bitmap.width, - canvas.height / bitmap.height - ); - ctx.drawImage( - bitmap, - 0, 0, bitmap.width, bitmap.height, - (canvas.width - bitmap.width * ratio) / 2, - (canvas.height - bitmap.height * ratio) / 2, - bitmap.width * ratio, - bitmap.height * ratio - ); - - const sizes = [16, 32, 48, 128]; - const imageData = Object.fromEntries( - sizes.map(size => { - const resizedCanvas = new OffscreenCanvas(size, size); - const resizedCtx = resizedCanvas.getContext('2d')!; - resizedCtx.drawImage(canvas, 0, 0, size, size); - return [size, resizedCtx.getImageData(0, 0, size, size)]; - }) - ); - - chrome.action.setIcon({ imageData }); + const response = await fetch(url) + if (!response.ok) throw new Error('Flag not found') + const blob = await response.blob() + return await createImageBitmap(blob) } catch (error) { - console.error('Error updating extension icon:', error); - - // Fixed fallback SVG - const fallbackSVG = ` - - ? - `; - - // Properly encode SVG - const encodedSVG = encodeURIComponent(fallbackSVG) - .replace(/'/g, '%27') - .replace(/"/g, '%22'); - - const fallbackUrl = `data:image/svg+xml;charset=utf-8,${encodedSVG}`; - - // Set icon using path with size-specific URLs - chrome.action.setIcon({ - path: { - "16": fallbackUrl, - "32": fallbackUrl, - "48": fallbackUrl, - "128": fallbackUrl - } - }); + throw new Error( + `Failed to load flag: ${code} - ${ + error instanceof Error ? error.message : String(error) + }` + ) } } + + const processImage = async (bitmap: ImageBitmap) => { + const canvas = new OffscreenCanvas(128, 128) + const ctx = canvas.getContext('2d')! + + const ratio = Math.min( + canvas.width / bitmap.width, + canvas.height / bitmap.height + ) + ctx.clearRect(0, 0, canvas.width, canvas.height) + ctx.drawImage( + bitmap, + 0, + 0, + bitmap.width, + bitmap.height, + (canvas.width - bitmap.width * ratio) / 2, + (canvas.height - bitmap.height * ratio) / 2, + bitmap.width * ratio, + bitmap.height * ratio + ) + + const sizes = [16, 32, 48, 128] + return Object.fromEntries( + sizes.map(size => { + const resizedCanvas = new OffscreenCanvas(size, size) + const ctx = resizedCanvas.getContext('2d')! + ctx.drawImage(canvas, 0, 0, size, size) + return [size, ctx.getImageData(0, 0, size, size)] + }) + ) + } + + try { + const bitmap = await loadImageBitmap(validCode) + chrome.action.setIcon({ imageData: await processImage(bitmap) }) + } catch (error) { + console.error('Primary flag failed, trying unknown:', error) + try { + const unknownBitmap = await loadImageBitmap('unknown') + chrome.action.setIcon({ imageData: await processImage(unknownBitmap) }) + } catch (fallbackError) { + console.error('Both flag assets failed:', fallbackError) + } + } +} diff --git a/utils/index.ts b/utils/index.ts index 21a8eff..ab02e71 100644 --- a/utils/index.ts +++ b/utils/index.ts @@ -1,26 +1,36 @@ export function isPrivateIP(host: string): boolean { - try { - const ip = host.startsWith('[') ? host.slice(1, -1) : host; - if (ip === 'localhost') return true; + try { + const rawIp = host.startsWith('[') ? host.slice(1, -1) : host - // IPv4 private ranges - if (ip.includes('.')) { - const parts = ip.split('.').map(Number); - return parts[0] === 10 || - (parts[0] === 172 && parts[1] >= 16 && parts[1] <= 31) || - (parts[0] === 192 && parts[1] === 168) || - (parts[0] === 169 && parts[1] === 254); - } + if (rawIp === 'localhost') return true - // IPv6 private ranges - if (ip.includes(':')) { - return ip.startsWith('fc00::/7') || - ip.startsWith('fe80::/10') || - ip.startsWith('::1'); - } + if (rawIp.includes('.')) { + const parts = rawIp.split('.').map(Number) + if (parts.length !== 4 || parts.some(isNaN)) return false - return false; - } catch { - return false; + return ( + parts[0] === 10 || + (parts[0] === 172 && parts[1] >= 16 && parts[1] <= 31) || + (parts[0] === 192 && parts[1] === 168) || + (parts[0] === 169 && parts[1] === 254) + ) } + + if (rawIp.includes(':')) { + const ip = rawIp.split('%')[0] + + if (ip === '::1') return true + + const firstHextet = parseInt(ip.split(':')[0], 16) + if ((firstHextet & 0xfe00) === 0xfc00) return true + + if ((firstHextet & 0xffc0) === 0xfe80) return true + + return false + } + + return false + } catch { + return false } +} diff --git a/utils/model.ts b/utils/model.ts index bb2016d..cfacee7 100644 --- a/utils/model.ts +++ b/utils/model.ts @@ -1,10 +1,15 @@ export interface ServerData { - origin: string - ip: string; - hostname: string | null; - country: string | null; - city: string | null; - org: string; - isLocal?: boolean; - isBrowserResource?: boolean; + origin: string + ip: string + hostname: string | null + country: string | null + city: string | null + org: string + isLocal?: boolean + isBrowserResource?: boolean +} + +export interface DNSEntry { + type: number + data: string }