Skip to content

Instantly share code, notes, and snippets.

@mrcyclo
Last active January 23, 2026 18:42
Show Gist options
  • Select an option

  • Save mrcyclo/ba05a259cd31861f3ac335dc71bba5b0 to your computer and use it in GitHub Desktop.

Select an option

Save mrcyclo/ba05a259cd31861f3ac335dc71bba5b0 to your computer and use it in GitHub Desktop.
Press F9 to send correct answer
// ==UserScript==
// @name Quiz Auto Answer
// @namespace http://tampermonkey.net/
// @version 2025-05-15
// @description try to take over the world!
// @author mrcyclo
// @match https://quiz.com/*/
// @icon https://www.google.com/s2/favicons?sz=64&domain=quiz.com
// @grant none
// ==/UserScript==
(async function() {
while (true) {
await sleep(100);
if (!window.__SOCKET__) continue;
break;
}
let currentQuestion = null;
let roomId = null;
let serverTimestamp = null;
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function getRndInteger(min, max) {
return Math.floor(Math.random() * (max - min + 1) ) + min;
}
// Research from quiz.com js with keyword 'pathString'
function I(e, a = 400, n = 300) {
let M = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
let t = .001953125 * a
, r = .001953125 * n
, i = Math.floor(e.length / 3)
, o = Array(i);
for (let a = 0; a < i; a++) {
let n = e.substring(3 * a, 3 * a + 3)
, i = [...n].reduce( (e, a, n) => e + (1 << (2 - n) * 6) * M.indexOf(a), 0)
, l = (511 & i) * t
, s = (i >> 9 & 511) * r;
o[a] = {
x: l,
y: s
}
}
return o
}
function getPinPointAnswer(text) {
var i = (text || "").split("~").map(e => I(e)).filter(e => e.length > 2);
var points = i[0];
const total = points.reduce((acc, p) => {
acc.x += p.x;
acc.y += p.y;
return acc;
}, { x: 0, y: 0 });
const count = points.length;
return {
x: total.x / count,
y: total.y / count
}
}
async function submit() {
if (!currentQuestion) return;
let answer = null;
switch (currentQuestion.type) {
case 'TypeAnswer':
answer = currentQuestion.answers.find(x => x.isCorrect).text;
break;
case 'Classic':
answer = currentQuestion.answers.findIndex(x => x.isCorrect);
break;
case 'CheckBoxes':
answer = currentQuestion.answers.map(x => x.isCorrect);
break;
case 'Reorder':
answer = currentQuestion.answers
.map((x, i) => { x.index = i; return x; })
.toSorted((a, b) => a.pos - b.pos)
.map(x => x.index);
break;
case 'Range':
answer = currentQuestion.answers.find(x => x.isCorrect).text;
break;
case 'Pinpoint':
var tmp = currentQuestion.answers.find(x => x.isCorrect).text;
answer = getPinPointAnswer(tmp);
break;
default:
return;
}
window.__SOCKET__.send(JSON.stringify(["room/message",{"roomId":roomId,"message":{"answer":{"slideIndex":currentQuestion.index,"answer":answer,"progress":0,"unsubmitted":false,"timestamp":serverTimestamp},"serverTimestamp":serverTimestamp}}]));
}
function showCorrectAnswer() {
if (!currentQuestion) return;
let answer = null;
switch (currentQuestion.type) {
case 'TypeAnswer':
answer = currentQuestion.answers.find(x => x.isCorrect).text;
break;
case 'Classic':
answer = currentQuestion.answers.find(x => x.isCorrect).text;
break;
case 'CheckBoxes':
answer = currentQuestion.answers.map(x => x.isCorrect ? 1 : 0);
break;
case 'Reorder':
answer = currentQuestion.answers
.toSorted((a, b) => a.pos - b.pos)
.map(x => x.text);
break;
case 'Range':
answer = currentQuestion.answers.find(x => x.isCorrect).text;
break;
default:
return;
}
console.log(answer);
}
const origOnMessage = window.__SOCKET__.onmessage;
const myOnMessage = e => {
origOnMessage(e);
const json = JSON.parse(e.data);
const messageType = json[0];
const messageData = json[1];
if (!messageData) return;
if (messageData.serverTimestamp) {
serverTimestamp = messageData.serverTimestamp;
}
if (messageType == 'room/message') {
roomId = messageData.roomId;
if (messageData.message.state) {
currentQuestion = messageData.message.state.slideObject;
showCorrectAnswer();
}
if (messageData.message.patch) {
for (const patch of messageData.message.patch) {
if (patch.op != 'replace') continue;
if (patch.path != '/slideObject') continue;
if (!patch.value) continue;
currentQuestion = patch.value;
showCorrectAnswer();
break;
}
}
if (messageData.message.status == 'wait for answer') {
//submit();
}
}
};
window.__SOCKET__.onmessage = myOnMessage;
document.addEventListener('keydown', e => {
if (e.key != 'F9') return;
e.preventDefault();
submit();
});
console.log('Injected!');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment