wolfyflutter

44. n9.cl [url shortener]

Aug 4th, 2025 (edited)
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.07 KB | Source Code | 0 0
  1. /*
  2.   base   : https://n9.cl/en
  3.   node   : v24.4.0
  4.   update : 4 agustus 2025
  5.   fungsi : url shortener
  6.   by     : wolep
  7. */
  8.  
  9. const shortUrl = async function (url) {
  10.     const headers = {
  11.         'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0',
  12.         'Accept-Encoding': 'gzip, deflate, br, zstd',
  13.         'Content-Type': 'application/x-www-form-urlencoded'
  14.     }
  15. ;
  16.     const body = new URLSearchParams({
  17.         'xjxfun' : 'create',
  18.         'xjxargs[]' : 'S<![CDATA['+url+']]>'
  19.     })
  20.  
  21.     const r = await fetch('https://n9.cl/en', {headers, body, 'method':'post'})
  22.     if (!r.ok) throw Error (`${r.status} ${r.statusText}`)
  23.     const t = await r.text()
  24.     const u = t.match(/location = "(.+?)";/)?.[1]
  25.     if (!u) throw Error (`gagal mendapatkan short url`)
  26.     const fu = u.replace('/en/r','')
  27.     return fu
  28. }
  29.  
  30.  
  31. // cara pakai
  32. shortUrl('https://whatsapp.com/channel/0029Vb5EZCjIiRotHCI1213L')
  33. .then(console.log)
  34. .catch(console.log)
  35.  
  36. // output : https://n9.cl/dh63iw
Advertisement
Add Comment
Please, Sign In to add comment