acquitelol / azalea

The cutest Sparx Maths theming and bookwork bypass extension ~!
45 stars 6 forks source link

Question #1

Closed NajmAjmal-old closed 1 year ago

NajmAjmal-old commented 1 year ago

Hi @acquitelol,

Firstly, I would like to say this project is AMAZING. I have used this extension and can see a lot of hard work has been put in. Secondly, I had a question about this extension. In your description you stated “bookwork-bypass extension for Chromium ~!”, could you further explain this. Does it automatically do the bookwork check? Finally, I also have worked on a similar project, it's called Sintco Sparxmaths Solver. Here you customize your colour themes and during the bookwork check, it highlights the correct answer.

Thanks, Najm

acquitelol commented 1 year ago

Does it automatically do the bookwork check?

TL;DR ~ yes

Some prequisites: Sparx is written in React (with Redux). This means that all of the HTML is rendered with a framework, and if you use document.querySelector(".element") you can access the React side of it through fibers (try Object.keys(document.querySelector("#app-container")).forEach(prop => console.log(document.querySelector("#app-container")[prop])) in the console). Sometimes, it may not be accessible through that specific element, especially if its wrapped by another "component". React components, then, can be accessed through this, and you can access their properties by traveling through these JSON trees. You can experiment with this by using azalea.utilities.findReact(document.querySelector(".alert")) and just examining the tree (on that note there is an entire API you can mess with on window.azalea or azalea for short)

So, I have access to every component's props already through azalea.utilities.findReact(<>), especially class components, and I have access to the Redux Dispatcher (which is sort of a global storage for state and can dispatch "events" to update the UI) through assigning a prop to the Object.__proto__ that would be assigned to the Redux object, and capturing it. This needs to be done at document_load so that it is assigned before any dependencies load.

This means that I can find a relationship between the stored answer (look here) and the markup of the answer in the bookwork check (through iterating through the different options, by accessing the props of the WAC). If there is sufficient relationship, then the answer can be automatically submitted by calling a method on the WAC (Written Answer Check) that takes in answerText, answerChoice, answerOption, notWrittenDown which is called with '', null, option, false by me if I believe that the option is the correct one. At the moment, this is currently a very simple and flawed algorithm, by just using a number regex /[0-9]/g and matching both the option markup and the stored answers, and checking if the option's matches include the stored answer's matches. I am planning to make this algorithm much better eventually, but it can fail the bookwork check (and that is why I made it disableable through Menu > Settings). You can view this entire patch and how it works here.

Also I saw your extension, it's pretty cool! I like your approach on it, by highlighting the proposed correct answers.

~ Rosie <3

acquitelol commented 1 year ago

Since the Sparx-v2 update, it has become significantly harder to mod Sparx, although still possible. However, it might have actually become easier to get automatic bookwork checking, maybe even being able to compare answers directly instead of parts of them, leading to a full automatic submitting. I look at their source code as a reference for my updates, and from what I've seen their code is now wayyyy cleaner and neater, so I wouldn't be surprised if there is a standardized module for Answers and they all follow the same format. :3

Twi543 commented 1 year ago

is it now working with the sparx v2 update? like is the bookwork check logger working? thanks for your help

Twi543 commented 1 year ago

i had an issue with mine

Twi543 commented 1 year ago

If you go to settings icon there are two added things in the drop down menu: settings and themes

acquitelol commented 1 year ago

yep ^^^ just note that the css is very unfinished of course ;3

acquitelol commented 1 year ago

i had an issue with mine

not yet, the bookwork is the last thing i still need to completely redo, it doesnt work at all and thats expected because everything changed

it (should|might) be working by the end of next week if i have time to work on it

Twi543 commented 1 year ago

Oh ok thanks. The rest of it looks really nice. Great UI

StefCoders commented 1 year ago

Where is the log?

acquitelol commented 1 year ago

The log isn't accessible in the UI yet. If you want to list out every bookwork code that was ever saved, run azalea.handlers.storages.bookwork.list() in the console.