feat: add scripts

This commit is contained in:
2023-08-22 01:28:47 +07:00
parent 7fe79a2bdb
commit 92c0e0ee6c
19 changed files with 581 additions and 438 deletions

View File

@ -14,81 +14,88 @@
// ==/UserScript==
function init() {
const chest = document.getElementsByClassName("chest")[0]
const chestStatus = document.getElementsByClassName("chest__btn btn")[0]
const openWheelBtn = document.getElementsByClassName("wheel__btn")[0]
const upgradeBtn = document.getElementsByClassName("card__upgrade")[0]
// Has string characters need to be removed first.
const requiredScore = document.getElementsByClassName("card__note")[0].getElementsByTagName("strong")[0]
const currentScore = document.getElementsByClassName("card__data")[0].getElementsByTagName("span")[1]
const chest = document.getElementsByClassName("chest")[0];
const chestStatus = document.getElementsByClassName("chest__btn btn")[0];
const openWheelBtn = document.getElementsByClassName("wheel__btn")[0];
const upgradeBtn = document.getElementsByClassName("card__upgrade")[0];
// Has string characters need to be removed first.
const requiredScore = document
.getElementsByClassName("card__note")[0]
.getElementsByTagName("strong")[0];
const currentScore = document
.getElementsByClassName("card__data")[0]
.getElementsByTagName("span")[1];
function toInt(str) {
return parseInt(str.replace(/[^0-9]/g, ''))
function toInt(str) {
return parseInt(str.replace(/[^0-9]/g, ""));
}
function upgradeRank() {
if (toInt(currentScore.innerHTML) >= toInt(requiredScore.innerHTML)) {
upgradeBtn.click();
}
}
function upgradeRank() {
if (toInt(currentScore.innerHTML) >= toInt(requiredScore.innerHTML)) {
upgradeBtn.click()
function receiveRankReward() {
const rewards = document.getElementsByClassName("milestone available");
for (const reward of rewards) {
if (reward.className.includes("claimed")) {
continue;
}
reward.click();
}
}
function spinWheel() {
const spinBtn = document.getElementsByClassName("popup-wheel__btn")[0];
const spinLeft = spinBtn.children[1].getElementsByTagName("strong")[0];
function doSpin() {
spinBtn.click();
setTimeout(() => {
if (parseInt(spinLeft.innerHTML) > 0) {
setTimeout(doSpin, 1000);
}
}, 3000);
}
doSpin();
const closeBtn = document.getElementsByClassName("close")[0];
closeBtn.click();
}
function receiveRankReward() {
const rewards = document.getElementsByClassName("milestone available")
for (const reward of rewards) {
if (reward.className.includes("claimed")) {
continue
}
reward.click()
}
function wheel() {
if (
!openWheelBtn.className.includes("animate__tada") ||
document.getElementById("wheel") != null
) {
return;
}
console.log("click chest");
openWheelBtn.click();
setTimeout(spinWheel, 1000);
}
function spinWheel() {
const spinBtn = document.getElementsByClassName("popup-wheel__btn")[0]
const spinLeft = spinBtn.children[1].getElementsByTagName("strong")[0]
function doSpin() {
spinBtn.click()
setTimeout(() => {
if (parseInt(spinLeft.innerHTML) > 0) {
setTimeout(doSpin, 1000)
}
}, 3000)
}
doSpin()
const closeBtn = document.getElementsByClassName("close")[0]
closeBtn.click()
function receiveScore() {
if (chestStatus.innerHTML === "Nhận") {
chest.click();
}
}
function wheel() {
if (!openWheelBtn.className.includes("animate__tada") || document.getElementById("wheel") != null) {
return
}
console.log("click chest")
openWheelBtn.click()
setTimeout(spinWheel, 1000)
setInterval(() => {
if ((element = document.getElementsByClassName("swal2-close")[0])) {
element.click();
}
}, 100);
function receiveScore() {
if (chestStatus.innerHTML === "Nhận") {
chest.click()
}
}
setInterval(() => {
if (element = document.getElementsByClassName("swal2-close")[0]) {
element.click()
}
}, 100);
function loop() {
receiveScore()
upgradeRank()
receiveRankReward()
setTimeout(wheel, 500)
setTimeout(loop, 1000)
}
loop()
function loop() {
receiveScore();
upgradeRank();
receiveRankReward();
setTimeout(wheel, 500);
setTimeout(loop, 1000);
}
loop();
}
setTimeout(init, 5000)
setTimeout(init, 5000);
console.warn("[8thang5 - Auto farm] Successfully loaded")
console.log("Made by @tretrauit under MIT License")
console.warn("[8thang5 - Auto farm] Successfully loaded");
console.log("Made by @tretrauit under MIT License");