Skip to content

Instantly share code, notes, and snippets.

@ayashiiiyo
Created May 15, 2026 10:23
Show Gist options
  • Select an option

  • Save ayashiiiyo/4fde4f192e51e470868a1c8d41c64170 to your computer and use it in GitHub Desktop.

Select an option

Save ayashiiiyo/4fde4f192e51e470868a1c8d41c64170 to your computer and use it in GitHub Desktop.
const instagram = async (
url = 'Link_IG'
) => {
try {
const ua =
'Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/537.36 (KHTML, like Gecko) CriOS/135.0.7049.83 Mobile/15E148 Safari/604.1'
const page = await fetch(
'https://staging.zeawin.com/NullGram/',
{
headers: {
'user-agent': ua
}
}
)
const html = await page.text()
const cookie =
page.headers.get('set-cookie') || ''
const encoded = html.match(
/const\s+_0x1a\s*=\s*"([^"]+)"/
)?.[1]
let hex = ''
for (let i = 0; i < encoded.length; i += 2) {
hex += String.fromCharCode(
parseInt(encoded.substr(i, 2), 16)
)
}
const decoded = decodeURIComponent(
atob(
hex
.split('')
.reverse()
.join('')
)
)
const token = decoded.match(
/window\.nxToken\s*=\s*'([^']+)'/
)?.[1]
const nxTime = Number(
decoded.match(
/window\.nxTime\s*=\s*(\d+)/
)?.[1]
)
const start = Date.now()
let uSum = 0
for (const c of url) {
uSum += c.charCodeAt(0)
}
const ts =
nxTime +
Math.floor((Date.now() - start) / 1000)
const te = btoa(
token
.split('')
.reverse()
.join('')
.substring(0, 10) + (ts + uSum)
)
let mChar = ''
for (let i = 0; i < url.length; i += 2) {
mChar += url[i]
}
const tn = btoa(
`${mChar}-N-${ts * uSum}-${token.substring(3, 8)}`
)
const req = await fetch(
'https://staging.zeawin.com/NullGram/ig.php',
{
method: 'POST',
headers: {
'content-type': 'application/json',
'x-null-token': token,
origin: 'https://staging.zeawin.com',
referer:
'https://staging.zeawin.com/NullGram/',
cookie,
'user-agent': ua
},
body: JSON.stringify({
url,
ts,
te,
tn
})
}
)
const json = await req.json()
const rot13 = str =>
str.replace(/[a-zA-Z]/g, c =>
String.fromCharCode(
(
c <= 'Z' ? 90 : 122
) >= (c = c.charCodeAt(0) + 13)
? c
: c - 26
)
)
const parsed = JSON.parse(
decodeURIComponent(
escape(
atob(
rot13(json.payload)
.split('')
.reverse()
.join('')
)
)
)
)
return {
author: parsed.author,
avatar: parsed.avatar,
audio: parsed.audio,
media: parsed.media
}
} catch (e) {
console.error(e)
}
}
instagram()
.then(console.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment