ilytobias / Khan-Destroyer

A Khan hack which includes: Answer Overwrite, Answer Revealer, Auto Answer, And a Energy point farmer.
Mozilla Public License 2.0
109 stars 48 forks source link

Energy point farmer: pointsgained, farm is not defined #7

Closed i0Z3R0 closed 4 months ago

i0Z3R0 commented 4 months ago

Describe the bug

Issue with energy point farmer

Screenshot 2024-07-06 at 1 55 42 PM

Steps to reproduce

Click on the bookmark
Enter an URL
Click on farm
Nothing runs, and console shows the error above

Are you stupid

no

Operating System

macOS

Browser

Chrome

Before submitting a bug report

ilytobias commented 4 months ago

I don't wanna work on this anymore, I spent 4 hours on this yesturday, run this code in your console. I will patch later.

for (let i = 0; i < 1e4; i++) {
    clearInterval(i)
}
document.open();
document.write(`
    <style>
        body {
            margin: 0;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #2c2f33;
            color: #ffffff;
        }
        #app {
            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }
        header, footer {
            background-color: #23272a;
            padding: 1em;
            text-align: center;
        }
        main {
            flex: 1;
            padding: 2em;
        }
        .card {
            background-color: #36393f;
            border-radius: 8px;
            padding: 1em;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        }
        a {
            color: #7289da;
            text-decoration: none;
        }
        a:hover {
            text-decoration: underline;
        }
        input {
            background-color: #36393f;
            border-radius: 8px;
            padding: 1em;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            color: white;
            margin-bottom: 1em;
        }
        button {
            background-color: #7289da;
            border-radius: 8px;
            padding: 1em;
            color: white;
            border: none;
            cursor: pointer;
        }
        button:hover {
            background-color: #5a6fb3;
        }
        p {
            margin: 0.5em 0;
        }
    </style>
    <div id="app">
        <header>
            <h1>Farmer</h1>
        </header>
        <main>
            <section class="card">
                <h2>Points, <span id="total"></span></h2>
                <p>Please enter in a link to a unique Khan lesson or <a href="/">let me</a> get one for you.</p>
            </section>
            <input id="input" placeholder="URL..."></input>
            <button onclick="farm()">Farm</button>
            <p>Rigs farming: <span id="lessonsFarming">0</span></p>
            <p>EP gained: <span id="pointsFarmed">0</span></p>
             <p>EP gained (1m): <span id="min">0</span></p>
        </main>
        <footer>
            <p>&copy; 2024 IlyTobias</p>
        </footer>
    </div>
`);
document.close();
let totalPoints = 0;
let previousPoints = 0;
let totalGainedPoints = 0;

function extractPoints() {
    let pointsIfr = document.createElement("iframe");
    pointsIfr.src = "https://www.khanacademy.org/profile/me/courses";
    document.body.appendChild(pointsIfr);
    pointsIfr.onload = function () {
        setTimeout(function () {
            let pointsText = "";
            for (let i of pointsIfr.contentWindow.document.getElementsByClassName(
                    "odometer-ribbon-inner")) {
                pointsText += i.textContent
            }
            pointsIfr.remove();
            let currentPoints = parseInt(pointsText.replace(/,/g, ""), 10);
            if (!isNaN(currentPoints)) {
                if (previousPoints === 0) {
                    window.pointsGained = 0
                }
                else {
                    window.pointsGained = currentPoints - previousPoints
                }
                totalPoints = currentPoints;
                totalGainedPoints += pointsGained;
                document.getElementById("pointsFarmed").textContent = totalGainedPoints;
                document.getElementById("min").innerText = pointsGained;
                document.getElementById("total").innerText = totalPoints;
                previousPoints = totalPoints
            }
            else {}
        }, 3e3)
    }
}
setInterval(extractPoints, 6e4);
extractPoints();

function farm(url = document.getElementById("input").value) {
    (function () {
        let div = document.createElement("div");
        const key = Math.floor(Math.random() * 1e8);
        div.innerHTML = `<iframe id="egg${key}" style="display:none;" src="${url}"></iframe>`;
        document.body.appendChild(div);
        let script = document.createElement("script");
        script.innerHTML =
            `const de=function(e,t){let n=document.getElementsByTagName(e);for(let i=0;i<n.length;i++){if(n[i].textContent.trim()===t){return n[i]}}return null};function e(e,t){let n=de(e,t);if(n){n.scrollIntoView();n.click()}}function t(e){let t=document.getElementsByClassName(e)[0];if(t){t.scrollIntoView();t.click()}}setInterval(function(){e("button","Let’s go");t("_ssxvf9l");e("button","Check");e("button","Try again");e("button","Next question");e("button","Show summary")},3e3);for (let i = 0; i < document.getElementsByTagName("style").length; i++){document.getElementsByTagName("style")[i].remove();};`;
        document.getElementById("egg" + key).contentWindow.document.body.appendChild(script);
        let l = JSON.parse;
        document.getElementById("egg" + key).contentWindow.JSON.parse = function (e, t) {
            let a = l(e, t);
            try {
                for (let n = 0; n < Object.keys(a.data).length; n++) {
                    let e = a.data[Object.keys(a.data)[n]];
                    let t = Object.keys(a.data)[n];
                    if (t === "assessmentItem") {
                        console.log(e);
                        a.data[Object.keys(a.data)[n]].item.itemData =
                            '{"answerArea":{"calculator":false,"chi2Table":false,"periodicTable":false,"tTable":false,"zTable":false},"hints":[{"content":"$\\\\begin{align}\\\\left(\\\\dfrac{z^{4}}{6^{2}}\\\\right)^{-3}&=\\\\dfrac{\\\\left(z^{4}\\\\right)^{-3}}{\\\\left(6^{2}\\\\right)^{-3}}\\\\end{align}$","images":{},"replace":false,"widgets":{}},{"content":"$\\\\begin{align}\\\\phantom{\\\\left(\\\\dfrac{z^{4}}{6^{2}}\\\\right)^{-3}}&=\\\\dfrac{z^{(4)(-3)}}{6^{(2)(-3)}}\\\\n\\\\dfrac{6^{6}}{z^{12}}\\\\end{align}$","images":{},"replace":false,"widgets":{}}],"itemDataVersion":{"major":0,"minor":1},"question":{"content":"Khan cheat made by ilyTobias[[☃ radio 1]]","images":{},"widgets":{"radio 1":{"alignment":"default","graded":true,"options":{"choices":[{"content":"Correct answer","correct":true},{"content":"Incorrect answer","correct":false}],"deselectEnabled":false,"displayCount":null,"hasNoneOfTheAbove":false,"multipleSelect":false,"onePerLine":true,"randomize":false},"static":false,"type":"radio","version":{"major":1,"minor":0}}}}}'
                    }
                }
            }
            catch (n) {}
            return a
        }
    })()
}
ilytobias commented 4 months ago

fixed.