osrs-json-hiscores 2.10.0 → 2.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/lib/hiscores.js +8 -8
  2. package/package.json +1 -1
package/lib/hiscores.js CHANGED
@@ -58,7 +58,7 @@ var utils_1 = require("./utils");
58
58
  */
59
59
  function getRSNFormat(rsn) {
60
60
  return __awaiter(this, void 0, void 0, function () {
61
- var url, response, dom, spans, nameSpan, _a;
61
+ var url, response, dom, anchor, _a;
62
62
  return __generator(this, function (_b) {
63
63
  switch (_b.label) {
64
64
  case 0:
@@ -79,10 +79,9 @@ function getRSNFormat(rsn) {
79
79
  case 2:
80
80
  response = _b.sent();
81
81
  dom = new jsdom_1.JSDOM(response.data);
82
- spans = dom.window.document.querySelectorAll('span[style="color:#AA0022;"]');
83
- if (spans.length >= 2) {
84
- nameSpan = spans[1];
85
- return [2 /*return*/, utils_1.rsnFromElement(nameSpan)];
82
+ anchor = dom.window.document.querySelector('.personal-hiscores__row.personal-hiscores__row--type-highlight a');
83
+ if (anchor) {
84
+ return [2 /*return*/, utils_1.rsnFromElement(anchor)];
86
85
  }
87
86
  throw Error('Player not found');
88
87
  case 3:
@@ -105,7 +104,8 @@ function parseStats(csv) {
105
104
  .split('\n')
106
105
  .filter(function (entry) { return !!entry; })
107
106
  .map(function (stat) { return stat.split(','); });
108
- if (splitCSV.length !== utils_1.SKILLS.length + utils_1.BH_MODES.length + utils_1.CLUES.length + utils_1.BOSSES.length + 5) {
107
+ if (splitCSV.length !==
108
+ utils_1.SKILLS.length + utils_1.BH_MODES.length + utils_1.CLUES.length + utils_1.BOSSES.length + 5) {
109
109
  throw Error(utils_1.INVALID_FORMAT_ERROR);
110
110
  }
111
111
  var skillObjects = splitCSV
@@ -186,7 +186,7 @@ function getStats(rsn) {
186
186
  if (typeof rsn !== 'string') {
187
187
  throw Error('RSN must be a string');
188
188
  }
189
- else if (!/^[a-zA-Z0-9 _]+$/.test(rsn)) {
189
+ else if (!/^[a-zA-Z0-9 _-]+$/.test(rsn)) {
190
190
  throw Error('RSN contains invalid character');
191
191
  }
192
192
  else if (rsn.length > 12 || rsn.length < 1) {
@@ -271,7 +271,7 @@ function getStatsByGamemode(rsn, mode) {
271
271
  if (typeof rsn !== 'string') {
272
272
  throw Error('RSN must be a string');
273
273
  }
274
- else if (!/^[a-zA-Z0-9 _]+$/.test(rsn)) {
274
+ else if (!/^[a-zA-Z0-9 _-]+$/.test(rsn)) {
275
275
  throw Error('RSN contains invalid character');
276
276
  }
277
277
  else if (rsn.length > 12 || rsn.length < 1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "osrs-json-hiscores",
3
- "version": "2.10.0",
3
+ "version": "2.10.2",
4
4
  "description": "The Old School Runescape API wrapper that does more!",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",