ilytobias / Khan-Destroyer

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

Answer Revealer userscript deprecated #15

Open T3M1N4L opened 1 week ago

T3M1N4L commented 1 week ago

Describe the bug

Khan Academy gives a crash message when the user script is on, I then tried to update the user script to the latest version but tamper monkey simply says it's not a valid user script. I see you updated the bookmarklet a few hours ago, but I am on the arc browser, rendering bookmarklets useless. Please update the userscript

Steps to reproduce

1. Have the userscript on [if possible]
2. Go to any lesson on khan academy, then it crashes

--

1. Go to revealer.user.js, copy paste it in to tampermonkey
2. Tampermonkey gives error [invalid userscirpt]

Are you stupid

yeah probably

Operating System

Windows

Browser

Arc Browser

Before submitting a bug report

T3M1N4L commented 1 week ago

Looks like khan academy may have patched it, as I converted the bookmarklet into a console command and ran it, and Khan Academy just reloaded.

This is what I used -

if (typeof originalParse === "undefined") {
    window.originalParse = JSON.parse;
}

JSON.parse = function (t, e) {
    let n = originalParse(t, e);

    try {
        const itemData = JSON.parse(n.data.assessmentItem.item.itemData);
        const isPT = location.hostname.split(".")[0] === "pt";

        if (itemData.question && itemData.question.content &&
            itemData.question.content[1] === itemData.question.content[1].toUpperCase()) {

            console.log(itemData);

            itemData.question.content += "\n [[☃ explanation 3]] [[☃ explanation 4]]";

            itemData.question.widgets["explanation 3"] = {
                alignment: "default",
                graded: true,
                options: {
                    explanation: itemData.hints[itemData.hints.length - 1].content,
                    hidePrompt: isPT ? "Ocultar" : "Hide",
                    showPrompt: isPT ? "Resposta" : "Answer",
                    static: false,
                    widgets: itemData.hints[itemData.hints.length - 1]
                }
            };

            itemData.question.widgets["explanation 4"] = {
                options: {
                    explanation: "discord.gg/khanacademy",
                    hidePrompt: "",
                    showPrompt: "Discord"
                }
            };

            n.data.assessmentItem.item.itemData = JSON.stringify(itemData);
        }
    } catch (error) {
        console.error("Error parsing lesson data:", error);
    }

    return n;
};

location.softReload = () => {
    const htmlContent = document.getElementsByTagName("html")[0].outerHTML;
    document.open();
    document.write(htmlContent);
    document.close();
};

location.softReload();

console.error = function () {};
T3M1N4L commented 1 week ago

I found the userscript i was using, I was using @doxrgithub 's

// ==UserScript==
// @name         Khan answer revealer
// @version      1.0
// @description  Khan hack
// @author       IlyTobias (github@ilytobias)
// @match        https://www.khanacademy.org/*
// @grant        none
// ==/UserScript==

let n = JSON.parse;
JSON.parse = function (t) {
    let e = n(t);
    try {
        let t = JSON.parse(e.data.assessmentItem.item.itemData);
        t.question.content = t.question.content + "[[☃ explanation 2]]";
        console.log(t);
        t.question.widgets["explanation 2"] = {
            alignment: "default"
            , graded: true
            , options: {
                explanation: t.hints[t.hints.length - 1].content
                , hidePrompt: "Hide"
                , showPrompt: "Answer"
                , static: false
                , widgets: t.hints[t.hints.length - 1].widgets
            }
            , static: false
            , type: "explanation"
            , version: {
                major: 0
                , minor: 0
            }
        };
        e.data.assessmentItem.item.itemData = JSON.stringify(t)
    } catch (t) {}
    return e
}

This returns a crash screen now image

On math it returns a full white crash [uh-oh] screen

ArdC-137 commented 1 week ago

Upup!! He's right.