add cloudflare

This commit is contained in:
2025-03-18 12:55:32 +01:00
parent 940b8bbec4
commit a540f1eb0a
3 changed files with 63 additions and 43 deletions
+8 -3
View File
@@ -1,9 +1,14 @@
export async function updateIcon(countryCode: string | null) {
const validCode =
countryCode?.match(/^[A-Z]{2}$/i)?.[0]?.toLowerCase() || 'unknown'
let validCode
if (countryCode === 'cloudflare') {
validCode = 'cloudflare'
} else {
validCode =
countryCode?.match(/^[A-Z]{2}$/i)?.[0]?.toLowerCase() || 'unknown'
}
const loadImageBitmap = async (code: string): Promise<ImageBitmap> => {
const url = browser.runtime.getURL("/")
const url = browser.runtime.getURL('/')
try {
const response = await fetch(url + `${code}.webp`)
if (!response.ok) throw new Error('Flag not found')