kon.lol

by RFour · Aug 1, 2026 ·javascript

I'm sooo boredddddd idk what I'm doing, basically url shortener stuff

konkon.lolshortener
konlol.jsjavascript
1export async function konlol(req) {
2  const { searchParams: sp } = new URL(req.url);
3  const url = sp.get('url');
4  const custom = sp.get('custom');
5  const mode = sp.get('mode') || 'shorten';
6
7  if (mode === 'status') {
8    try {
9      const res = await fetch("https://kon.lol/api/rate-status", {
10        headers: {
11          'User-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Mobile Safari/537.36',
12          'Referer': 'https://kon.lol/'
13        }
14      });
15      return res.json();
16    } catch (err) {
17      return { error: err.message };
18    }
19  }
20
21  if (!url) {
22    return {
23      error: "missing url",
24      usage: {
25        shorten: "/konlol?url=https://example.com",
26        custom: "/konlol?url=https://example.com&custom=myslug",
27        status: "/konlol?mode=status"
28      }
29    };
30  }
31
32  try {
33    const body = { url };
34    if (custom) body.customPath = custom;
35
36    const res = await fetch("https://kon.lol/api/shorten", {
37      method: 'POST',
38      headers: { 'Content-Type': 'application/json' },
39      body: JSON.stringify(body)
40    });
41    return res.json();
42  } catch (err) {
43    return { error: err.message };
44  }
45}
raw