export async function konlol(req) { const { searchParams: sp } = new URL(req.url); const url = sp.get('url'); const custom = sp.get('custom'); const mode = sp.get('mode') || 'shorten'; if (mode === 'status') { try { const res = await fetch("https://kon.lol/api/rate-status", { headers: { 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Mobile Safari/537.36', 'Referer': 'https://kon.lol/' } }); return res.json(); } catch (err) { return { error: err.message }; } } if (!url) { return { error: "missing url", usage: { shorten: "/konlol?url=https://example.com", custom: "/konlol?url=https://example.com&custom=myslug", status: "/konlol?mode=status" } }; } try { const body = { url }; if (custom) body.customPath = custom; const res = await fetch("https://kon.lol/api/shorten", { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) }); return res.json(); } catch (err) { return { error: err.message }; } }