I don't know if this question is against the rules, so I'll understand if it gets deleted or if I receive a punishment.
The following script creates an alert with the answer of a multiple choice exercise in Khanacademy. It works basically in all exercises that have an "A B C" type selectable multiple choice answers. It used to work perfectly before, but now the console spits out the following error:
ERROR: Execution of script 'KA Multiple Choice' failed! Cannot read property 'props' of undefined
I don't know if the method used was patched, but I would like to know if I can do anything to fix it.
Here is the script:
const arrayanswers = JSON.parse(window["./javascript/app-shell-package/app-entry.js"].props.componentProps.initialItem.itemData).question.widgets["radio 1"].options.choices,
filtered = arrayanswers.reduce((acc, item, index) => ((item.correct) ? [...acc, index] : acc), []);
alert("0 = Option A" + '\n' + "1 = Option B" + '\n' + "2 = Option C" + '\n' + "3 = Option D" + '\n' + "Answers are: " + `${filtered.join(', ')}`);
EDIT: I got it working by using a Snippet from Chrome. However, I would still like to make it work in Tampermonkey.