-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.js
127 lines (110 loc) · 3.81 KB
/
home.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
function editR5Text(index, newText) {
const elements = document.querySelectorAll(".text-3xl.text-r5");
elements[index].innerHTML = newText;
}
function editR4Text(index, newText) {
const elements = document.querySelectorAll(".text-3xl.text-r4");
elements[index].innerHTML = newText;
}
function editSpanText(index, newText, className) {
const elements = document.querySelectorAll(`${className}`);
if (index >= 0 && index < elements.length) {
const spanElement = elements[index];
const textNode = spanElement.lastChild; // access the last child node, which should be the text node
textNode.textContent = newText;
} else {
console.error(`Index ${index} is out of range`);
}
}
function editConvenesWorthText(newText) {
const elements = document.querySelectorAll(
".flex.h-fit.w-full.items-center.rounded-2xl.bg-item.p-6"
);
if (elements.length > 0) {
const textNode = elements[0].lastChild; // access the last child node, which should be the text node
textNode.textContent = newText;
} else {
console.error(`Element not found`);
}
}
function getSpanText(index, className) {
const elements = document.querySelectorAll(`${className}`);
if (index >= 0 && index < elements.length) {
const spanElement = elements[index];
const textNode = spanElement.lastChild; // access the last child node, which should be the text node
return textNode.textContent;
} else {
console.error(`Index ${index} is out of range`);
return null;
}
}
if (getSpanText(1, ".text-3xl") != 0) {
var f_reso_five_pity = 10;
var f_weap_five_pity = 9;
var s_weap_five_pity = 37;
var f_reso_four_pity = f_reso_five_pity % 10;
var f_weap_four_pity = f_weap_five_pity % 10;
var s_weap_four_pity = s_weap_five_pity % 10;
editR5Text(0, f_reso_five_pity);
editR5Text(1, f_weap_five_pity);
editR5Text(3, s_weap_five_pity);
editR4Text(0, f_reso_four_pity);
editR4Text(1, f_weap_four_pity);
editR4Text(3, s_weap_four_pity);
fetch(
"https://raw.githubusercontent.com/baka-aho/astrite-gacha/refs/heads/main/featured-resonator.json"
)
.then((response) => response.json())
.then((data) => {
const characters = data.characters;
var totalPullsReso = 0;
characters.forEach((character) => {
totalPullsReso += character.value;
});
totalPullsReso += f_reso_five_pity;
const elements = document.querySelectorAll(".text-3xl");
elements[1].innerHTML = totalPullsReso;
editSpanText(
0,
totalPullsReso * 160,
".flex.items-center.text-neutral-400"
);
return totalPullsReso;
})
.then((totalPullsReso) => {
fetch(
"https://raw.githubusercontent.com/baka-aho/astrite-gacha/refs/heads/main/featured-weapon.json"
)
.then((response) => response.json())
.then((data) => {
const weapons = data.weapons;
var totalPullsWeap = 0;
weapons.forEach((weapon) => {
totalPullsWeap += weapon.value;
});
totalPullsWeap += f_weap_five_pity;
const elements = document.querySelectorAll(".text-3xl");
elements[4].innerHTML = totalPullsWeap;
editSpanText(
1,
totalPullsWeap * 160,
".flex.items-center.text-neutral-400"
);
const totalPullsOverall =
totalPullsReso +
totalPullsWeap +
Number(getSpanText(13, ".text-3xl")) +
Number(getSpanText(16, ".text-3xl")) +
Number(getSpanText(7, ".text-3xl"));
editConvenesWorthText(
` ${(totalPullsOverall * 160).toLocaleString()}`
);
})
.catch((error) => {
console.error("Error fetching data:", error);
});
})
.catch((error) => {
console.error("Error fetching data:", error);
});
}