gj-boomlings-api 1.4.3 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/config.json +1 -1
  3. package/functions/blockUser.js +7 -6
  4. package/functions/deleteAccountPost.js +7 -6
  5. package/functions/deleteComment.js +5 -4
  6. package/functions/deleteLevel.js +8 -4
  7. package/functions/dlLevel.js +15 -27
  8. package/functions/dlMessage.js +10 -3
  9. package/functions/getAccountPosts.js +8 -4
  10. package/functions/getBlockedList.js +9 -2
  11. package/functions/getCommentHistory.js +8 -4
  12. package/functions/getComments.js +8 -4
  13. package/functions/getCreatorScores.js +6 -1
  14. package/functions/getFriendsList.js +12 -2
  15. package/functions/getGauntlets.js +6 -4
  16. package/functions/getLevelByID.js +8 -4
  17. package/functions/getMapPacks.js +7 -0
  18. package/functions/getMessages.js +9 -2
  19. package/functions/getOfficialSongInfo.js +1 -1
  20. package/functions/getProfile.js +8 -4
  21. package/functions/getSongInfo.js +8 -1
  22. package/functions/getTop100.js +2 -0
  23. package/functions/getUserLevels.js +9 -2
  24. package/functions/reportLevel.js +3 -1
  25. package/functions/searchLevels.js +7 -0
  26. package/functions/searchUsers.js +7 -3
  27. package/functions/unblockUser.js +7 -6
  28. package/functions/updateLevelDesc.js +8 -4
  29. package/functions/uploadAccountPost.js +7 -6
  30. package/functions/uploadComment.js +10 -6
  31. package/functions/uploadMessage.js +10 -6
  32. package/index.js +0 -3
  33. package/misc/decCommentFromHistory.js +2 -0
  34. package/misc/decodeGJGauntlet.js +25 -30
  35. package/misc/decodeLevel.js +9 -32
  36. package/misc/decodeLevelRes.js +10 -27
  37. package/misc/gjReq.js +0 -2
  38. package/misc/gjWReq.js +10 -0
  39. package/misc/rgbToHEX.js +1 -1
  40. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <div align="center">
2
2
  <h1>
3
- <a href="https://www.npmjs.com/package/gj-boomlings-api"><img src="https://shikoshib.github.io/font1.png" width="576"></a>
3
+ <a href="https://www.npmjs.com/package/gj-boomlings-api"><img src="https://shikoshib.github.io/font1.png" width="500"></a>
4
4
  </h1>
5
5
  A light-weight Geometry Dash API wrapper<br><br><a href="https://github.com/shikoshib/gj-boomlings-api/wiki"><b>Documentation</b></a><br><br>
6
6
  <a href="https://www.npmjs.com/package/gj-boomlings-api"><img src="https://img.shields.io/npm/v/gj-boomlings-api.svg?maxAge=3600" alt="npm version" /></a>
package/config.json CHANGED
@@ -5,6 +5,6 @@
5
5
  "Accept-Encoding":"*",
6
6
  "Accept":"*/*"
7
7
  },
8
- "server":"https://www.boomlings.com/database/",
8
+ "server":"http://www.boomlings.com/database/",
9
9
  "secret":"Wmfd2893gb7"
10
10
  }
@@ -1,11 +1,12 @@
1
1
  module.exports = {
2
2
  blockUser:
3
3
  async function(target, username, password) {
4
- if(!target || target == "") throw new Error("Please provide a target's player ID or username!");
5
- if(!username || username == "") throw new Error("Please provide your player ID or username!");
6
- if(!password || password == "") throw new Error("Please provide your password!");
4
+ if(!target) throw new Error("Please provide a target's player ID or username!");
5
+ if(!username) throw new Error("Please provide your player ID or username!");
6
+ if(!password) throw new Error("Please provide your password!");
7
7
 
8
8
  const {gjReq} = require("../misc/gjReq.js");
9
+ const {gjWReq} = require("../misc/gjWReq.js");
9
10
  const { searchUsers } = require("./searchUsers.js");
10
11
 
11
12
  let user = await searchUsers(username);
@@ -14,9 +15,6 @@ module.exports = {
14
15
  const {gjp} = require("../misc/gjp.js");
15
16
 
16
17
  const data = {
17
- gameVersion: 21,
18
- binaryVersion: 35,
19
- gdw: 0,
20
18
  secret: "Wmfd2893gb7",
21
19
  targetAccountID: targetObj.accountID,
22
20
  accountID: user.accountID,
@@ -26,6 +24,9 @@ module.exports = {
26
24
  let res = await gjReq("blockGJUser20", data);
27
25
  if(res.data == -1) throw new Error(-1);
28
26
 
27
+ if(res.data.startsWith("error code")) res = await gjWReq("blockUser", `${target}?user=${username}&password=${password}`);
28
+ if(res.status == 403) throw new Error(res.data.error);
29
+
29
30
  return 1;
30
31
  }
31
32
  }
@@ -1,11 +1,12 @@
1
1
  module.exports = {
2
2
  deleteAccountPost:
3
3
  async function(id, str, password) {
4
- if(!id || id == "") throw new Error("Please provide an account post ID!");
5
- if(!str || str == "") throw new Error("Please provide a user ID or name!");
6
- if(!password || password == "") throw new Error("Please provide a password!");
4
+ if(!id) throw new Error("Please provide an account post ID!");
5
+ if(!str) throw new Error("Please provide a user ID or name!");
6
+ if(!password) throw new Error("Please provide a password!");
7
7
 
8
8
  const {gjReq} = require("../misc/gjReq.js");
9
+ const {gjWReq} = require("../misc/gjWReq.js");
9
10
  const { searchUsers } = require("./searchUsers.js");
10
11
 
11
12
  let user = await searchUsers(str);
@@ -14,9 +15,6 @@ module.exports = {
14
15
  const xor = new XOR();
15
16
 
16
17
  let data = {
17
- gameVersion: 21,
18
- binaryVersion: 35,
19
- gdw: 0,
20
18
  accountID: user.accountID,
21
19
  secret: "Wmfd2893gb7",
22
20
  gjp: xor.encrypt(password, 37526),
@@ -26,6 +24,9 @@ module.exports = {
26
24
  let res = await gjReq("deleteGJAccComment20", data);
27
25
  if(res.data == -1) throw new Error(-1);
28
26
 
27
+ if(res.data.startsWith("error code")) res = await gjWReq("deleteAccountPost", `?id=${id}&user=${str}&password=${password}`);
28
+ if(res.status == 403) throw new Error(res.data.error);
29
+
29
30
  return 1;
30
31
  }
31
32
  }
@@ -1,12 +1,13 @@
1
1
  module.exports = {
2
2
  deleteComment:
3
3
  async function(id, lvl, str, password) {
4
- if(!id || id == "") throw new Error("Please provide a comment ID!");
5
- if(!lvl || lvl == "") throw new Error("Please provide a level ID!");
6
- if(!str || str == "") throw new Error("Please provide a user ID or name!");
7
- if(!password || password == "") throw new Error("Please provide a password!");
4
+ if(!id) throw new Error("Please provide a comment ID!");
5
+ if(!lvl) throw new Error("Please provide a level ID!");
6
+ if(!str) throw new Error("Please provide a user ID or name!");
7
+ if(!password) throw new Error("Please provide a password!");
8
8
 
9
9
  const {gjReq} = require("../misc/gjReq.js");
10
+ const {gjWReq} = require("../misc/gjWReq.js");
10
11
  const { searchUsers } = require("./searchUsers.js");
11
12
 
12
13
  let user = await searchUsers(str);
@@ -1,11 +1,12 @@
1
1
  module.exports = {
2
2
  deleteLevel:
3
3
  async function(lvl, str, password) {
4
- if(!lvl || lvl == "") throw new Error("Please provide a level ID!");
5
- if(!str || str == "") throw new Error("Please provide a user ID or name!");
6
- if(!password || password == "") throw new Error("Please provide a password!");
4
+ if(!lvl) throw new Error("Please provide a level ID!");
5
+ if(!str) throw new Error("Please provide a user ID or name!");
6
+ if(!password) throw new Error("Please provide a password!");
7
7
 
8
8
  const {gjReq} = require("../misc/gjReq.js");
9
+ const {gjWReq} = require("../misc/gjWReq.js");
9
10
  const { searchUsers } = require("./searchUsers.js");
10
11
  const {gjp} = require("../misc/gjp.js");
11
12
 
@@ -21,6 +22,9 @@ module.exports = {
21
22
  let res = await gjReq("deleteGJLevelUser20", data);
22
23
  if(res.data == -1) throw new Error(-1);
23
24
 
24
- return 1;
25
+ if(res.data.startsWith("error code")) res = await gjWReq("deleteLevel", `${lvl}?user=${str}&password=${password}`);
26
+ if(res.status == 403) throw new Error(res.data.error);
27
+
28
+ return res.data;
25
29
  }
26
30
  }
@@ -3,19 +3,17 @@ module.exports = {
3
3
  async function(level) {
4
4
  const {decB64} = require("../misc/decB64.js");
5
5
  const zlib = require("zlib");
6
- if(!level || level == "") throw new Error("Please provide a level ID.");
6
+ if(!level) throw new Error("Please provide a level ID.");
7
7
  if(isNaN(level)) throw new Error("The level parameter should be a number.");
8
8
 
9
9
  const {gjReq} = require("../misc/gjReq.js");
10
+ const {gjWReq} = require("../misc/gjWReq.js");
10
11
  const { server } = require("../config.json");
11
12
 
12
13
  const XOR = require("../misc/xor.js");
13
14
  let xor = new XOR()
14
15
 
15
16
  const data = {
16
- gameVersion: 21,
17
- binaryVersion: 35,
18
- gdw: 0,
19
17
  levelID: level.toString().trim(),
20
18
  secret: "Wmfd2893gb7"
21
19
  }
@@ -23,6 +21,12 @@ module.exports = {
23
21
  let res = await gjReq('downloadGJLevel22', data);
24
22
  if(res.data == -1) throw new Error("-1 This level is not found.");
25
23
 
24
+ if(res.data.startsWith("error code")) {
25
+ res = await gjWReq("dlLevel", level);
26
+ if(res.status == 403) throw new Error(res.data.error);
27
+ return res.data;
28
+ }
29
+
26
30
  let spl = res.data.split(":");
27
31
  let levelInfo = [];
28
32
  for(let i =0;i<spl.length;i++) {
@@ -60,23 +64,7 @@ module.exports = {
60
64
 
61
65
  let disliked = likes.includes("-") ? true : false;
62
66
 
63
- if(verifiedCoins == "0") verifiedCoins = false;
64
- if(verifiedCoins == "1") verifiedCoins = true;
65
-
66
- let demonBoolDecoding = {
67
- '1': true,
68
- '': false,
69
- '0': false
70
- }
71
-
72
- let featuredDecoding = {
73
- "0": false,
74
- "1": true,
75
- undefined: true
76
- }
77
-
78
- let featured = featuredDecoding[ftrd];
79
- if(featured == undefined) featured = true;
67
+ let featured = Boolean(Number(ftrd));
80
68
 
81
69
  let difficultyDecoding = {
82
70
  "-10": "Auto",
@@ -88,7 +76,7 @@ module.exports = {
88
76
  "50": "Insane"
89
77
  }
90
78
 
91
- if(demonBoolDecoding[demonBool] == true) {
79
+ if(Boolean(Number(demonBool))) {
92
80
  difficultyDecoding = {
93
81
  "10": "Easy Demon",
94
82
  "20": "Medium Demon",
@@ -147,20 +135,20 @@ module.exports = {
147
135
  disliked: disliked,
148
136
  length: lengthDecoding[length],
149
137
  password: password,
150
- demon: demonBoolDecoding[demonBool],
138
+ demon: Boolean(Number(demonBool)),
151
139
  featured: featured,
152
- epic: demonBoolDecoding[epic],
140
+ epic: Boolean(Number(epic)),
153
141
  objects: objects,
154
142
  uploaded: uploaded,
155
143
  updated: updated,
156
144
  stars_requested: Number(starsRequested),
157
145
  game_version: decodeGameVersion[gameVersion],
158
- ldm: demonBoolDecoding[ldm],
146
+ ldm: Boolean(Number(ldm)),
159
147
  copied: Number(copiedID),
160
148
  large: Number(objs) > 40000 ? true : false,
161
- two_p: demonBoolDecoding[twoPlayer],
149
+ two_p: Boolean(Number(twoPlayer)),
162
150
  coins: Number(coins),
163
- verified_coins: verifiedCoins,
151
+ verified_coins: Boolean(Number(verifiedCoins)),
164
152
  song: getLvl.song,
165
153
  }
166
154
 
@@ -1,12 +1,13 @@
1
1
  module.exports = {
2
2
  dlMessage:
3
3
  async function(id, user, pass) {
4
- if(!id || id == "") throw new Error("Please provide a message ID!");
4
+ if(!id) throw new Error("Please provide a message ID!");
5
5
  if(Number(id) == NaN) throw new Error("The message ID should be a number!");
6
- if(!user || user == "") throw new Error("Please provide your player ID or username!");
7
- if(!pass || pass == "") throw new Error("Please provide your password!");
6
+ if(!user) throw new Error("Please provide your player ID or username!");
7
+ if(!pass) throw new Error("Please provide your password!");
8
8
 
9
9
  const {gjReq} = require("../misc/gjReq.js");
10
+ const {gjWReq} = require("../misc/gjWReq.js");
10
11
  const {secret} = require("../config.json");
11
12
  const { searchUsers } = require("./searchUsers.js");
12
13
  const {gjp} = require("../misc/gjp.js");
@@ -24,6 +25,12 @@ module.exports = {
24
25
  let res = await gjReq("downloadGJMessage20", data);
25
26
  if(res.data == -1) throw new Error(-1);
26
27
 
28
+ if(res.data.startsWith("error code")) {
29
+ res = await gjWReq("dlMessage", `${id}?user=${user}&password=${pass}`);
30
+ if(res.status == 403) throw new Error(res.data.error);
31
+ return res.data;
32
+ }
33
+
27
34
  return decMessage(res.data);
28
35
  }
29
36
  }
@@ -1,17 +1,15 @@
1
1
  module.exports = {
2
2
  getAccountPosts:
3
3
  async function(str, page = 1) {
4
- if(!str || str == "") throw new Error("Please provide a user ID or name!");
4
+ if(!str) throw new Error("Please provide a user ID or name!");
5
5
  const { decodeAccountPost } = require("../misc/decodeAccountPost.js");
6
6
  const {gjReq} = require("../misc/gjReq.js");
7
+ const {gjWReq} = require("../misc/gjWReq.js");
7
8
  const { searchUsers } = require("./searchUsers.js");
8
9
 
9
10
  let user = await searchUsers(str);
10
11
 
11
12
  let ACdata = {
12
- gameVersion: 21,
13
- binaryVersion: 35,
14
- gdw: 0,
15
13
  accountID: user.accountID,
16
14
  secret: "Wmfd2893gb7",
17
15
  page: page - 1
@@ -20,6 +18,12 @@ module.exports = {
20
18
  let res = await gjReq("getGJAccountComments20", ACdata);
21
19
  if(res.data == -1) throw new Error("-1 Not found.");
22
20
  if(res.data.startsWith("#")) throw new Error("Whoops! Couldn't find anything!");
21
+
22
+ if(res.data.startsWith("error code")) {
23
+ res = await gjWReq("getAccountPosts", `${str}?page=${page}`);
24
+ if(res.status == 403) throw new Error(res.data.error);
25
+ return res.data;
26
+ }
23
27
 
24
28
  let accPosts = res.data.split("|");
25
29
  let result = [];
@@ -1,10 +1,11 @@
1
1
  module.exports = {
2
2
  getBlockedList:
3
3
  async function(str, pass) {
4
- if(!str || str == "") throw new Error("Please provide your player ID or username!");
5
- if(!pass || pass == "") throw new Error("Please provide your password!");
4
+ if(!str) throw new Error("Please provide your player ID or username!");
5
+ if(!pass) throw new Error("Please provide your password!");
6
6
 
7
7
  const {gjReq} = require("../misc/gjReq.js");
8
+ const {gjWReq} = require("../misc/gjWReq.js");
8
9
  const {gjp} = require("../misc/gjp.js");
9
10
  const { searchUsers } = require("./searchUsers.js");
10
11
 
@@ -20,6 +21,12 @@ module.exports = {
20
21
  let res = await gjReq("getGJUserList20", data);
21
22
  if(res.data == -1) throw new Error(-1);
22
23
  if(res.data == -2) throw new Error("No players have been found in the blocklist.");
24
+
25
+ if(res.data.startsWith("error code")) {
26
+ res = await gjWReq("getBlockedList", `${str}?password=${pass}`);
27
+ if(res.status == 403) throw new Error(res.data.error);
28
+ return res.data;
29
+ }
23
30
 
24
31
  let players = res.data.split("|");
25
32
  let result = [];
@@ -1,11 +1,12 @@
1
1
  module.exports = {
2
2
  getCommentHistory:
3
3
  async function(str, page = 1, mode = 1) {
4
- if(!str || str == "") throw new Error("Please provide a player ID or name!");
4
+ if(!str) throw new Error("Please provide a player ID or name!");
5
5
  if(page && isNaN(page)) throw new Error("Please provide a page!");
6
6
  if(mode && isNaN(mode)) throw new Error("Please provide a mode ID! 0 for recent, 1 for most liked.");
7
7
 
8
8
  const {gjReq} = require("../misc/gjReq.js");
9
+ const {gjWReq} = require("../misc/gjWReq.js");
9
10
  const {decCommentFromHistory} = require("../misc/decCommentFromHistory.js");
10
11
  const {getProfile} = require("./getProfile.js");
11
12
 
@@ -13,9 +14,6 @@ module.exports = {
13
14
  if(user.commentHistory != "all") throw new Error("Whoops! This user has disabled viewing his comment history!");
14
15
 
15
16
  const CHData = {
16
- gameVersion: 21,
17
- binaryVersion: 35,
18
- gdw: 0,
19
17
  secret: "Wmfd2893gb7",
20
18
  userID: user.playerID,
21
19
  page: Number(page) - 1,
@@ -24,6 +22,12 @@ module.exports = {
24
22
 
25
23
  let res = await gjReq("getGJCommentHistory", CHData);
26
24
  if(res.data == -1) throw new Error("-1 Not found.");
25
+
26
+ if(res.data.startsWith("error code")) {
27
+ res = await gjWReq("getCommentHistory", `${str}?page=${page}&mode=${mode}`);
28
+ if(res.status == 403) throw new Error(res.data.error);
29
+ return res.data;
30
+ }
27
31
 
28
32
  let comments = res.data.split("|");
29
33
  let result = [];
@@ -1,11 +1,12 @@
1
1
  module.exports = {
2
2
  getComments:
3
3
  async function(level, page = 1, mode = 1) {
4
- if(!level || level == "") throw new Error("Please provide a level ID!");
4
+ if(!level) throw new Error("Please provide a level ID!");
5
5
  if(isNaN(level)) throw new Error("A level ID should be a number.");
6
6
  if(mode && isNaN(mode)) throw new Error("Please provide a mode ID! 0 for recent, 1 for most liked.");
7
7
 
8
8
  const {gjReq} = require("../misc/gjReq.js");
9
+ const {gjWReq} = require("../misc/gjWReq.js");
9
10
  const { decodeGJComment } = require("../misc/decodeGJComment.js");
10
11
 
11
12
  const data = {
@@ -13,13 +14,16 @@ module.exports = {
13
14
  page: Number(page) - 1,
14
15
  mode: Number(mode),
15
16
  secret: "Wmfd2893gb7",
16
- gameVersion: 21,
17
- binaryVersion: 35,
18
- gdw: 0
19
17
  }
20
18
 
21
19
  let res = await gjReq("getGJComments21", data);
22
20
  if(res.data.startsWith("#")) throw new Error("-1 No comments have been found.");
21
+
22
+ if(res.data.startsWith("error code")) {
23
+ res = await gjWReq("getComments", `${level}?page=${page}&mode=${mode}`);
24
+ if(res.status == 403) throw new Error(res.data.error);
25
+ return res.data;
26
+ }
23
27
 
24
28
  let comments = res.data.split("|");
25
29
  let result = [];
@@ -3,6 +3,7 @@ module.exports = {
3
3
  async function() {
4
4
  const { decScoresUser } = require("../misc/decScoresUser.js");
5
5
  const {gjReq} = require("../misc/gjReq.js");
6
+ const {gjWReq} = require("../misc/gjWReq.js");
6
7
  const { secret } = require("../config.json");
7
8
 
8
9
  const data = {
@@ -12,9 +13,13 @@ module.exports = {
12
13
  }
13
14
 
14
15
  let res = await gjReq("getGJScores20", data);
16
+ if(res.data.startsWith("error code")) {
17
+ res = await gjWReq("getCreatorScores");
18
+ return res.data;
19
+ }
15
20
 
16
21
  let players = res.data.split("|");
17
- let emptyElem = players.indexOf(100);
22
+ let emptyElem = players[100];
18
23
 
19
24
  players.splice(emptyElem, 1);
20
25
 
@@ -1,10 +1,11 @@
1
1
  module.exports = {
2
2
  getFriendsList:
3
3
  async function(str, pass) {
4
- if(!str || str == "") throw new Error("Please provide your player ID or username!");
5
- if(!pass || pass == "") throw new Error("Please provide your password!");
4
+ if(!str) throw new Error("Please provide your player ID or username!");
5
+ if(!pass) throw new Error("Please provide your password!");
6
6
 
7
7
  const {gjReq} = require("../misc/gjReq.js");
8
+ const {gjWReq} = require("../misc/gjWReq.js");
8
9
  const {gjp} = require("../misc/gjp.js");
9
10
  const { searchUsers } = require("./searchUsers.js");
10
11
 
@@ -17,6 +18,15 @@ module.exports = {
17
18
  }
18
19
 
19
20
  let res = await gjReq("getGJUserList20", data);
21
+ if(res.data == -1) throw new Error(-1);
22
+ if(res.data == -2) throw new Error("No players have been found in the friends list.");
23
+
24
+ if(res.data.startsWith("error code")) {
25
+ res = await gjWReq("getFriendsList", `${str}?password=${pass}`);
26
+ if(res.status == 403) throw new Error(res.data.error);
27
+ return res.data;
28
+ }
29
+
20
30
  let players = res.data.split("|");
21
31
  let result = [];
22
32
 
@@ -2,16 +2,18 @@ module.exports = {
2
2
  getGauntlets:
3
3
  async function() {
4
4
  const {gjReq} = require("../misc/gjReq.js");
5
+ const {gjWReq} = require("../misc/gjWReq.js");
5
6
  const { decodeGJGauntlet } = require("../misc/decodeGJGauntlet.js")
6
7
 
7
8
  const data = {
8
- secret: "Wmfd2893gb7",
9
- gameVersion: 21,
10
- binaryVersion: 35,
11
- gdw: 0
9
+ secret: "Wmfd2893gb7"
12
10
  }
13
11
 
14
12
  let res = await gjReq("getGJGauntlets21", data)
13
+ if(res.data.startsWith("error code")) {
14
+ res = await gjWReq("getGauntlets");
15
+ return res.data;
16
+ }
15
17
 
16
18
  let gauntlets = res.data.split("|");
17
19
  let result = [];
@@ -1,25 +1,29 @@
1
1
  module.exports = {
2
2
  getLevelByID:
3
3
  async function(id) {
4
- if(!id || id == "") throw new Error("Please provide a level ID!");
4
+ if(!id) throw new Error("Please provide a level ID!");
5
5
  if(isNaN(id)) throw new Error("The level ID should be a number!");
6
6
 
7
7
  const {decodeLevel} = require("../misc/decodeLevel.js");
8
8
  const {gjReq} = require("../misc/gjReq.js");
9
+ const {gjWReq} = require("../misc/gjWReq.js");
9
10
  const {secret} = require("../config.json");
10
11
 
11
12
  const data = {
12
13
  secret: secret,
13
14
  str: id,
14
- gameVersion: 21,
15
- binaryVersion: 35,
16
- gdw: 0,
17
15
  type: 0
18
16
  }
19
17
 
20
18
  let res = await gjReq("getGJLevels21", data);
21
19
  if(res.data == -1) throw new Error("-1 Not found.");
22
20
 
21
+ if(res.data.startsWith("error code")) {
22
+ res = await gjWReq("getLevelByID", id);
23
+ if(res.status == 403) throw new Error(res.data.error);
24
+ return res.data;
25
+ }
26
+
23
27
  return await decodeLevel(res.data);
24
28
  }
25
29
  }
@@ -4,6 +4,7 @@ module.exports = {
4
4
  const { decodeMapPack } = require("../misc/decodeMapPack.js");
5
5
 
6
6
  const {gjReq} = require("../misc/gjReq.js");
7
+ const {gjWReq} = require("../misc/gjWReq.js");
7
8
  const data = {
8
9
  secret: "Wmfd2893gb7",
9
10
  page: Number(page) - 1
@@ -12,6 +13,12 @@ module.exports = {
12
13
  let res = await gjReq("getGJMapPacks21", data);
13
14
  if(res.data.startsWith("#")) throw new Error("-1 Not found.");
14
15
 
16
+ if(res.data.startsWith("error code")) {
17
+ res = await gjWReq("getMapPacks", page);
18
+ if(res.status == 403) throw new Error(res.data.error);
19
+ return res.data;
20
+ }
21
+
15
22
  let packs = res.data.split("|");
16
23
  let result = [];
17
24
  packs.forEach(p => {
@@ -1,11 +1,12 @@
1
1
  module.exports = {
2
2
  getMessages:
3
3
  async function(user, pass, page = 1) {
4
- if(!user || user == "") throw new Error("Please provide your player ID or username!");
5
- if(!pass || pass == "") throw new Error("Please provide your password!");
4
+ if(!user) throw new Error("Please provide your player ID or username!");
5
+ if(!pass) throw new Error("Please provide your password!");
6
6
  if(Number(page) == NaN) throw new Error("The page should be a number!");
7
7
 
8
8
  const {gjReq} = require("../misc/gjReq.js");
9
+ const {gjWReq} = require("../misc/gjWReq.js");
9
10
  const {secret} = require("../config.json");
10
11
  const {gjp} = require("../misc/gjp.js");
11
12
  const {decMsg} = require("../misc/decMsg.js");
@@ -23,6 +24,12 @@ module.exports = {
23
24
  let res = await gjReq("getGJMessages20", data);
24
25
  if(res.data == -1) throw new Error(-1);
25
26
 
27
+ if(res.data.startsWith("error code")) {
28
+ res = await gjWReq("getMessages", `${user}?password=${pass}&page=${page}`);
29
+ if(res.status == 403) throw new Error(res.data.error);
30
+ return res.data;
31
+ }
32
+
26
33
  let msgs = res.data.split("|");
27
34
  let result = [];
28
35
  msgs.forEach(m => {
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
2
  getOfficialSongInfo:
3
3
  function(song) {
4
- if(!song || song == "") throw new Error("Please provide a song ID.");
4
+ if(!song) throw new Error("Please provide a song ID.");
5
5
  if(isNaN(song)) throw new Error("A song ID must be a number.");
6
6
  const {
7
7
  sm,
@@ -1,16 +1,14 @@
1
1
  module.exports = {
2
2
  getProfile:
3
3
  async function(str) {
4
- if(!str || str == "") throw new Error("Please provide a user ID or name!");
4
+ if(!str) throw new Error("Please provide a user ID or name!");
5
5
  const {gjReq} = require("../misc/gjReq.js");
6
+ const {gjWReq} = require("../misc/gjWReq.js");
6
7
  const { searchUsers } = require("./searchUsers.js");
7
8
 
8
9
  let user = await searchUsers(str);
9
10
 
10
11
  let data = {
11
- gameVersion: 21,
12
- binaryVersion: 35,
13
- gdw: 0,
14
12
  targetAccountID: user.accountID,
15
13
  secret: "Wmfd2893gb7"
16
14
  };
@@ -18,6 +16,12 @@ module.exports = {
18
16
  let res = await gjReq("getGJUserInfo20", data);
19
17
  if(res.data == -1) throw new Error("-1 This user is not found.");
20
18
 
19
+ if(res.data.startsWith("error code")) {
20
+ res = await gjWReq("getProfile", str);
21
+ if(res.status == 403) throw new Error(res.data.error);
22
+ return res.data;
23
+ }
24
+
21
25
  let spl = res.data.split(':');
22
26
  let userInfo = [];
23
27
  for(let i =0;i<spl.length;i++) {
@@ -1,9 +1,10 @@
1
1
  module.exports = {
2
2
  getSongInfo:
3
3
  async function(song) {
4
- if(!song || song == "") throw new Error("Please provide a song ID.");
4
+ if(!song) throw new Error("Please provide a song ID.");
5
5
  if(isNaN(song)) throw new Error("A song ID must be a number.")
6
6
  const {gjReq} = require("../misc/gjReq.js");
7
+ const {gjWReq} = require("../misc/gjWReq.js");
7
8
 
8
9
  const data = {
9
10
  songID: song,
@@ -13,6 +14,12 @@ module.exports = {
13
14
  let res = await gjReq('getGJSongInfo', data);
14
15
  if(res.data == -2) throw new Error(`-2. Couldn't find a song with ID ${song}.`)
15
16
 
17
+ if(res.data.startsWith("error code")) {
18
+ res = await gjWReq("getSongInfo", song);
19
+ if(res.status == 403) throw new Error(res.data.error);
20
+ return res.data;
21
+ }
22
+
16
23
  const result = {
17
24
  "name": res.data.split("|~2~|~")[1].split("~|~3~|~")[0],
18
25
  "id": Number(res.data.split("1~|~")[1].split("~|~2~|")[0]),
@@ -3,6 +3,7 @@ module.exports = {
3
3
  async function() {
4
4
  const { decScoresUser } = require("../misc/decScoresUser.js");
5
5
  const {gjReq} = require("../misc/gjReq.js");
6
+ const {gjWReq} = require("../misc/gjWReq.js");
6
7
  const { secret } = require("../config.json");
7
8
 
8
9
  const data = {
@@ -12,6 +13,7 @@ module.exports = {
12
13
  }
13
14
 
14
15
  let res = await gjReq("getGJScores20", data);
16
+ if(res.data.startsWith("error code")) res = await gjWReq("getTop100");
15
17
 
16
18
  let players = res.data.split("|");
17
19
  let emptyElem = players.indexOf(100);
@@ -1,9 +1,10 @@
1
1
  module.exports = {
2
2
  getUserLevels:
3
3
  async function(str, page = 1) {
4
- if(!str || str == "") throw new Error("Please provide a username or player ID!");
4
+ if(!str) throw new Error("Please provide a username or player ID!");
5
5
 
6
6
  const {gjReq} = require("../misc/gjReq.js");
7
+ const {gjWReq} = require("../misc/gjWReq.js");
7
8
  const { secret } = require("../config.json");
8
9
  const { decodeLevelRes } = require("../misc/decodeLevelRes.js");
9
10
  const { searchUsers } = require("./searchUsers.js");
@@ -18,7 +19,13 @@ module.exports = {
18
19
  page: Number(page) - 1
19
20
  }
20
21
 
21
- let res = await gjReq("getGJLevels21", data)
22
+ let res = await gjReq("getGJLevels21", data);
23
+
24
+ if(res.data.startsWith("error code")) {
25
+ res = await gjWReq("getUserLevels", `${str}?page=${page}`);
26
+ if(res.status == 403) throw new Error(res.data.error);
27
+ return res.data;
28
+ }
22
29
 
23
30
  let levels = res.data.split("#")[0].split("|");
24
31
  let creators = res.data.split("#")[1].split("|");
@@ -1,10 +1,11 @@
1
1
  module.exports = {
2
2
  reportLevel:
3
3
  async function(level) {
4
- if(!level || level == "") throw new Error("Please provide a level ID.");
4
+ if(!level) throw new Error("Please provide a level ID.");
5
5
  if(isNaN(Number(level))) throw new Error("The level ID should be a number.");
6
6
 
7
7
  const {gjReq} = require("../misc/gjReq.js");
8
+ const {gjWReq} = require("../misc/gjWReq.js");
8
9
 
9
10
  const data = {
10
11
  levelID: level.toString().trim(),
@@ -12,6 +13,7 @@ module.exports = {
12
13
  }
13
14
 
14
15
  let res = await gjReq("reportGJLevel", data);
16
+ if(res.data.startsWith("error code")) res = await gjWReq("reportLevel", id);
15
17
 
16
18
  return res.data;
17
19
  }
@@ -2,6 +2,7 @@ module.exports = {
2
2
  searchLevels:
3
3
  async function(query, page = 1) {
4
4
  const {gjReq} = require("../misc/gjReq.js");
5
+ const {gjWReq} = require("../misc/gjWReq.js");
5
6
  const { secret } = require("../config.json");
6
7
 
7
8
  const { decodeLevelRes } = require("../misc/decodeLevelRes.js");
@@ -15,6 +16,12 @@ module.exports = {
15
16
 
16
17
  let res = await gjReq("getGJLevels21", data)
17
18
 
19
+ if(res.data.startsWith("error code")) {
20
+ res = await gjWReq("searchLevels", `${query}?page=${page}`);
21
+ if(res.status == 403) throw new Error(res.data.error);
22
+ return res.data;
23
+ }
24
+
18
25
  let levels = res.data.split("#")[0].split("|");
19
26
  let creators = res.data.split("#")[1].split("|");
20
27
  let songs = res.data.split("#")[2].split(":");
@@ -1,9 +1,9 @@
1
1
  module.exports = {
2
2
  searchUsers:
3
3
  async function(str) {
4
- if(!str || str == '') throw new Error("Please provide a query!");
5
-
4
+ if(!str) throw new Error("Please provide a query!");
6
5
  const {gjReq} = require("../misc/gjReq.js");
6
+ const {gjWReq} = require("../misc/gjWReq.js");
7
7
  const { decodeUserResult } = require("../misc/decodeUserResult.js");
8
8
 
9
9
  let res = await gjReq("getGJUsers20", {
@@ -11,7 +11,11 @@ module.exports = {
11
11
  secret: "Wmfd2893gb7"
12
12
  })
13
13
 
14
- if(res.data == -1) throw new Error(`Couldn't find a "${str}" user.`)
14
+ if(res.data == -1) throw new Error(`Couldn't find a "${str}" user.`);
15
+ if(res.data.startsWith("error code")) {
16
+ res = await gjWReq("searchUsers", str);
17
+ if(res.status == 403) throw new Error(res.data.error);
18
+ }
15
19
 
16
20
  return decodeUserResult(res.data);
17
21
  }
@@ -1,11 +1,12 @@
1
1
  module.exports = {
2
2
  unblockUser:
3
3
  async function(target, username, password) {
4
- if(!target || target == "") throw new Error("Please provide a target's player ID or username!");
5
- if(!username || username == "") throw new Error("Please provide your player ID or username!");
6
- if(!password || password == "") throw new Error("Please provide your password!");
4
+ if(!target) throw new Error("Please provide a target's player ID or username!");
5
+ if(!username) throw new Error("Please provide your player ID or username!");
6
+ if(!password) throw new Error("Please provide your password!");
7
7
 
8
8
  const {gjReq} = require("../misc/gjReq.js");
9
+ const {gjWReq} = require("../misc/gjWReq.js");
9
10
  const { searchUsers } = require("./searchUsers.js");
10
11
 
11
12
  let user = await searchUsers(username);
@@ -14,9 +15,6 @@ module.exports = {
14
15
  const {gjp} = require("../misc/gjp.js");
15
16
 
16
17
  const data = {
17
- gameVersion: 21,
18
- binaryVersion: 35,
19
- gdw: 0,
20
18
  secret: "Wmfd2893gb7",
21
19
  targetAccountID: targetObj.accountID,
22
20
  accountID: user.accountID,
@@ -26,6 +24,9 @@ module.exports = {
26
24
  let res = await gjReq("unblockGJUser20", data)
27
25
  if(res.data == -1) throw new Error(-1);
28
26
 
27
+ if(res.data.startsWith("error code")) res = await gjWReq("unblockUser", `${target}?user=${username}&password=${password}`);
28
+ if(res.status == 403) throw new Error(res.data.error);
29
+
29
30
  return 1;
30
31
  }
31
32
  }
@@ -3,13 +3,14 @@ module.exports = {
3
3
  async function(level, d, user, password) {
4
4
  let desc = d;
5
5
 
6
- if(!level || level == "") throw new Error("Please provide a level ID!");
6
+ if(!level) throw new Error("Please provide a level ID!");
7
7
  if(Number(level) == NaN) throw new Error("A level ID must be a number!");
8
8
  if(!desc) desc = "(No description provided)";
9
- if(!user || user == "") throw new Error("Please provide a user ID or name!");
10
- if(!password || password == "") throw new Error("Please provide a password!");
9
+ if(!user) throw new Error("Please provide a user ID or name!");
10
+ if(!password) throw new Error("Please provide a password!");
11
11
 
12
12
  const {gjReq} = require("../misc/gjReq.js");
13
+ const {gjWReq} = require("../misc/gjWReq.js");
13
14
  const { secret } = require("../config.json");
14
15
  const { searchUsers } = require("./searchUsers.js");
15
16
 
@@ -29,6 +30,9 @@ module.exports = {
29
30
  let res = await gjReq("updateGJDesc20", uLDdata);
30
31
  if(res.data == -1) throw new Error("-1 Failed to update the description.");
31
32
 
32
- return 1;
33
+ if(res.data.startsWith("error code")) res = await gjWReq("updateLevelDesc", `${level}?content=${encB64(desc)}&user=${user}&password=${password}`);
34
+ if(res.status == 403) throw new Error(res.data.error);
35
+
36
+ return res.data;
33
37
  }
34
38
  }
@@ -2,11 +2,12 @@ module.exports = {
2
2
  uploadAccountPost:
3
3
  async function(content, str, password) {
4
4
  const {encB64} = require("../misc/encB64.js");
5
- if(!content || content == "") throw new Error("Please provide an account post content!");
6
- if(!str || str == "") throw new Error("Please provide a user ID or name!");
7
- if(!password || password == "") throw new Error("Please provide a password!");
5
+ if(!content) throw new Error("Please provide an account post content!");
6
+ if(!str) throw new Error("Please provide a user ID or name!");
7
+ if(!password) throw new Error("Please provide a password!");
8
8
 
9
9
  const {gjReq} = require("../misc/gjReq.js");
10
+ const {gjWReq} = require("../misc/gjWReq.js");
10
11
  const { searchUsers } = require("./searchUsers.js");
11
12
 
12
13
  let user = await searchUsers(str);
@@ -17,9 +18,6 @@ module.exports = {
17
18
  const comment = encB64(content);
18
19
 
19
20
  let uACdata = {
20
- gameVersion: 21,
21
- binaryVersion: 35,
22
- gdw: 0,
23
21
  accountID: user.accountID,
24
22
  secret: "Wmfd2893gb7",
25
23
  gjp: xor.encrypt(password, 37526),
@@ -30,6 +28,9 @@ module.exports = {
30
28
  let res = await gjReq("uploadGJAccComment20", uACdata);
31
29
  if(res.status == 500) throw new Error("500 Error: couldn't post!");
32
30
 
31
+ if(res.data.startsWith("error code")) res = await gjWReq("uploadAccountPost", `?content=${encB64(content)}&user=${str}&password=${password}`);
32
+ if(res.status == 403) throw new Error(res.data.error);
33
+
33
34
  return res.data;
34
35
  }
35
36
  }
@@ -1,15 +1,16 @@
1
1
  module.exports = {
2
2
  uploadComment:
3
3
  async function(comment, id, user, password, percent = 0) {
4
- if(!comment || comment == "") throw new Error("Please provide a comment!");
5
- if(!id || id == "") throw new Error("Please provide a level ID!");
6
- if(!user || user == "") throw new Error("Please provide a username or a player ID!");
7
- if(!password || password == "") throw new Error("Please provide a password!");
4
+ if(!comment) throw new Error("Please provide a comment!");
5
+ if(!id) throw new Error("Please provide a level ID!");
6
+ if(!user) throw new Error("Please provide a username or a player ID!");
7
+ if(!password) throw new Error("Please provide a password!");
8
8
  if(Number(percent) > 100) throw new Error("The percentage cannot be more than 100!");
9
9
 
10
10
  const { gjp } = require("../misc/gjp.js");
11
11
  const { encB64 } = require("../misc/encB64.js");
12
12
  const {gjReq} = require("../misc/gjReq.js");
13
+ const {gjWReq} = require("../misc/gjWReq.js");
13
14
  const crypto = require('crypto')
14
15
  const { searchUsers } = require("./searchUsers.js");
15
16
 
@@ -22,13 +23,13 @@ module.exports = {
22
23
  const XOR = require("../misc/xor.js");
23
24
  const xor = new XOR();
24
25
 
25
- let chkStr = userObj.username + encB64(comment) + Number(id) + Number(percent) + "0xPT6iUrtws0J";
26
+ let chkStr = userObj.username.toLowerCase() + encB64(comment) + Number(id) + Number(percent) + "0xPT6iUrtws0J";
26
27
  let chk = xor.encrypt(sha1(chkStr), 29481);
27
28
 
28
29
  const uCdata = {
29
30
  accountID: userObj.accountID,
30
31
  gjp: gjp(password),
31
- userName: userObj.username,
32
+ userName: userObj.username.toLowerCase(),
32
33
  comment: encB64(comment),
33
34
  levelID: id,
34
35
  percent: percent,
@@ -42,6 +43,9 @@ module.exports = {
42
43
  if(res.data == -10) throw new Error("You're permanently banned from commenting!");
43
44
  if(res.data.startsWith("temp_")) throw new Error(`You're temporarily banned from commenting!\nRemaining duration: ${edata.split("_")[1]} seconds\nReason: ${edata.split("_")[2]}`);
44
45
 
46
+ if(res.data.startsWith("error code")) res = await gjWReq("uploadComment", `${id}?comment=${encB64(comment)}&user=${user}&password=${password}&percent=${percent}`)
47
+ if(res.status == 403) throw new Error(res.data.error)
48
+
45
49
  return res.data;
46
50
  }
47
51
  }
@@ -1,15 +1,16 @@
1
1
  module.exports = {
2
2
  uploadMessage:
3
3
  async function(receiver, subj, content, user, pass) {
4
- if(!receiver || receiver == "") throw new Error("Please specify a message receiver!");
5
- if(!subj || subj == "") throw new Error("Please specify a message subject!");
6
- if(!content || content == "") throw new Error("Please specify a message content!");
7
- if(!user || user == "") throw new Error("Please provide a username or a player ID!");
8
- if(!pass || pass == "") throw new Error("Please provide a password!");
4
+ if(!receiver) throw new Error("Please specify a message receiver!");
5
+ if(!subj) throw new Error("Please specify a message subject!");
6
+ if(!content) throw new Error("Please specify a message content!");
7
+ if(!user) throw new Error("Please provide a username or a player ID!");
8
+ if(!pass) throw new Error("Please provide a password!");
9
9
 
10
10
  const { gjp } = require("../misc/gjp.js");
11
11
  const { encB64 } = require("../misc/encB64.js");
12
12
  const {gjReq} = require("../misc/gjReq.js");
13
+ const {gjWReq} = require("../misc/gjWReq.js");
13
14
  const { secret } = require("../config.json");
14
15
  const { searchUsers } = require("./searchUsers.js");
15
16
 
@@ -31,6 +32,9 @@ module.exports = {
31
32
  let res = await gjReq("uploadGJMessage20", data);
32
33
  if(res.data == -1) throw new Error(-1);
33
34
 
34
- return 1;
35
+ if(res.data.startsWith("error code")) res = await gjWReq("uploadMessage", `?receiver=${receiver}&subject=${encB64(subj)}&content=${encB64(content)}&user=${user}&password=${pass}`)
36
+ if(res.status == 403) throw new Error(res.data.error)
37
+
38
+ return res.data;
35
39
  }
36
40
  }
package/index.js CHANGED
@@ -1,6 +1,3 @@
1
- console.log('\x1b[32m%s\x1b[40m', 'Thanks for using gj-boomlings-api!\nhttps://github.com/shikoshib/gj-boomlings-api');
2
- console.log('\x1b[37m%s\x1b[0m', '');
3
-
4
1
  const { dlLevel } = require("./functions/dlLevel.js");
5
2
  const { getSongInfo } = require("./functions/getSongInfo.js");
6
3
  const { getOfficialSongInfo } = require("./functions/getOfficialSongInfo.js");
@@ -19,6 +19,8 @@ module.exports = {
19
19
  let age = cmnt[5].split("~")[1];
20
20
  let messageID = cmnt[6].split("~")[1].split(":")[0];
21
21
  let username = cmnt[7].split("~")[0];
22
+
23
+ if(Number(cmnt[7].split("~")[0]) != NaN) username = cmnt[9].split("~")[0];
22
24
 
23
25
  const res = {
24
26
  username: username,
@@ -2,44 +2,39 @@ module.exports = {
2
2
  decodeGJGauntlet:
3
3
  function(gauntlet) {
4
4
  let spl = gauntlet.split(':');
5
- let glInfo = [];
6
- for(let i =0;i<spl.length;i++) {
7
- if(i%2!=0) {
8
- glInfo.push(spl[i-1]+`:`+spl[i]);
9
- }
10
- }
11
5
 
12
- let id = glInfo[0].split(":")[1];
13
- let levelList = glInfo[1].split(":")[1];
6
+ let id = spl[1];
7
+ let lvlList = spl[3];
14
8
 
15
- let firstLvl = levelList.split(",")[0];
16
- let secondLvl = levelList.split(",")[1].split(",")[0];
17
- let thirdLvl = levelList.split(",")[2].split(",")[0];
18
- let fourthLvl = levelList.split(",")[3].split(",")[0];
19
- let fifthLvl = levelList.split(",")[4].split("#")[0];
9
+ let arr = lvlList.split(",");
10
+ let Lvl1 = arr[0];
11
+ let Lvl2 = arr[1]
12
+ let Lvl3 = arr[2];
13
+ let Lvl4 = arr[3];
14
+ let Lvl5 = arr[4].split("#")[0];
20
15
 
21
16
  const glIDs = {
22
- "1": "Fire Gauntlet",
23
- "2": "Ice Gauntlet",
24
- "3": "Poison Gauntlet",
25
- "4": "Shadow Gauntlet",
26
- "5": "Lava Gauntlet",
27
- "6": "Bonus Gauntlet",
28
- "7": "Chaos Gauntlet",
29
- "8": "Demon Gauntlet",
30
- "9": "Time Gauntlet",
31
- "10": "Crystal Gauntlet",
32
- "11": "Magic Gauntlet",
33
- "12": "spike Gauntlet",
34
- "13": "Monster Gauntlet",
35
- "14": "Doom Gauntlet",
36
- "15": "Death Gauntlet"
17
+ "1": "Fire",
18
+ "2": "Ice",
19
+ "3": "Poison",
20
+ "4": "Shadow",
21
+ "5": "Lava",
22
+ "6": "Bonus",
23
+ "7": "Chaos",
24
+ "8": "Demon",
25
+ "9": "Time",
26
+ "10": "Crystal",
27
+ "11": "Magic",
28
+ "12": "spike",
29
+ "13": "Monster",
30
+ "14": "Doom",
31
+ "15": "Death"
37
32
  }
38
33
 
39
- const list = [firstLvl,secondLvl,thirdLvl,fourthLvl,fifthLvl]
34
+ let list = [Number(Lvl1),Number(Lvl2),Number(Lvl3),Number(Lvl4),Number(Lvl5)]
40
35
 
41
36
  const result = {
42
- "name": glIDs[id],
37
+ "name": `${glIDs[id]} Gauntlet`,
43
38
  "levels": list
44
39
  }
45
40
 
@@ -38,29 +38,12 @@ module.exports = {
38
38
  author = levelInfo[27].split(":")[0];
39
39
  }
40
40
 
41
- let disliked = false;
42
- if(likes.includes("-")) disliked = true;
41
+ let disliked = likes.includes("-") ? true : false;
43
42
 
44
43
  if(desc.includes("/")) desc = desc.split("/")[0];
45
44
  if(decB64(desc) == '') desc = "KE5vIGRlc2NyaXB0aW9uIHByb3ZpZGVkKQ=="
46
45
 
47
- if(verifiedCoins == "0") verifiedCoins = false;
48
- if(verifiedCoins == "1") verifiedCoins = true;
49
-
50
- let demonBoolDecoding = {
51
- '1': true,
52
- '': false,
53
- '0': false
54
- }
55
-
56
- let featuredDecoding = {
57
- "0": false,
58
- "1": true,
59
- undefined: true
60
- }
61
-
62
- let featured = featuredDecoding[ftrd];
63
- if(featured == undefined) featured = true;
46
+ let featured = Boolean(Number(ftrd));
64
47
 
65
48
  let difficultyDecoding = {
66
49
  "-10": "Auto",
@@ -72,7 +55,7 @@ module.exports = {
72
55
  "50": "Insane"
73
56
  }
74
57
 
75
- if(demonBoolDecoding[demonBool] == true) {
58
+ if(Boolean(Number(demonBool))) {
76
59
  difficultyDecoding = {
77
60
  "10": "Easy Demon",
78
61
  "20": "Medium Demon",
@@ -91,18 +74,12 @@ module.exports = {
91
74
  }
92
75
 
93
76
  const decodeGameVersion = {
94
- "1": "Pre-1.7",
95
- "2": "Pre-1.7",
96
- "3": "Pre-1.7",
97
- "4": "Pre-1.7",
98
- "5": "Pre-1.7",
99
- "6": "Pre-1.7",
100
- "7": "Pre-1.7",
101
77
  "10": "1.7",
102
78
  "18": "1.8",
103
79
  "19": "1.9",
104
80
  "20": "2.0",
105
- "21": "2.1"
81
+ "21": "2.1",
82
+ undefined: "Pre-1.7"
106
83
  }
107
84
 
108
85
  const { getOfficialSongInfo } = require("../functions/getOfficialSongInfo.js");
@@ -142,17 +119,17 @@ module.exports = {
142
119
  likes: Number(likes),
143
120
  disliked: disliked,
144
121
  length: lengthDecoding[length],
145
- demon: demonBoolDecoding[demonBool],
122
+ demon: Boolean(Number(demonBool)),
146
123
  featured: featured,
147
- epic: demonBoolDecoding[epic],
124
+ epic: Boolean(Number(epic)),
148
125
  objects: Number(objs),
149
126
  stars_requested: Number(starsRequested),
150
127
  game_version: decodeGameVersion[gameVersion],
151
128
  copied: Number(copiedID),
152
129
  large: Number(objs) > 40000 ? true : false,
153
- two_p: demonBoolDecoding[twoPlayer],
130
+ two_p: Boolean(Number(twoPlayer)),
154
131
  coins: Number(coins),
155
- verified_coins: verifiedCoins,
132
+ verified_coins: Boolean(Number(verifiedCoins)),
156
133
  song: song
157
134
  }
158
135
 
@@ -2,7 +2,7 @@ module.exports = {
2
2
  decodeLevelRes:
3
3
  function(level){
4
4
  const {decB64} = require("./decB64.js");
5
-
5
+
6
6
  let spl = level.split(':');
7
7
  let levelInfo = [];
8
8
  for(let i =0;i<spl.length;i++) {
@@ -10,7 +10,7 @@ module.exports = {
10
10
  levelInfo.push(spl[i-1]+`:`+spl[i]);
11
11
  }
12
12
  }
13
-
13
+
14
14
  let id = levelInfo[0].split("1:")[1];
15
15
  let name = levelInfo[1].split("2:")[1];
16
16
  let version = levelInfo[2].split("5:")[1];
@@ -34,29 +34,12 @@ module.exports = {
34
34
  let starsRequested = levelInfo[23].split("39:")[1];
35
35
  let customSong = levelInfo[26].split("35:")[1].split("#")[0];
36
36
 
37
- let disliked = false;
38
- if(likes.includes("-")) disliked = true;
37
+ let disliked = likes.includes("-") ? true : false;
39
38
 
40
39
  if(desc.includes("/")) desc = desc.split("/")[0];
41
40
  if(decB64(desc) == '') desc = "KE5vIGRlc2NyaXB0aW9uIHByb3ZpZGVkKQ=="
42
41
 
43
- if(verifiedCoins == "0") verifiedCoins = false;
44
- if(verifiedCoins == "1") verifiedCoins = true;
45
-
46
- let demonBoolDecoding = {
47
- '1': true,
48
- '': false,
49
- '0': false
50
- }
51
-
52
- let featuredDecoding = {
53
- "0": false,
54
- "1": true,
55
- undefined: true
56
- }
57
-
58
- let featured = featuredDecoding[ftrd];
59
- if(featured == undefined) featured = true;
42
+ let featured = Boolean(Number(ftrd));
60
43
 
61
44
  let difficultyDecoding = {
62
45
  "-10": "Auto",
@@ -68,7 +51,7 @@ module.exports = {
68
51
  "50": "Insane"
69
52
  }
70
53
 
71
- if(demonBoolDecoding[demonBool] == true) {
54
+ if(Boolean(Number(demonBool))) {
72
55
  difficultyDecoding = {
73
56
  "10": "Easy Demon",
74
57
  "20": "Medium Demon",
@@ -77,7 +60,7 @@ module.exports = {
77
60
  "50": "Extreme Demon"
78
61
  }
79
62
  }
80
-
63
+
81
64
  const lengthDecoding = {
82
65
  "0": "Tiny",
83
66
  "1": "Short",
@@ -112,17 +95,17 @@ module.exports = {
112
95
  likes: Number(likes),
113
96
  disliked: disliked,
114
97
  length: lengthDecoding[length],
115
- demon: demonBoolDecoding[demonBool],
98
+ demon: Boolean(Number(demonBool)),
116
99
  featured: featured,
117
- epic: demonBoolDecoding[epic],
100
+ epic: Boolean(Number(epic)),
118
101
  objects: Number(objs),
119
102
  stars_requested: Number(starsRequested),
120
103
  game_version: decodeGameVersion[gameVersion],
121
104
  copied: Number(copiedID),
122
105
  large: Number(objs) > 40000 ? true : false,
123
- two_p: demonBoolDecoding[twoPlayer],
106
+ two_p: Boolean(Number(twoPlayer)),
124
107
  coins: Number(coins),
125
- verified_coins: verifiedCoins
108
+ verified_coins: Boolean(Number(verifiedCoins))
126
109
  }
127
110
 
128
111
  return {
package/misc/gjReq.js CHANGED
@@ -11,13 +11,11 @@ module.exports = {
11
11
 
12
12
  let r = await fetch(`${server}${endpoint.endsWith(".php") ? endpoint.split(".php")[0] : endpoint}.php`, {
13
13
  method: 'POST',
14
- mode: "no-cors",
15
14
  headers: headers,
16
15
  body: new URLSearchParams(data)
17
16
  })
18
17
 
19
18
  let res = await r.text()
20
- if(res.toLowerCase() == "error code: 1005") throw new Error("1005 Error: Your IP is banned from making requests to this server.");
21
19
 
22
20
  return {
23
21
  data: res,
package/misc/gjWReq.js ADDED
@@ -0,0 +1,10 @@
1
+ module.exports = {
2
+ gjWReq:
3
+ async function(endpoint, data = "") {
4
+ let r = await fetch(`https://gbaweb.vercel.app/${endpoint}/${data}`)
5
+ let res = await r.text()
6
+ if(res.includes("{") || res.includes("[")) res = JSON.parse(res);
7
+
8
+ return {data: res, status: r.status};
9
+ }
10
+ }
package/misc/rgbToHEX.js CHANGED
@@ -2,7 +2,7 @@ module.exports = {
2
2
  rgbToHEX:
3
3
  function(color) {
4
4
  let r = color.split(",")[0];
5
- let g = color.split(",")[1].split(",")[0];
5
+ let g = color.split(",")[1];
6
6
  let b = color.split(",")[2];
7
7
 
8
8
  if(b.includes("#")) b = b.split("#")[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gj-boomlings-api",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "A light-weight Geometry Dash API wrapper",
5
5
  "main": "index.js",
6
6
  "scripts": {