toolsjavascript152
sURL.li - Link Shortener & Unshortener Engine
Engine shortener & unshortener link surl.li via HyperHost tools API. Mendukung short link dan unshort link tanpa captcha.
Vamz Spectre13 Okt 2026218 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/surli" -o surli.js
# 2. Jalankan script
node surli.js
Dependencies npm yang Dibutuhkan:
npm install None (Built-in Node.js 18+)Panduan Penggunaan:
curl -sL https://vamxapi.my.id/snippet/raw/surli -o surli.js && node surli.js "https://surl.li/xsnwkm"
surli.js(218 lines)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/**
* ========================================================
* Name: HyperHost sURL - Link Shortener & Unshortener (CLI & Module)
*
* Cara Download:
* curl -sL "https://code.vamxapi.my.id/snippet/raw/surli" -o surli.js
*
* Cara Eksekusi:
* node surli.js short "https://google.com"
* node surli.js unshort "https://surl.li/kjaesz"
*
* Author: Vamz Spectre
* Source: https://vamxapi.my.id
* ========================================================
*/
const BASE_URL = "https://hyperhost.ua/tools";
const DEFAULT_HEADERS = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
"Accept-Language": "en-US,en;q=0.9"
};
/**
* Dapatkan CSRF Token & Session Cookies dari HyperHost
*/
async function getSession(refererPath = "/en/surli") {
const tokenRes = await fetch(`${BASE_URL}/csrf-token`, {
headers: {
...DEFAULT_HEADERS,
"Referer": `${BASE_URL}${refererPath}`
}
});
if (!tokenRes.ok) {
throw new Error(`Gagal mengambil token sesi: HTTP ${tokenRes.status}`);
}
const cookies = tokenRes.headers.getSetCookie
? tokenRes.headers.getSetCookie().map(c => c.split(";")[0]).join("; ")
: (tokenRes.headers.get("set-cookie") || "");
const { csrf_token } = await tokenRes.json();
if (!csrf_token) throw new Error("Gagal mengekstrak CSRF token dari server");
return { csrf_token, cookies };
}
/**
* 1. Shorten URL (Membuat link pendek surl.li)
*/
async function shorten(longUrl) {
if (!longUrl) throw new Error("URL tujuan wajib diisi!");
const { csrf_token, cookies } = await getSession("/en/surli");
const res = await fetch(`${BASE_URL}/pushData`, {
method: "POST",
headers: {
...DEFAULT_HEADERS,
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"X-CSRF-TOKEN": csrf_token,
"X-Requested-With": "XMLHttpRequest",
"Cookie": cookies,
"Referer": `${BASE_URL}/en/surli`
},
body: new URLSearchParams({
"data[url]": longUrl
})
});
if (!res.ok) {
throw new Error(`Gagal memendekkan URL: HTTP ${res.status}`);
}
const data = await res.json();
if (!data.result || !data.short_url) {
throw new Error(data.message || "Gagal membuat shortlink surl.li");
}
return {
success: true,
action: "shorten",
originalUrl: longUrl,
shortUrl: data.short_url
};
}
/**
* 2. Unshorten URL (Membongkar link pendek)
*/
async function unshorten(shortUrl) {
if (!shortUrl) throw new Error("URL shortlink wajib diisi!");
const { csrf_token, cookies } = await getSession("/en/unshort-link");
const res = await fetch(`${BASE_URL}/unshortData`, {
method: "POST",
headers: {
...DEFAULT_HEADERS,
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"X-CSRF-TOKEN": csrf_token,
"X-Requested-With": "XMLHttpRequest",
"Cookie": cookies,
"Referer": `${BASE_URL}/en/unshort-link`
},
body: new URLSearchParams({
"data[url]": shortUrl
})
});
if (!res.ok) {
throw new Error(`Gagal membongkar link: HTTP ${res.status}`);
}
const data = await res.json();
if (data.errors) {
throw new Error(JSON.stringify(data.errors));
}
return {
success: true,
action: "unshorten",
shortUrl: data.shortUrl || shortUrl,
destinationUrl: data.greatUrl,
redirects: data.countRedirects || 1,
isSafe: data.isSaveUrl ?? true,
previewImage: data.previewIMG || null
};
}
/**
* Universal Dispatcher
*/
async function surli(command, ...rest) {
const clean = (command || "").trim();
if (!clean) throw new Error("Parameter input (short/unshort atau URL) wajib disertakan!");
const lower = clean.toLowerCase();
if (lower === "short" || lower === "shorten") {
const targetUrl = rest.join(" ").trim();
if (!targetUrl) throw new Error("URL yang ingin dipendekkan wajib disertakan!");
return await shorten(targetUrl);
}
if (lower === "unshort" || lower === "unshorten" || lower === "expand") {
const targetUrl = rest.join(" ").trim();
if (!targetUrl) throw new Error("URL yang ingin dibongkar wajib disertakan!");
return await unshorten(targetUrl);
}
// Deteksi otomatis jika input langsung berupa URL:
const isShortDomain = /^(https?:\/\/)?(surl\.li|bit\.ly|tinyurl\.com|t\.co|cutt\.ly|is\.gd|rb\.gy)/i.test(clean);
if (isShortDomain) {
return await unshorten(clean);
}
if (clean.startsWith("http://") || clean.startsWith("https://")) {
return await shorten(clean);
}
throw new Error(`Perintah tidak dikenali: "${command}". Gunakan "short" atau "unshort".`);
}
// CommonJS safe export
if (typeof module !== "undefined" && module.exports) {
module.exports = {
surli,
shorten,
short: shorten,
unshorten,
unshort: unshorten,
default: surli
};
}
/**
* CLI Runner:
* node surli.js short "https://google.com"
* node surli.js unshort "https://surl.li/kjaesz"
*/
const cliArgs = process.argv.slice(2);
const mainCommand = cliArgs[0] ? cliArgs[0].trim() : null;
async function runCli() {
if (!mainCommand) {
console.log(
JSON.stringify(
{
success: false,
message: "Sub-command belum ditentukan.",
usage: {
short: "node surli.js short <url>",
unshort: "node surli.js unshort <url_pendek>"
},
examples: [
"node surli.js short \"https://google.com\"",
"node surli.js unshort \"https://surl.li/kjaesz\""
]
},
null,
2
)
);
process.exit(1);
}
const res = await surli(mainCommand, ...cliArgs.slice(1));
console.log(JSON.stringify(res, null, 2));
}
if (process.argv[1]) {
runCli().catch((err) => {
console.error(JSON.stringify({ success: false, error: err.message }, null, 2));
process.exit(1);
});
}