Use 'jQuery' instead of '$'

That fixes jQuery thingy
Also semi-fix card drawing thingy?
This commit is contained in:
tretrauit 2021-07-05 20:10:56 +00:00
parent be75abf7b3
commit 94bcf90208

View File

@ -1,13 +1,6 @@
// Fetch jQuery // Fetch jQuery
await fetch("https://code.jquery.com/jquery-3.6.0.min.js").then(x => x.text()).then(y => eval(y)) await fetch("https://code.jquery.com/jquery-3.6.0.min.js").then(x => x.text()).then(y => eval(y))
// Wait for jQuery to be loaded. // Wait for jQuery to be loaded.
async function execjQuery() {
while (!window.jQuery) {
}
$("window").off("mouseup")
}
execjQuery()
{ {
// From https://stackoverflow.com/a/53914092 // From https://stackoverflow.com/a/53914092
class ClassWatcher { class ClassWatcher {
@ -56,36 +49,61 @@ execjQuery()
var disableChest = false var disableChest = false
function clickFirstButtonByClassName(className) { function clickFirstButtonByClassName(className) {
document.getElementsByClassName(className)[0].dispatchEvent(new MouseEvent("click")); let btn = document.getElementsByClassName(className)[0]
if (!(typeof btn === "undefined")) {
btn.dispatchEvent(new MouseEvent("click"));
}
} }
// Click the spin button // Click the spin button
function spin() { function spin() {
if (document.getElementsByClassName("popup-draw__card").length > 0) { clickFirstButtonByClassName("wheel__main--note")
// Do pick random 3 cards instead of spin. if (!disableChest) {
let teams = document.getElementsByClassName("popup-draw__card") clickFirstButtonByClassName("chest")
for (let i = 0; i < 3; i++) {
teams[i].dispatchEvent(new MouseEvent("click"));
}
} }
else { document.getElementById("widget2").dispatchEvent(new MouseEvent("click"));
// Spin }
clickFirstButtonByClassName("wheel__main--note")
if (!disableChest) { function pickCard() {
clickFirstButtonByClassName("chest") let teams = document.getElementsByClassName("popup-draw__card")
} for (let i = 0; i < 3; i++) {
document.getElementById("widget2").dispatchEvent(new MouseEvent("click")); teams[i].dispatchEvent(new MouseEvent("click"));
} }
} }
// Close the dialog // Check for dialog message then close
function closeSwal2() { function closeSwalDialog() {
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") clickFirstButtonByClassName("swal2-close")
if (document.getElementsByClassName("swal2-close").length > 0) {
setTimeout(closeSwalDialog, 100);
}
}
function Swal2Dialog() {
if (document.getElementsByClassName("popup-draw__card").length > 0) {
pickCard()
}
else {
let swal2msg = document.getElementsByClassName("popup-alert__message")
if (swal2msg.length > 0) {
if (swal2msg[0].innerHTML == "Đã đạt đến giới hạn Rương đếm ngược hàng ngày") {
disableChest = true
}
else if (swal2msg[0].innerHTML == "Bạn đã hết lượt quay trong ngày") {
closeAutoFarm()
}
}
}
closeSwalDialog()
} }
// Watch for SweetAlert 2 // Watch for SweetAlert 2
new ClassWatcher(document.body, 'swal2-shown', closeSwal2, spin); let swal2Watcher = new ClassWatcher(document.body, 'swal2-shown', Swal2Dialog, spin);
// ReactModal__Body--open
function closeAutoFarm() {
swal2Watcher.disconnect()
}
spin() spin()
jQuery("window").off("mouseup")
jQuery("document").off("visibilitychange")
} }