-
Notifications
You must be signed in to change notification settings - Fork 0
/
presence.ts
90 lines (83 loc) · 3.15 KB
/
presence.ts
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
const presence = new Presence({
clientId: "797596006820085790" //The client ID of the Application created at https://discordapp.com/developers/applications
});
var browsingStamp = Math.floor(Date.now() / 1000);
var flag = "";
function getLevel(index: number)
{
let isMastery = document.getElementsByClassName("skill-level-bar-ni-exp-bar")[index].className.includes("mastery");
return document.getElementsByClassName("skill-level-bar-ni-exp-level")[index].textContent + (isMastery ? "M" : "");
}
presence.on("UpdateData", async () => {
const presenceData: PresenceData = {
largeImageKey: "idlescape"
};
var titleFormatted = document.getElementsByClassName("status-action")[0].textContent;
if(flag == ""){
flag = titleFormatted;
}
if(flag != titleFormatted){
browsingStamp = Math.floor(Date.now() / 1000);
}
presenceData.startTimestamp = browsingStamp;
if (document.location.pathname == "/" || document.location.pathname == "/characters") {
presenceData.details = "Choosing a character";
} else {
presenceData.details = titleFormatted;
if((<HTMLImageElement>document.getElementsByClassName("header-league-icon")[0]).src.startsWith("https://idlescape.com/images/leagues/ironman")) {
var league = "Ironman League";
} else {
var league = "Normal League";
}
presenceData.state = document.getElementsByClassName("navbar1-box left drawer-button noselect")[0].textContent.substring(2) + "in " + league;
if(titleFormatted.startsWith("Mining")){
presenceData.smallImageText = "Mining level : " + getLevel(0);
presenceData.smallImageKey = "mining";
}
else if(titleFormatted.startsWith("Foraging"))
{
presenceData.smallImageText = "Foraging level : " + getLevel(1);
presenceData.smallImageKey = "foraging";
}
else if(titleFormatted.startsWith("Fishing"))
{
presenceData.smallImageText = "Fishing level : " + getLevel(2);
presenceData.smallImageKey = "fishing";
}
else if(titleFormatted.startsWith("Smithing"))
{
presenceData.smallImageText = "Smithing level : " + getLevel(3);
presenceData.smallImageKey = "smithing";
}
else if(titleFormatted.startsWith("Cooking"))
{
presenceData.smallImageText = "Cooking level : " + getLevel(5);
presenceData.smallImageKey = "cooking";
}
else if(titleFormatted.startsWith("Runecrafting"))
{
presenceData.smallImageText = "Runecrafting level : " + getLevel(7);
presenceData.smallImageKey = "runecrafting";
}
else if(titleFormatted.startsWith("Enchanting"))
{
presenceData.details = "Scrollcrafting";
presenceData.smallImageText = "Enchanting level : " + getLevel(8);
presenceData.smallImageKey = "enchanting";
}
else if(titleFormatted.startsWith("Fighting"))
{
presenceData.smallImageText = "HP:" + getLevel(9) +
", ATK:" + getLevel(10) +
", STR:" + getLevel(11) +
", DEF:" + getLevel(12);
presenceData.smallImageKey = "fighting";
}
}
if (presenceData.details == null) {
presence.setTrayTitle();
presence.setActivity();
} else {
presence.setActivity(presenceData);
}
});