-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnew.js
77 lines (66 loc) · 2.5 KB
/
new.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
function getCookie(name) {
var v = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
return v ? v[2] : null;
}
// Get incoming invites
// var pageIndex = 0;
// var pageSize = 12;
// var url = `${siteMaster.scApiBase}/friends/getInvites?onlineService=sc&nickname=&pageIndex=${pageIndex}&pageSize=${pageSize}`;
// var method = 'GET';
// Get outgoing invites
// var pageIndex = 0;
// var pageSize = 12;
// var url = `${siteMaster.scApiBase}/friends/getInvitesSent?onlineService=sc&nickname=&pageIndex=${pageIndex}&pageSize=${pageSize}`;
// var method = 'GET';
// Get active friends
// var pageIndex = 0;
// var pageSize = 12;
// var url = `${siteMaster.scApiBase}/friends/getFriendsFiltered?onlineService=sc&nickname=&pageIndex=${pageIndex}&pageSize=${pageSize}`;
// var method = 'GET';
// Cancel outgoing invite
// var rockstarId = '';
// var url = `${siteMaster.scApiBase}/friends/cancelInvite?rockstarId=${rockstarId}&isMyOwnInvite=true`;
// var method = 'POST';
// Cancel incoming invite
// var rockstarId = '';
// var url = `${siteMaster.scApiBase}/friends/cancelInvite?rockstarId=${rockstarId}&isMyOwnInvite=false`;
// var method = 'POST';
// Remove friend
// var rockstarId = '';
// var url = `${siteMaster.scApiBase}/friends/remove?rockstarId=${rockstarId}`;
// var method = 'POST';
// Block player
// var rockstarId = '';
// var url = `${siteMaster.scApiBase}/friends/blockPlayer?rockstarId=${rockstarId}`;
// var method = 'POST';
// Unblock player
// var rockstarId = '';
// var url = `${siteMaster.scApiBase}/friends/unblockPlayer?rockstarId=${rockstarId}`;
// var method = 'POST';
// Search for users containing {searchTerm}
// var searchTerm = '';
// var url = `${siteMaster.scApiBase}/search/user?service=sc&searchTerm=${searchTerm}`;
// var method = 'GET';
function DoRequest(object) {
try {
var bearerToken = GetCookie(siteMaster.scauth.tokenCookieName);
var scApiRequestOptions = {
method: object.method,
credentials: 'same-origin',
cache: 'default',
mode: 'cors',
headers: {
'X-Requested-With': 'XMLHttpRequest',
'X-Lang': 'en-US',
'X-Cache-Ver': '10',
'Authorization': `Bearer ${bearerToken}`
}
};
fetch(object.url, scApiRequestOptions)
.then(response => response.json())
.then(json => object.success(json))
.catch(error => object.error(error))
} catch (error) {
object.error(error);
}
}