Stalker JavaScript

Instagram Stalk

Mengambil informasi user lewat username instagram

JA Instagram Stalk.javascript
src > modules > Instagram Stalk.javascript
/**
 * Judul : Instagram Stalker
 * Base URL : https://igwatcher.com
 * Author : Cx99 - t.me/exploit99
 * Deskripsi : Mengambil informasi profil, post, reels, stories, highlights dan tagged Instagram
 * Channel : https://whatsapp.com/channel/0029VbCSF8sA89MopCVOYW06
 */

'use strict'

const BASE = 'https://igwatcher.com'

const headers = {
	'user-agent': 'Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36',
	'accept': 'application/json, text/plain, */*',
	'accept-language': 'en-US,en;q=0.9',
	'referer': 'https://igwatcher.com/',
	'origin': 'https://igwatcher.com'
}

const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))

function extractUsername(input) {
	const raw = input.trim()
		.replace(/^@/, '')
		.replace(/^https?:\/\/(www\.)?instagram\.com\//i, '')
		.replace(/^https?:\/\/instagr\.am\//i, '')
		.replace(/\/$/, '')
		.split('/')[0]
		.split('?')[0]

	if (!/^[a-zA-Z0-9._]{1,30}$/.test(raw)) {
		throw new Error(`Invalid username: "${raw}"`)
	}

	return raw.toLowerCase()
}

async function jget(url, timeout = 50000) {
	const controller = new AbortController()
	const timer = setTimeout(() => controller.abort(), timeout)

	try {
		const response = await fetch(url, {
			method: 'GET',
			headers,
			cache: 'no-store',
			signal: controller.signal
		})

		const text = await response.text()
		let data

		try {
			data = JSON.parse(text)
		} catch {
			data = text
		}

		return {
			ok: response.ok,
			status: response.status,
			data
		}
	} catch (error) {
		if (error.name === 'AbortError') {
			throw new Error('Request timeout')
		}

		throw error
	} finally {
		clearTimeout(timer)
	}
}

async function request(path, params = {}, timeout = 50000) {
	const query = new URLSearchParams(params)
	const response = await jget(`${BASE}${path}?${query}`, timeout)

	if (!response.ok) {
		const message = typeof response.data === 'object'
			? response.data?.message || JSON.stringify(response.data)
			: response.data

		throw new Error(`HTTP ${response.status}: ${message}`)
	}

	return response.data
}

const getProfile = username =>
	request('/wp-json/igw/v1/search', { username }, 40000)

const getPosts = username =>
	request('/wp-json/igw/v1/posts', {
		username,
		limit: 24,
		lazy: 1
	}, 55000)

const getReels = username =>
	request('/wp-json/igw/v1/reels', {
		username,
		limit: 24,
		lazy: 1
	}, 55000)

const getStories = username =>
	request('/wp-json/igw/v1/stories', { username }, 55000)

const getHighlights = username =>
	request('/wp-json/igw/v1/highlights', { username }, 55000)

const getTagged = username =>
	request('/wp-json/igw/v1/tagged', {
		username,
		limit: 24,
		lazy: 1
	}, 50000)

async function processStep(fn) {
	await sleep(350)

	try {
		return {
			success: true,
			data: await fn()
		}
	} catch (error) {
		return {
			success: false,
			error: error.message
		}
	}
}

async function igstalk(input) {
	if (!input) {
		return {
			status: false,
			message: 'Username kosong'
		}
	}

	try {
		const username = extractUsername(input)
		const result = { username }

		const profile = await processStep(() => getProfile(username))
		profile.success
			? result.profile = profile.data
			: result.profile_error = profile.error

		const posts = await processStep(() => getPosts(username))
		posts.success
			? result.posts = posts.data
			: result.posts_error = posts.error

		const reels = await processStep(() => getReels(username))
		reels.success
			? result.reels = reels.data
			: result.reels_error = reels.error

		const stories = await processStep(() => getStories(username))
		stories.success
			? result.stories = stories.data
			: result.stories_error = stories.error

		const highlights = await processStep(() => getHighlights(username))
		highlights.success
			? result.highlights = highlights.data
			: result.highlights_error = highlights.error

		const tagged = await processStep(() => getTagged(username))
		tagged.success
			? result.tagged = tagged.data
			: result.tagged_error = tagged.error

		return {
			status: true,
			result
		}
	} catch (error) {
		return {
			status: false,
			message: error.message
		}
	}
}

module.exports = { igstalk }

;(async () => {
	const { igstalk } = require('./igstalk')

	const result = await igstalk('rfkaansyah_')
	console.log(JSON.stringify(result, null, 2))
})()
Kembali ke Home
Home Search Request Owner Login