Use 'jQuery' instead of '$'
That fixes jQuery thingy Also semi-fix card drawing thingy?
This commit is contained in:
parent
be75abf7b3
commit
94bcf90208
@ -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) {
|
|
||||||
// Do pick random 3 cards instead of spin.
|
|
||||||
let teams = document.getElementsByClassName("popup-draw__card")
|
|
||||||
for (let i = 0; i < 3; i++) {
|
|
||||||
teams[i].dispatchEvent(new MouseEvent("click"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Spin
|
|
||||||
clickFirstButtonByClassName("wheel__main--note")
|
clickFirstButtonByClassName("wheel__main--note")
|
||||||
if (!disableChest) {
|
if (!disableChest) {
|
||||||
clickFirstButtonByClassName("chest")
|
clickFirstButtonByClassName("chest")
|
||||||
}
|
}
|
||||||
document.getElementById("widget2").dispatchEvent(new MouseEvent("click"));
|
document.getElementById("widget2").dispatchEvent(new MouseEvent("click"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pickCard() {
|
||||||
|
let teams = document.getElementsByClassName("popup-draw__card")
|
||||||
|
for (let i = 0; i < 3; i++) {
|
||||||
|
teams[i].dispatchEvent(new MouseEvent("click"));
|
||||||
}
|
}
|
||||||
// Close the dialog
|
}
|
||||||
function closeSwal2() {
|
// Check for dialog message then close
|
||||||
if (document.getElementsByClassName("popup-alert__message")[0].innerHTML == "Đã đạt đến giới hạn Rương đếm ngược hàng ngày") {
|
function closeSwalDialog() {
|
||||||
|
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
|
disableChest = true
|
||||||
}
|
}
|
||||||
clickFirstButtonByClassName("swal2-close")
|
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")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user