-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSteamAwardsVote.js
68 lines (63 loc) · 1.98 KB
/
SteamAwardsVote.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
// 1.3.0-2022Winter
var LinkVote = "https://store.steampowered.com/salevote";
var Votes = [ // fallback votes; empty for random
1245620, // ELDEN RING
1592190, // BONELAB
570, // Dota 2
1144200, // Ready or Not
698670, // Scorn
1637320, // Dome Keeper
1245620, // ELDEN RING
1462040, // FINAL FANTASY VII REMAKE INTERGRADE
1703340, // The Stanley Parable: Ultra Deluxe
1455840, // Dorfromantik
1794680, // Vampire Survivors
];
var Shift = 72; // starting nomination index; continues from previous year
var NominatedApps = [];
var MarkedAsNominated = document.getElementsByClassName("user_nominated_app");
if (MarkedAsNominated.length > 0) {
for (let App of MarkedAsNominated) {
App = App.parentElement;
NominatedApps[App.dataset["voteid"]] = App.dataset["voteAppid"];
console.log(`Previously nominated app ${App.dataset["voteAppid"]} in category ${App.dataset["voteid"]}`);
};
};
function GenerateVotes() {
g_rgAwardSectionScrollDefs.forEach((Section) => {
let Category = Section.voteid;
if (Category in NominatedApps) {
Votes[Category - Shift] = NominatedApps[Category];
} else {
let VoteRNG = Math.floor(Math.random() * Section.rgApps.length);
VoteRNG = Section.rgApps[VoteRNG].dataset["voteAppid"];
Votes[Category - Shift] = VoteRNG;
console.log(`Randomly picked app ${VoteRNG} for Section ${Category}`);
};
});
PostVotes();
};
function PostVotes(Category = 0) {
var Init = {
method: "Post",
credentials: "include",
body: new FormData()
};
Init.body.append("sessionid", g_sessionID);
Init.body.append("voteid", Category + Shift);
Init.body.append("appid", Votes[Category]);
Init.body.append("developerid", 0);
fetch(LinkVote, Init).catch((Message) => {
console.error("Voting error:", Message);
});
if (++Category < Votes.length) {
setTimeout(PostVotes, 500, Category);
} else {
console.log("Voting done");
};
};
if (Votes.length > 0) {
PostVotes();
} else {
GenerateVotes();
};