This repository has been archived by the owner on Jun 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (34 loc) · 1.73 KB
/
index.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
const { readFile, writeFile } = require("fs").promises;
const { Client } = require("fnbr");
const { writeFileSync } = require("fs");
(async () => {
let auth;
try {
auth = { deviceAuth: JSON.parse(await readFile("./deviceAuth.json")), killOtherTokens: false };
} catch (e) {
auth = { authorizationCode: async () => Client.consoleQuestion("Please enter an authorization code: "), killOtherTokens: false };
}
s = await Client.consoleQuestion("Enter a status you would like to be on your Fortnite Profile: ")
const client = new Client({
auth,
forceNewParty: false,
createParty: false,
connectToXMPP: false,
defaultStatus: s,
defaultOnlineType: "online"
});
client.on("deviceauth:created", (da) => writeFile("./deviceAuth.json", JSON.stringify(da, null, 2)));
client.on("ready", () => console.log(`Logged in as ${client.user.displayName}`));
await client.login();
async function getRawProfile(id, profile) {
const endpoint = `https://fortnite-public-service-prod11.ol.epicgames.com/fortnite/api/game/v2/profile/${id}/client/QueryProfile?profileId=${profile}&rvn=-1`;
const response = await client.http.sendEpicgamesRequest(true, "POST", endpoint, "fortnite", { "Content-Type": "application/json" }, {});
if (response.error) throw response.error;
return response.response;
}
d = await getRawProfile(`${client.user.id}`, "athena");
for (const [key, value] of Object.entries(d["profileChanges"][0]["profile"]["items"])) {
if (value.templateId === "Accolades:accoladeid_stw_mission_sk_victory") return writeFileSync("MSKCount.txt", `MSK Clears: ${value.attributes.earned_count}`);
}
// process.exit();
})();