// ==UserScript==
// @name C0dedlegacy - KeyCash Ultimate Solver
// @match https://keycash.pro/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
console.log("[Auto-Solver] Script initialized.");
// Create HUD for tracking
const hud = document.createElement('div');
hud.style = "position:fixed;top:10px;left:10px;padding:10px;background:rgba(0,0,0,0.8);color:#0f0;z-index:9999;font-family:monospace;border:1px solid #0f0;pointer-events:none;";
document.documentElement.appendChild(hud);
function solve(res) {
if (!res.success) return;
// Update HUD if solve data exists
if (res.total !== undefined) {
hud.innerHTML = `TOTAL: ${res.total}<br>SOLVES: ${res.math_solves}`;
// Look for "Next" buttons after a win
setTimeout(() => {
const nextBtn = Array.from(document.querySelectorAll('button, a, .btn')).find(el =>
/next|continue|play/i.test(el.innerText)
);
if (nextBtn) nextBtn.click();
}, 1000);
return;
}
// Arithmetic Solver
if (res.a !== undefined && res.b !== undefined) {
const a = parseFloat(res.a);
const b = parseFloat(res.b);
let ans;
switch (res.op) {
case '-': ans = a - b; break;
case 'x': case '×': case '\u00d7': ans = a * b; break;
case '/': case '÷': case '\u00f7': ans = a / b; break;
default: ans = a + b;
}
console.log(`[Auto-Solver] ${a} ${res.op} ${b} = ${ans}`);
setTimeout(() => {
const buttons = Array.from(document.querySelectorAll('button, .option, .choice'));
const target = buttons.find(btn => btn.innerText.trim() == ans);
if (target) target.click();
}, 400);
}
}
// Intercept XHR
const oldOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function() {
this.addEventListener('load', () => {
try { solve(JSON.parse(this.responseText)); } catch (e) {}
});
return oldOpen.apply(this, arguments);
};
// Intercept Fetch
const oldFetch = window.fetch;
window.fetch = async (...args) => {
const response = await oldFetch(...args);
const clone = response.clone();
clone.text().then(text => {
try { solve(JSON.parse(text)); } catch (e) {}
});
return response;
};
})();