From 61bff36c5c9108a973153252c27280e7f57e8a7a Mon Sep 17 00:00:00 2001 From: tretrauit <3550664-tretrauit@users.noreply.gitlab.com> Date: Sun, 4 Jul 2021 21:12:08 +0000 Subject: [PATCH] Fix chest & jQuery --- Games/Arena_of_Valor/AWC_AutoSpin.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Games/Arena_of_Valor/AWC_AutoSpin.js b/Games/Arena_of_Valor/AWC_AutoSpin.js index b578c1e..957d948 100644 --- a/Games/Arena_of_Valor/AWC_AutoSpin.js +++ b/Games/Arena_of_Valor/AWC_AutoSpin.js @@ -1,7 +1,17 @@ (async function() { // Fetch jQuery - 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) + let jquery = await fetch("https://code.jquery.com/jquery-3.6.0.min.js").then(x => x.text()).then(y => eval(y)) + let meaningOfLife = false; + async function waitForJQuery(){ + while (true) { + if ($ != null){ + $("window").off("mouseup") + return + } + await null; // prevents app from hanging + } + } + waitForJQuery(); { // From https://stackoverflow.com/a/53914092 class ClassWatcher { @@ -48,6 +58,7 @@ } } + var disableChest = false function clickFirstButtonByClassName(className) { document.getElementsByClassName(className)[0].dispatchEvent(new MouseEvent("click")); } @@ -63,12 +74,17 @@ else { // Spin clickFirstButtonByClassName("wheel__main--note") - clickFirstButtonByClassName("chest") - document.getElementsByClassName("widget2").dispatchEvent(new MouseEvent("click")); + if (!disableChest) { + clickFirstButtonByClassName("chest") + } + document.getElementById("widget2").dispatchEvent(new MouseEvent("click")); } } // Close the dialog function closeSwal2() { + if (document.getElementsByClassName("popup-alert__message")[0].innerHTML == "Đã đạt đến giới hạn Rương đếm ngược hàng ngày") { + disableChest = true + } clickFirstButtonByClassName("swal2-close") }