-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathUbisoft Connect - Add Uplay Friend.js
87 lines (76 loc) · 2.88 KB
/
Ubisoft Connect - Add Uplay Friend.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
// The uplay group list, please change
const UPLAYGROUP = `
PERSON1
PERSON2
PERSON3
ETC
REPLACE THIS
PASTE THE UPLAY GROUP LIST HERE
`;
// The code, do not touch
/* eslint-disable no-console */
const DELAY = 4000;
function sleep(ms) {
return new Promise((res) => setTimeout(res, ms));
}
// the code, do not touch
async function addUplayFriend(name, delay) {
if (delay) {
await sleep(delay);
}
let data = JSON.parse(localStorage.PRODOverlayConnectLoginData);
let { profiles } = await fetch(`https://public-ubiservices.ubi.com/v2/profiles?nameOnPlatform=${name}&platformType=uplay`, {
"headers": {
"accept": "*/*",
"accept-language": "en",
"authorization": `Ubi_v1 t=${data.ticket}`,
"cache-control": "no-cache",
"pragma": "no-cache",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "cross-site",
"sec-gpc": "1",
"ubi-appid": "314d4fef-e568-454a-ae06-43e3bece12a6",
"ubi-sessionid": data.sessionId,
},
"referrer": "https://connect.ubisoft.com/",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "omit",
}).then((res) => res.json());
let friend = profiles[0];
if (!friend) {
throw new Error(`Could not find uplay user: ${name}`);
}
let result = await fetch(`https://public-ubiservices.ubi.com/v3/profiles/${data.user_id}/friends`, {
"headers": {
"accept": "*/*",
"accept-language": "en",
"authorization": `Ubi_v1 t=${data.ticket}`,
"cache-control": "no-cache",
"content-type": "application/json;charset=UTF-8",
"pragma": "no-cache",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "cross-site",
"sec-gpc": "1",
"ubi-appid": "314d4fef-e568-454a-ae06-43e3bece12a6",
"ubi-sessionid": data.sessionId,
},
"referrer": "https://connect.ubisoft.com/",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": `{"friends":["${friend.userId}"]}`,
"method": "POST",
"mode": "cors",
"credentials": "omit",
}).then((res) => res.json());
console.log("Added Uplay Friend", JSON.stringify({ friend, result }, null, 4));
}
(async() => {
await Promise.all(UPLAYGROUP.split("\n").map((l) => l.trim())
.filter((l) => l.length > 0)
.map((name, i) => addUplayFriend(name, i * DELAY).catch((err) => console.error(err))));
console.log("Done adding all Uplay friends!\nLove, Revadike <3");
})();