Add auto click Chest

Also a workaround for jQuery unbind mouseup event.
This commit is contained in:
tretrauit 2021-07-04 20:02:30 +00:00
parent c44116eee5
commit 01d4db7b8c

View File

@ -1,7 +1,7 @@
// TODO: FIX JQUERY ASYNC (async function() {
// Fetch jQuery // Fetch jQuery
await fetch("https://code.jquery.com/jquery-3.6.0.min.js").then(x => x.text()).then(y => eval(y)).then(() => $("window").off("mouseup")) await fetch("https://code.jquery.com/jquery-3.6.0.min.js").then(x => x.text()).then(y => eval(y))
setTimeout(() => { $("window").off("mouseup") }, 1000)
{ {
// From https://stackoverflow.com/a/53914092 // From https://stackoverflow.com/a/53914092
class ClassWatcher { class ClassWatcher {
@ -54,13 +54,16 @@ await fetch("https://code.jquery.com/jquery-3.6.0.min.js").then(x => x.text()).t
// Click the spin button // Click the spin button
function spin() { function spin() {
if (document.getElementsByClassName("popup-draw__card").length > 0) { if (document.getElementsByClassName("popup-draw__card").length > 0) {
// Do pick random 3 cards instead of spin.
let teams = document.getElementsByClassName("popup-draw__card") let teams = document.getElementsByClassName("popup-draw__card")
for (let i = 0; i < 3; i++) { for (let i = 0; i < 3; i++) {
teams[i].dispatchEvent(new MouseEvent("click")); teams[i].dispatchEvent(new MouseEvent("click"));
} }
} }
else { else {
// Spin
clickFirstButtonByClassName("wheel__main--note") clickFirstButtonByClassName("wheel__main--note")
clickFirstButtonByClassName("chest")
} }
} }
// Close the dialog // Close the dialog
@ -69,6 +72,7 @@ await fetch("https://code.jquery.com/jquery-3.6.0.min.js").then(x => x.text()).t
} }
// Watch for SweetAlert 2 // Watch for SweetAlert 2
let bodywatcher = new ClassWatcher(document.body, 'swal2-shown', closeSwal2, spin); new ClassWatcher(document.body, 'swal2-shown', closeSwal2, spin);
spin() spin()
} }
})();