fix: better tag filter

Also formatted it with biomejs

I didn't realize that Honkai Star R(ai)l has AI in it 💀
This commit is contained in:
2024-03-07 00:39:56 +07:00
parent 7e07d807d5
commit c28408cabc
8 changed files with 262 additions and 250 deletions

View File

@ -14,86 +14,86 @@
// ==/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 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 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 wheel() {
if (
!openWheelBtn.className.includes("animate__tada") ||
document.getElementById("wheel") != null
) {
return;
}
console.log("click chest");
openWheelBtn.click();
setTimeout(spinWheel, 1000);
}
function wheel() {
if (
!openWheelBtn.className.includes("animate__tada") ||
document.getElementById("wheel") != null
) {
return;
}
console.log("click chest");
openWheelBtn.click();
setTimeout(spinWheel, 1000);
}
function receiveScore() {
if (chestStatus.innerHTML === "Nhận") {
chest.click();
}
}
function receiveScore() {
if (chestStatus.innerHTML === "Nhận") {
chest.click();
}
}
setInterval(() => {
if ((element = document.getElementsByClassName("swal2-close")[0])) {
element.click();
}
}, 100);
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);