scraperjavascript338
Quizizz & Wayground Live Questions & Answers Scraper
Scraper otomatis untuk mengekstrak pertanyaan, opsi pilihan, dan kunci jawaban (answers decoding) dari Quizizz & Wayground menggunakan Game Code (PIN) atau Quiz URL/ID.
Vamz Spectre11 Okt 2026415 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/quizizz-questions-scraper" -o quizizz-questions-scraper.js
# 2. Jalankan script
node quizizz-questions-scraper.js
Dependencies npm yang Dibutuhkan:
npm install Built-in Node.js fetch (Node 18+)Panduan Penggunaan:
curl -sL "https://code.vamxapi.my.id/snippet/raw/quizizz-questions-scraper" -o quizizz-questions-scraper.js && node quizizz-questions-scraper.js "<game_code_or_url>"
quizizz-questions-scraper.js(415 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
/**
* ========================================================
* Name: Quizizz & Wayground Live Questions & Answers Scraper
*
* Cara Download:
* curl -sL "https://code.vamxapi.my.id/snippet/raw/quizizz-questions-scraper" -o quizizz-questions-scraper.js
*
* Cara Eksekusi:
* node quizizz-questions-scraper.js "601541"
* node quizizz-questions-scraper.js "https://wayground.com/join?gc=601541"
* node quizizz-questions-scraper.js "https://wayground.com/admin/quiz/60ca9d27d88141001c1d792d"
* node quizizz-questions-scraper.js "60ca9d27d88141001c1d792d"
*
* Author: Vamz Spectre
* Source: https://vamxapi.my.id
* ========================================================
*/
const DEFAULT_USER_AGENT =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36";
const QUIZIZZ_PLAY_API = "https://game.quizizz.com/play-api";
class Encoding {
static decode(t, e = false) {
if (e) {
const head = this.extractHeader(t);
return this.decodeRaw(head, true);
}
const headDecoded = this.decode(this.extractHeader(t), true);
const data = this.extractData(t);
return this.decodeRaw(data, false, headDecoded);
}
static decodeRaw(t, e, o = "quizizz.com") {
const s = this.extractVersion(t);
let r = e ? o.charCodeAt(0) : o.charCodeAt(0) + o.charCodeAt(o.length - 1);
r = -r;
const n = [];
for (let i = 0; i < t.length; i++) {
const c = t[i].charCodeAt(0);
const a = e ? this.safeAdd(c, r) : this.addOffset(c, r, i, s);
n.push(String.fromCharCode(a));
}
return n.join("");
}
static addOffset(t, e, o, s) {
return 2 === s
? this.verifyCharCode(t)
? this.safeAdd(t, o % 2 === 0 ? e : -e)
: t
: this.safeAdd(t, o % 2 === 0 ? e : -e);
}
static extractData(t) {
const e = t.charCodeAt(t.length - 2) - 33;
return t.slice(e, -2);
}
static extractHeader(t) {
const e = t.charCodeAt(t.length - 2) - 33;
return t.slice(0, e);
}
static extractVersion(t) {
if (typeof t === "string" && t[t.length - 1]) {
const e = parseInt(t[t.length - 1], 10);
if (!isNaN(e)) return e;
}
return null;
}
static safeAdd(t, e) {
const o = t + e;
return o > 65535 ? o - 65535 + 0 - 1 : o < 0 ? 65535 - (0 - o) + 1 : o;
}
static verifyCharCode(t) {
if (typeof t === "number") {
return !(t >= 55296 && t <= 56319 || t >= 56320 && t <= 57343);
}
return false;
}
}
function cleanText(text) {
if (!text || typeof text !== "string") return "";
return text
.replace(/<[^>]+>/g, "")
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, '"')
.replace(/'/g, "'")
.replace(/ /g, " ")
.trim();
}
function extractIdentifier(input) {
if (!input || typeof input !== "string") return { type: "unknown", value: "" };
const trimmed = input.trim();
// 1. Direct MongoDB ObjectId atau URL quiz admin
const quizMatch = trimmed.match(/quiz\/([a-f0-9]{24})/i) || trimmed.match(/^([a-f0-9]{24})$/i);
if (quizMatch) {
return { type: "quiz_id", value: quizMatch[1] };
}
// 2. Game Code (PIN) 4-8 digit
const codeMatch = trimmed.match(/[?&](?:gc|code)=([0-9]{4,8})/i) || trimmed.match(/([0-9]{4,8})/);
if (codeMatch) {
return { type: "game_code", value: codeMatch[1] };
}
return { type: "unknown", value: trimmed };
}
function extractGameCode(input) {
const ident = extractIdentifier(input);
return ident.value;
}
function decodeQuizizzAnswer(rawAnswer, structure, options) {
if (rawAnswer === undefined || rawAnswer === null) {
const kind = (structure.kind || structure.type || "").toUpperCase();
if (kind === "BLANK") {
const texts = options.map((o) => o.text).filter(Boolean);
options.forEach((o) => { o.is_correct = true; });
return { answer_indices: options.map((o) => o.index), answers: texts };
}
return { answer_indices: [], answers: [] };
}
let resolved = null;
if (typeof rawAnswer === "number") {
resolved = [rawAnswer];
} else if (Array.isArray(rawAnswer)) {
resolved = rawAnswer.map((x) => (typeof x === "number" ? x : parseInt(x, 10))).filter((x) => !isNaN(x));
} else if (typeof rawAnswer === "string") {
const trimmed = rawAnswer.trim();
if (/^\d+$/.test(trimmed)) {
resolved = [parseInt(trimmed, 10)];
} else if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
try {
const parsed = JSON.parse(trimmed);
if (Array.isArray(parsed)) {
resolved = parsed.map((x) => (typeof x === "number" ? x : parseInt(x, 10))).filter((x) => !isNaN(x));
}
} catch {}
}
if (!resolved) {
try {
const decoded = Encoding.decode(trimmed);
if (decoded) {
try {
const parsed = JSON.parse(decoded);
if (Array.isArray(parsed)) {
resolved = parsed.map((x) => (typeof x === "number" ? x : parseInt(x, 10))).filter((x) => !isNaN(x));
} else if (typeof parsed === "number") {
resolved = [parsed];
}
} catch {}
if (!resolved && /^\d+$/.test(decoded.trim())) {
resolved = [parseInt(decoded.trim(), 10)];
}
if (!resolved && decoded.length > 0) {
return { answer_indices: [], answers: [cleanText(decoded)] };
}
}
} catch {}
}
}
if (Array.isArray(resolved) && resolved.length > 0) {
const answerTexts = [];
resolved.forEach((idx) => {
if (options[idx]) {
options[idx].is_correct = true;
const text = options[idx].text || (options[idx].media && options[idx].media[0]?.url ? `(Media: ${options[idx].media[0].url})` : "");
if (text) answerTexts.push(text);
}
});
return { answer_indices: resolved, answers: answerTexts };
}
const kind = (structure.kind || structure.type || "").toUpperCase();
if (kind === "BLANK") {
const texts = options.map((o) => o.text).filter(Boolean);
options.forEach((o) => { o.is_correct = true; });
return { answer_indices: options.map((o) => o.index), answers: texts };
}
return { answer_indices: [], answers: [] };
}
async function fetchQuizById(quizId, meta = {}) {
const res = await fetch(`https://wayground.com/_api/main/quiz/${quizId}`, {
headers: { "User-Agent": DEFAULT_USER_AGENT },
signal: AbortSignal.timeout(12000),
});
if (!res.ok) {
throw new Error(`Kuis Quizizz dengan ID "${quizId}" tidak ditemukan (HTTP ${res.status}).`);
}
const data = await res.json();
const quiz = data?.data?.quiz;
const info = quiz?.info || {};
const rawQuestions = info.questions || [];
const questions = rawQuestions.map((item, index) => {
const structure = item.structure || {};
const query = structure.query || {};
const rawOptions = structure.options || [];
const options = rawOptions.map((opt, optIdx) => ({
index: optIdx,
id: opt.id || opt._id || `opt_${optIdx}`,
text: cleanText(opt.text),
media: opt.media || [],
is_correct: false,
}));
const ansData = decodeQuizizzAnswer(structure.answer, structure, options);
return {
number: index + 1,
id: item._id || item.id,
type: item.type || structure.kind || "MCQ",
time_limit_ms: info.qm?.[item._id]?.time || structure.time || 30000,
question: cleanText(query.text || "(Media / Gambar Pertanyaan)"),
media: query.media || [],
options,
answer_indices: ansData.answer_indices,
answers: ansData.answers,
};
});
return {
quiz_id: quizId,
title: cleanText(info.name || quiz?.name || "Quizizz Quiz"),
subject: (info.subjects || []).join(", "),
total_questions: questions.length,
...meta,
questions,
};
}
async function getQuizizzQuestions(gameCodeOrUrl) {
const ident = extractIdentifier(gameCodeOrUrl);
if (!ident.value || ident.type === "unknown") {
throw new Error("Game Code (PIN) atau Quiz URL/ID Quizizz / Wayground tidak valid.");
}
// 1. Direct Quiz ID
if (ident.type === "quiz_id") {
return await fetchQuizById(ident.value);
}
const roomCode = ident.value;
// 2. Check Room untuk mendapatkan roomHash dan metadata
const checkRes = await fetch(`${QUIZIZZ_PLAY_API}/v5/checkRoom`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"User-Agent": DEFAULT_USER_AGENT,
},
body: JSON.stringify({ roomCode }),
signal: AbortSignal.timeout(10000),
});
const checkData = await checkRes.json().catch(() => null);
const room = checkData?.room;
if (!room || !room.hash) {
throw new Error(`Room Quizizz dengan kode "${roomCode}" tidak ditemukan atau sudah berakhir.`);
}
// 3. Coba ambil quizId agar mendapatkan jawaban 100% lengkap tanpa enkripsi
let quizId = room.quizId || room.quizInfo?.quizId || null;
if (!quizId && room.hash) {
try {
const studentRes = await fetch(`https://wayground.com/_gameapi/main/public/v1/students/games/${room.hash}`, {
headers: { "User-Agent": DEFAULT_USER_AGENT },
signal: AbortSignal.timeout(6000),
});
if (studentRes.ok) {
const studentData = await studentRes.json();
quizId = studentData?.data?.items?.[0]?.quizId || null;
}
} catch {}
}
if (quizId) {
try {
const quizResult = await fetchQuizById(quizId, {
game_code: room.code || roomCode,
room_hash: room.hash,
state: room.state || "active",
type: room.type || "live",
});
if (quizResult && quizResult.questions && quizResult.questions.length > 0) {
return quizResult;
}
} catch {}
}
// 4. Fallback ke endpoint internal v4 jika quizId private
const qRes = await fetch(`${QUIZIZZ_PLAY_API}/v4/getQuestions`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"User-Agent": DEFAULT_USER_AGENT,
},
body: JSON.stringify({ roomHash: room.hash }),
signal: AbortSignal.timeout(15000),
});
if (!qRes.ok) {
throw new Error(`Gagal mengambil daftar pertanyaan kuis (HTTP ${qRes.status}).`);
}
const qData = await qRes.json();
const rawQ = qData.questions || {};
const questionIds = Object.keys(rawQ);
const questions = questionIds.map((id, index) => {
const item = rawQ[id];
const structure = item.structure || {};
const query = structure.query || {};
const rawOptions = structure.options || [];
const options = rawOptions.map((opt, optIdx) => ({
index: optIdx,
id: opt.id || opt._id || `opt_${optIdx}`,
text: cleanText(opt.text),
media: opt.media || [],
is_correct: false,
}));
const ansData = decodeQuizizzAnswer(structure.answer, structure, options);
return {
number: index + 1,
id,
type: item.type || structure.kind || "MCQ",
time_limit_ms: item.time || 30000,
question: cleanText(query.text || "(Media / Gambar Pertanyaan)"),
media: query.media || [],
options,
answer_indices: ansData.answer_indices,
answers: ansData.answers,
};
});
return {
game_code: room.code || roomCode,
room_hash: room.hash,
state: room.state || "active",
type: room.type || "live",
total_questions: questions.length,
questions,
};
}
if (typeof module !== "undefined" && module.exports) {
module.exports = {
extractGameCode,
extractIdentifier,
getQuizizzQuestions,
default: getQuizizzQuestions,
};
}
/**
* CLI Runner:
* Langsung eksekusi jika dijalankan via terminal: node quizizz-questions-scraper.js "<code>"
*/
const argCode = process.argv[2];
if (argCode) {
getQuizizzQuestions(argCode)
.then((res) => {
console.log(JSON.stringify(res, null, 2));
})
.catch((err) => {
console.error(JSON.stringify({ status: false, error: err.message }, null, 2));
process.exit(1);
});
} else if (
process.argv[1] &&
(process.argv[1].endsWith("quizizz-questions-scraper.js") ||
process.argv[1].endsWith("quizizz-questions-scraper.cjs"))
) {
console.log(
JSON.stringify(
{
status: false,
message: "Parameter Game Code (PIN) atau Quiz URL/ID belum ditentukan.",
usage: 'node quizizz-questions-scraper.js "<game_code_or_url>"',
examples: [
'node quizizz-questions-scraper.js "601541"',
'node quizizz-questions-scraper.js "https://wayground.com/join?gc=601541"',
'node quizizz-questions-scraper.js "60ca9d27d88141001c1d792d"',
],
},
null,
2
)
);
process.exit(1);
}