Intercepts MathsOnline answers - Fixed duplicate/wrong inputs + smoother drag
// ==UserScript==
// @name MathsOnline HACKS!! {CHEAT} {HACKS} {EXPLOIT} {API} {DECOMPILED}
// @namespace http://tampermonkey.net/
// @version 2.7
// @description Intercepts MathsOnline answers - Fixed duplicate/wrong inputs + smoother drag
// @author Phil 🥹👍 and DynaHacks
// @license MIT
// @match *://*.mathsonline.com.au/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
let hudContainer = null;
let hudContent = null;
let isHidden = false;
const styles = `
#hacks-hud {
position: fixed;
top: 20px;
right: 20px;
width: 420px;
background: rgba(20, 20, 20, 0.97);
color: #ffffff;
border: 2px solid #00ff00;
border-radius: 8px;
font-family: monospace;
box-shadow: 0 0 25px rgba(0, 255, 0, 0.4);
z-index: 999999;
transition: opacity 0.2s ease-in-out;
user-select: none;
cursor: default;
will-change: transform;
}
#hacks-hud-header {
background: #111;
padding: 12px;
font-weight: bold;
font-size: 13px;
border-bottom: 1px solid #333;
display: flex;
justify-content: space-between;
align-items: center;
cursor: grab;
}
#hacks-hud-header:active { cursor: grabbing; }
#hacks-hud-title { color: #00ff00; }
#hacks-hud-toggle-btn {
background: #222;
border: 1px solid #555;
color: #0f0;
padding: 4px 10px;
border-radius: 4px;
cursor: pointer;
font-size: 11px;
}
#hacks-hud-body {
padding: 12px;
max-height: 520px;
overflow-y: auto;
font-size: 12px;
line-height: 1.4;
}
.hacks-answer-row {
display: flex;
justify-content: space-between;
padding: 8px 0;
border-bottom: 1px solid #222;
}
.hacks-answer-row:last-child { border-bottom: none; }
.hacks-label { color: #aaa; }
.hacks-val { color: #00ff88; font-weight: bold; }
.hacks-hidden-hud {
opacity: 0 !important;
pointer-events: none !important;
transform: scale(0.9) translateY(-15px);
}
`;
function injectStyles() {
const styleSheet = document.createElement("style");
styleSheet.innerText = styles;
document.head.appendChild(styleSheet);
}
function createHUD() {
if (document.getElementById('hacks-hud')) return;
hudContainer = document.createElement('div');
hudContainer.id = 'hacks-hud';
hudContainer.innerHTML = `
<div id="hacks-hud-header">
<span id="hacks-hud-title">MathsOnline Hacks v2.7</span>
<button id="hacks-hud-toggle-btn">HIDE (H)</button>
</div>
<div id="hacks-hud-body">
<div style="color:#888;text-align:center;">Awaiting active question...</div>
</div>
`;
document.body.appendChild(hudContainer);
hudContent = document.getElementById('hacks-hud-body');
document.getElementById('hacks-hud-toggle-btn').addEventListener('click', toggleHUD);
makeDraggable(hudContainer);
}
function makeDraggable(element) {
const header = document.getElementById('hacks-hud-header');
let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
let isDragging = false;
header.onmousedown = function(e) {
if (e.target.id === 'hacks-hud-toggle-btn') return;
e.preventDefault();
pos3 = e.clientX;
pos4 = e.clientY;
isDragging = true;
document.onmousemove = elementDrag;
document.onmouseup = closeDragElement;
};
function elementDrag(e) {
if (!isDragging) return;
e.preventDefault();
pos1 = pos3 - e.clientX;
pos2 = pos4 - e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
element.style.transition = 'none';
element.style.top = (element.offsetTop - pos2) + "px";
element.style.left = (element.offsetLeft - pos1) + "px";
element.style.right = "auto";
}
function closeDragElement() {
isDragging = false;
document.onmousemove = null;
document.onmouseup = null;
element.style.transition = 'opacity 0.2s ease-in-out';
}
}
function toggleHUD() {
isHidden = !isHidden;
hudContainer.classList.toggle('hacks-hidden-hud', isHidden);
}
window.addEventListener('keydown', e => { if(e.key.toLowerCase()==='h') toggleHUD(); });
function updateHUD(answers) {
if (!hudContent) return;
if (answers.length === 0) {
hudContent.innerHTML = `<div style="color:#888;text-align:center;">No answers detected yet...</div>`;
return;
}
let html = `<div style="color:#0f0;margin-bottom:12px;font-size:13px;">✅ Correct Answer(s) Found</div>`;
answers.forEach(a => {
html += `
<div class="hacks-answer-row">
<span class="hacks-label">${a.label}:</span>
<span class="hacks-val">${a.answer}</span>
</div>
`;
});
hudContent.innerHTML = html;
}
function analyzeAndProcess(rawText) {
if (typeof rawText !== 'string' || !rawText.includes('"components"')) return;
try {
const data = JSON.parse(rawText);
const found = new Map(); // deduplicate by label+answer
if (data.components && Array.isArray(data.components)) {
data.components.forEach(comp => {
if (!comp.Data) return;
try {
const parsed = JSON.parse(comp.Data);
// Multiple choice
if (comp.ComponentTypeID === "4" && (parsed.Correct === "true" || parsed.Correct === true)) {
const key = `Option ${comp.ComponentID}`;
found.set(key, { label: key, answer: "✅ THIS IS THE CORRECT ANSWER" });
}
// Input field - only real answers (skip placeholders like "xx", empty, or single digits if suspicious)
if (comp.ComponentTypeID === "2" && parsed.Answers) {
const ans = String(parsed.Answers).trim();
if (ans && ans !== "xx" && ans.length > 0) {
const key = `Input Field (Q${comp.QuestionID || '?'})`;
found.set(key, { label: key, answer: ans });
}
}
} catch(e){}
});
}
// Deep scan fallback
function deepScan(obj) {
if (!obj || typeof obj !== 'object') return;
if (obj.Correct === "true" || obj.Correct === true) {
const key = `Option ${obj.ComponentID || '?'}`;
found.set(key, { label: key, answer: "✅ THIS IS THE CORRECT ANSWER" });
}
if (obj.Answers !== undefined) {
const ans = String(obj.Answers).trim();
if (ans && ans !== "xx" && ans.length > 0) {
const key = `Input Answer`;
found.set(key, { label: key, answer: ans });
}
}
if (Array.isArray(obj)) obj.forEach(deepScan);
else Object.values(obj).forEach(deepScan);
}
deepScan(data);
const finalAnswers = Array.from(found.values());
if (finalAnswers.length > 0) {
updateHUD(finalAnswers);
}
} catch(e) {}
}
// Interceptors
const originalFetch = window.fetch;
window.fetch = async function(...args) {
const res = await originalFetch(...args);
try {
const clone = res.clone();
const text = await clone.text();
analyzeAndProcess(text);
} catch(e){}
return res;
};
const originalOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function() {
this.addEventListener('readystatechange', function() {
if (this.readyState === 4 && this.status === 200) {
analyzeAndProcess(this.responseText);
}
});
return originalOpen.apply(this, arguments);
};
const originalSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(body) {
if (body && typeof body === "string") analyzeAndProcess(body);
return originalSend.apply(this, arguments);
};
window.addEventListener('DOMContentLoaded', () => {
injectStyles();
createHUD();
});
})();