Skip to content

Commit

Permalink
Use simpler finder for SparxWeb
Browse files Browse the repository at this point in the history
  • Loading branch information
acquitelol committed Jul 14, 2023
1 parent d49c6e5 commit 7c198c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
17 changes: 6 additions & 11 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@

Themer.setTheme(labels[0]);

const AppContainer = document.getElementById("app-container");
const ReactRoot = AppContainer._reactRootContainer._internalRoot;
const ReactPendingProps = ReactRoot.current.child.pendingProps;
const Contexts = ReactPendingProps.children.props.children.props.children[0];
const SparxWebContainer = Contexts.props.children.props.children[1].type;

// Component prototypes to patch (Thank god these are all class-based components!)
const SparxWeb = SparxWebContainer.WrappedComponent.prototype;
const SparxWeb = findReact(document.getElementsByClassName('screen')[0]);
const WACOverlay = findReact(document.getElementsByClassName('wac-overlay')[0]);
const StatusBar = findReact(document.getElementsByClassName("status")[0]);

// This will adapt whenever SparxWeb re-renders
let dynamicSubmitButton = document.getElementById("skill-delivery-submit-button");

// Listen for Enter keypresses and store the answer when the dynamicSubmitButton exists (is in scope)
document.addEventListener("keypress", function(event) {
event.key === "Enter" && dynamicSubmitButton && storeAnswers();
})

// Assigns submit button and props to document for easier access
Patcher.after("render", SparxWeb, function() {
document.__props = this.props;
Expand Down Expand Up @@ -124,8 +123,4 @@

return res;
})

document.addEventListener("keypress", function(event) {
event.key === "Enter" && dynamicSubmitButton && storeAnswers();
})
})();
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CutestBypass",
"version": "1.5.0",
"version": "1.5.1",
"description": "Gives you access to many useful tools on SparxMaths!",
"manifest_version": 3,
"author": "Rosie",
Expand Down

0 comments on commit 7c198c2

Please sign in to comment.