osrs-json-hiscores 2.24.0 → 2.25.0
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.
- package/README.md +1 -0
- package/lib/hiscores.js +28 -28
- package/lib/utils/constants.d.ts +4 -2
- package/lib/utils/constants.js +5 -1
- package/lib/utils/helpers.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -122,6 +122,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
|
|
122
122
|
| Araxxor | `araxxor` |
|
|
123
123
|
| Artio | `artio` |
|
|
124
124
|
| Barrows Chests | `barrows` |
|
|
125
|
+
| Brutus | `brutus` |
|
|
125
126
|
| Bryophyta | `bryophyta` |
|
|
126
127
|
| Callisto | `callisto` |
|
|
127
128
|
| Calvar'ion | `calvarion` |
|
package/lib/hiscores.js
CHANGED
|
@@ -97,28 +97,30 @@ exports.getOfficialStats = getOfficialStats;
|
|
|
97
97
|
* @returns Formatted version of the rsn.
|
|
98
98
|
*/
|
|
99
99
|
function getRSNFormat(rsn, config, mode) {
|
|
100
|
+
var _a, _b;
|
|
100
101
|
if (mode === void 0) { mode = 'main'; }
|
|
101
102
|
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
-
var url, response, dom,
|
|
103
|
-
return __generator(this, function (
|
|
104
|
-
switch (
|
|
103
|
+
var url, response, dom, row, innerHTML, _c;
|
|
104
|
+
return __generator(this, function (_d) {
|
|
105
|
+
switch (_d.label) {
|
|
105
106
|
case 0:
|
|
106
107
|
(0, utils_1.validateRSN)(rsn);
|
|
107
108
|
url = (0, utils_1.getPlayerTableURL)(mode, rsn);
|
|
108
|
-
|
|
109
|
+
_d.label = 1;
|
|
109
110
|
case 1:
|
|
110
|
-
|
|
111
|
+
_d.trys.push([1, 3, , 4]);
|
|
111
112
|
return [4 /*yield*/, (0, utils_1.httpGet)(url, config)];
|
|
112
113
|
case 2:
|
|
113
|
-
response =
|
|
114
|
+
response = _d.sent();
|
|
114
115
|
dom = new jsdom_1.JSDOM(response.data);
|
|
115
|
-
|
|
116
|
-
if (
|
|
117
|
-
|
|
116
|
+
row = dom.window.document.querySelector('tr.personal-hiscores__row.personal-hiscores__row--type-highlight');
|
|
117
|
+
if (row) {
|
|
118
|
+
innerHTML = (row !== null && row !== void 0 ? row : {}).innerHTML;
|
|
119
|
+
return [2 /*return*/, ((_b = (_a = innerHTML === null || innerHTML === void 0 ? void 0 : innerHTML.match(new RegExp(rsn.replace(utils_1.WHITESPACE_REGEX, utils_1.WHITESPACE_REGEX_STRING), 'gi'))) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : rsn)];
|
|
118
120
|
}
|
|
119
121
|
return [3 /*break*/, 4];
|
|
120
122
|
case 3:
|
|
121
|
-
|
|
123
|
+
_c = _d.sent();
|
|
122
124
|
throw new utils_1.HiScoresError();
|
|
123
125
|
case 4: throw new utils_1.PlayerNotFoundError();
|
|
124
126
|
}
|
|
@@ -425,19 +427,18 @@ function getSkillPage(skill, mode, page, config) {
|
|
|
425
427
|
case 1:
|
|
426
428
|
response = _a.sent();
|
|
427
429
|
dom = new jsdom_1.JSDOM(response.data);
|
|
428
|
-
playersHTML = dom.window.document.querySelectorAll('.personal-hiscores__row');
|
|
430
|
+
playersHTML = dom.window.document.querySelectorAll('tr.personal-hiscores__row');
|
|
429
431
|
players = [];
|
|
430
432
|
playersHTML.forEach(function (row) {
|
|
431
|
-
|
|
432
|
-
var
|
|
433
|
-
var
|
|
434
|
-
var
|
|
435
|
-
var isDead = !!row.querySelector('td img');
|
|
433
|
+
// Omit first cell (pre-sailing link)
|
|
434
|
+
var _a = Array.from(row.cells), rankCell = _a[1], nameCell = _a[2], levelCell = _a[3], xpCell = _a[4];
|
|
435
|
+
var isDead = !!nameCell.querySelector('img');
|
|
436
|
+
var nameElement = nameCell.querySelector('a');
|
|
436
437
|
players.push({
|
|
437
|
-
name: (0, utils_1.rsnFromElement)(
|
|
438
|
-
rank: (0, utils_1.numberFromElement)(
|
|
439
|
-
level: (0, utils_1.numberFromElement)(
|
|
440
|
-
xp: (0, utils_1.numberFromElement)(
|
|
438
|
+
name: (0, utils_1.rsnFromElement)(nameElement),
|
|
439
|
+
rank: (0, utils_1.numberFromElement)(rankCell),
|
|
440
|
+
level: (0, utils_1.numberFromElement)(levelCell),
|
|
441
|
+
xp: (0, utils_1.numberFromElement)(xpCell),
|
|
441
442
|
dead: isDead
|
|
442
443
|
});
|
|
443
444
|
});
|
|
@@ -478,17 +479,16 @@ function getActivityPage(activity, mode, page, config) {
|
|
|
478
479
|
case 1:
|
|
479
480
|
response = _a.sent();
|
|
480
481
|
dom = new jsdom_1.JSDOM(response.data);
|
|
481
|
-
playersHTML = dom.window.document.querySelectorAll('.personal-hiscores__row');
|
|
482
|
+
playersHTML = dom.window.document.querySelectorAll('tr.personal-hiscores__row');
|
|
482
483
|
players = [];
|
|
483
484
|
playersHTML.forEach(function (row) {
|
|
484
|
-
var
|
|
485
|
-
var
|
|
486
|
-
var
|
|
487
|
-
var isDead = !!row.querySelector('td img');
|
|
485
|
+
var _a = Array.from(row.cells), rankCell = _a[0], nameCell = _a[1], scoreCell = _a[2];
|
|
486
|
+
var isDead = !!nameCell.querySelector('img');
|
|
487
|
+
var nameElement = nameCell.querySelector('a');
|
|
488
488
|
players.push({
|
|
489
|
-
name: (0, utils_1.rsnFromElement)(
|
|
490
|
-
rank: (0, utils_1.numberFromElement)(
|
|
491
|
-
score: (0, utils_1.numberFromElement)(
|
|
489
|
+
name: (0, utils_1.rsnFromElement)(nameElement),
|
|
490
|
+
rank: (0, utils_1.numberFromElement)(rankCell),
|
|
491
|
+
score: (0, utils_1.numberFromElement)(scoreCell),
|
|
492
492
|
dead: isDead
|
|
493
493
|
});
|
|
494
494
|
});
|
package/lib/utils/constants.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export declare const BASE_URL = "https://secure.runescape.com/m=hiscore_oldschoo
|
|
|
2
2
|
export declare const STATS_URL = "index_lite.ws?player=";
|
|
3
3
|
export declare const JSON_STATS_URL = "index_lite.json?player=";
|
|
4
4
|
export declare const SCORES_URL = "overall.ws?";
|
|
5
|
+
export declare const WHITESPACE_REGEX_STRING = "( |-|_)";
|
|
6
|
+
export declare const WHITESPACE_REGEX: RegExp;
|
|
5
7
|
export type GamemodeUrl = {
|
|
6
8
|
[key in Gamemode]: string;
|
|
7
9
|
};
|
|
@@ -14,9 +16,9 @@ export declare const BH_MODES: readonly ["hunterV2", "rogueV2", "hunter", "rogue
|
|
|
14
16
|
export type BHType = (typeof BH_MODES)[number];
|
|
15
17
|
export declare const GAMEMODES: readonly ["main", "ironman", "hardcore", "ultimate", "deadman", "seasonal", "tournament", "skiller", "oneDefence", "freshStart"];
|
|
16
18
|
export type Gamemode = (typeof GAMEMODES)[number];
|
|
17
|
-
export declare const BOSSES: readonly ["abyssalSire", "alchemicalHydra", "amoxliatl", "araxxor", "artio", "barrows", "bryophyta", "callisto", "calvarion", "cerberus", "chambersOfXeric", "chambersOfXericChallengeMode", "chaosElemental", "chaosFanatic", "commanderZilyana", "corporealBeast", "crazyArchaeologist", "dagannothPrime", "dagannothRex", "dagannothSupreme", "derangedArchaeologist", "doomOfMokhaiotl", "dukeSucellus", "generalGraardor", "giantMole", "grotesqueGuardians", "hespori", "kalphiteQueen", "kingBlackDragon", "kraken", "kreeArra", "krilTsutsaroth", "lunarChests", "mimic", "nex", "nightmare", "phosanisNightmare", "obor", "phantomMuspah", "sarachnis", "scorpia", "scurrius", "shellbaneGryphon", "skotizo", "solHeredit", "spindel", "tempoross", "gauntlet", "corruptedGauntlet", "hueycoatl", "leviathan", "royalTitans", "whisperer", "theatreOfBlood", "theatreOfBloodHardMode", "thermonuclearSmokeDevil", "tombsOfAmascut", "tombsOfAmascutExpertMode", "tzKalZuk", "tzTokJad", "vardorvis", "venenatis", "vetion", "vorkath", "wintertodt", "yama", "zalcano", "zulrah"];
|
|
19
|
+
export declare const BOSSES: readonly ["abyssalSire", "alchemicalHydra", "amoxliatl", "araxxor", "artio", "barrows", "brutus", "bryophyta", "callisto", "calvarion", "cerberus", "chambersOfXeric", "chambersOfXericChallengeMode", "chaosElemental", "chaosFanatic", "commanderZilyana", "corporealBeast", "crazyArchaeologist", "dagannothPrime", "dagannothRex", "dagannothSupreme", "derangedArchaeologist", "doomOfMokhaiotl", "dukeSucellus", "generalGraardor", "giantMole", "grotesqueGuardians", "hespori", "kalphiteQueen", "kingBlackDragon", "kraken", "kreeArra", "krilTsutsaroth", "lunarChests", "mimic", "nex", "nightmare", "phosanisNightmare", "obor", "phantomMuspah", "sarachnis", "scorpia", "scurrius", "shellbaneGryphon", "skotizo", "solHeredit", "spindel", "tempoross", "gauntlet", "corruptedGauntlet", "hueycoatl", "leviathan", "royalTitans", "whisperer", "theatreOfBlood", "theatreOfBloodHardMode", "thermonuclearSmokeDevil", "tombsOfAmascut", "tombsOfAmascutExpertMode", "tzKalZuk", "tzTokJad", "vardorvis", "venenatis", "vetion", "vorkath", "wintertodt", "yama", "zalcano", "zulrah"];
|
|
18
20
|
export type Boss = (typeof BOSSES)[number];
|
|
19
|
-
export declare const ACTIVITIES: readonly ["leaguePoints", "deadmanPoints", "hunterBHV2", "rogueBHV2", "hunterBH", "rogueBH", "allClues", "beginnerClues", "easyClues", "mediumClues", "hardClues", "eliteClues", "masterClues", "lastManStanding", "pvpArena", "soulWarsZeal", "riftsClosed", "colosseumGlory", "collectionsLogged", "abyssalSire", "alchemicalHydra", "amoxliatl", "araxxor", "artio", "barrows", "bryophyta", "callisto", "calvarion", "cerberus", "chambersOfXeric", "chambersOfXericChallengeMode", "chaosElemental", "chaosFanatic", "commanderZilyana", "corporealBeast", "crazyArchaeologist", "dagannothPrime", "dagannothRex", "dagannothSupreme", "derangedArchaeologist", "doomOfMokhaiotl", "dukeSucellus", "generalGraardor", "giantMole", "grotesqueGuardians", "hespori", "kalphiteQueen", "kingBlackDragon", "kraken", "kreeArra", "krilTsutsaroth", "lunarChests", "mimic", "nex", "nightmare", "phosanisNightmare", "obor", "phantomMuspah", "sarachnis", "scorpia", "scurrius", "shellbaneGryphon", "skotizo", "solHeredit", "spindel", "tempoross", "gauntlet", "corruptedGauntlet", "hueycoatl", "leviathan", "royalTitans", "whisperer", "theatreOfBlood", "theatreOfBloodHardMode", "thermonuclearSmokeDevil", "tombsOfAmascut", "tombsOfAmascutExpertMode", "tzKalZuk", "tzTokJad", "vardorvis", "venenatis", "vetion", "vorkath", "wintertodt", "yama", "zalcano", "zulrah"];
|
|
21
|
+
export declare const ACTIVITIES: readonly ["leaguePoints", "deadmanPoints", "hunterBHV2", "rogueBHV2", "hunterBH", "rogueBH", "allClues", "beginnerClues", "easyClues", "mediumClues", "hardClues", "eliteClues", "masterClues", "lastManStanding", "pvpArena", "soulWarsZeal", "riftsClosed", "colosseumGlory", "collectionsLogged", "abyssalSire", "alchemicalHydra", "amoxliatl", "araxxor", "artio", "barrows", "brutus", "bryophyta", "callisto", "calvarion", "cerberus", "chambersOfXeric", "chambersOfXericChallengeMode", "chaosElemental", "chaosFanatic", "commanderZilyana", "corporealBeast", "crazyArchaeologist", "dagannothPrime", "dagannothRex", "dagannothSupreme", "derangedArchaeologist", "doomOfMokhaiotl", "dukeSucellus", "generalGraardor", "giantMole", "grotesqueGuardians", "hespori", "kalphiteQueen", "kingBlackDragon", "kraken", "kreeArra", "krilTsutsaroth", "lunarChests", "mimic", "nex", "nightmare", "phosanisNightmare", "obor", "phantomMuspah", "sarachnis", "scorpia", "scurrius", "shellbaneGryphon", "skotizo", "solHeredit", "spindel", "tempoross", "gauntlet", "corruptedGauntlet", "hueycoatl", "leviathan", "royalTitans", "whisperer", "theatreOfBlood", "theatreOfBloodHardMode", "thermonuclearSmokeDevil", "tombsOfAmascut", "tombsOfAmascutExpertMode", "tzKalZuk", "tzTokJad", "vardorvis", "venenatis", "vetion", "vorkath", "wintertodt", "yama", "zalcano", "zulrah"];
|
|
20
22
|
export type ActivityName = (typeof ACTIVITIES)[number];
|
|
21
23
|
export type FormattedBossNames = {
|
|
22
24
|
[key in Boss]: string;
|
package/lib/utils/constants.js
CHANGED
|
@@ -24,11 +24,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
24
24
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.HiScoresError = exports.PlayerNotFoundError = exports.InvalidRSNError = exports.InvalidFormatError = exports.HISCORES_ERROR = exports.PLAYER_NOT_FOUND_ERROR = exports.INVALID_FORMAT_ERROR = exports.FORMATTED_COLLECTIONS_LOGGED = exports.FORMATTED_COLOSSEUM_GLORY = exports.FORMATTED_RIFTS_CLOSED = exports.FORMATTED_DEADMAN_POINTS = exports.FORMATTED_LEAGUE_POINTS = exports.FORMATTED_SOUL_WARS = exports.FORMATTED_PVP_ARENA = exports.FORMATTED_LMS = exports.FORMATTED_BH_NAMES = exports.FORMATTED_CLUE_NAMES = exports.FORMATTED_SKILL_NAMES = exports.FORMATTED_BOSS_NAMES = exports.ACTIVITIES = exports.BOSSES = exports.GAMEMODES = exports.BH_MODES = exports.CLUES = exports.SKILLS = exports.GAMEMODE_URL = exports.SCORES_URL = exports.JSON_STATS_URL = exports.STATS_URL = exports.BASE_URL = void 0;
|
|
27
|
+
exports.HiScoresError = exports.PlayerNotFoundError = exports.InvalidRSNError = exports.InvalidFormatError = exports.HISCORES_ERROR = exports.PLAYER_NOT_FOUND_ERROR = exports.INVALID_FORMAT_ERROR = exports.FORMATTED_COLLECTIONS_LOGGED = exports.FORMATTED_COLOSSEUM_GLORY = exports.FORMATTED_RIFTS_CLOSED = exports.FORMATTED_DEADMAN_POINTS = exports.FORMATTED_LEAGUE_POINTS = exports.FORMATTED_SOUL_WARS = exports.FORMATTED_PVP_ARENA = exports.FORMATTED_LMS = exports.FORMATTED_BH_NAMES = exports.FORMATTED_CLUE_NAMES = exports.FORMATTED_SKILL_NAMES = exports.FORMATTED_BOSS_NAMES = exports.ACTIVITIES = exports.BOSSES = exports.GAMEMODES = exports.BH_MODES = exports.CLUES = exports.SKILLS = exports.GAMEMODE_URL = exports.WHITESPACE_REGEX = exports.WHITESPACE_REGEX_STRING = exports.SCORES_URL = exports.JSON_STATS_URL = exports.STATS_URL = exports.BASE_URL = void 0;
|
|
28
28
|
exports.BASE_URL = 'https://secure.runescape.com/m=hiscore_oldschool';
|
|
29
29
|
exports.STATS_URL = 'index_lite.ws?player=';
|
|
30
30
|
exports.JSON_STATS_URL = 'index_lite.json?player=';
|
|
31
31
|
exports.SCORES_URL = 'overall.ws?';
|
|
32
|
+
exports.WHITESPACE_REGEX_STRING = '( |-|_)';
|
|
33
|
+
exports.WHITESPACE_REGEX = new RegExp(exports.WHITESPACE_REGEX_STRING, 'g');
|
|
32
34
|
exports.GAMEMODE_URL = {
|
|
33
35
|
main: "".concat(exports.BASE_URL, "/"),
|
|
34
36
|
ironman: "".concat(exports.BASE_URL, "_ironman/"),
|
|
@@ -97,6 +99,7 @@ exports.BOSSES = [
|
|
|
97
99
|
'araxxor',
|
|
98
100
|
'artio',
|
|
99
101
|
'barrows',
|
|
102
|
+
'brutus',
|
|
100
103
|
'bryophyta',
|
|
101
104
|
'callisto',
|
|
102
105
|
'calvarion',
|
|
@@ -188,6 +191,7 @@ exports.FORMATTED_BOSS_NAMES = {
|
|
|
188
191
|
araxxor: 'Araxxor',
|
|
189
192
|
artio: 'Artio',
|
|
190
193
|
barrows: 'Barrows Chests',
|
|
194
|
+
brutus: 'Brutus',
|
|
191
195
|
bryophyta: 'Bryophyta',
|
|
192
196
|
callisto: 'Callisto',
|
|
193
197
|
calvarion: "Calvar'ion",
|
package/lib/utils/helpers.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export declare const numberFromElement: (el: Element | null) => number;
|
|
|
48
48
|
* @param el OSRS hiscores table cell element.
|
|
49
49
|
* @returns RSN parsed from cell text.
|
|
50
50
|
*/
|
|
51
|
-
export declare const rsnFromElement: (el:
|
|
51
|
+
export declare const rsnFromElement: (el: HTMLAnchorElement | null) => string;
|
|
52
52
|
/**
|
|
53
53
|
* Will run an Axios `GET` request against a given URL after injecting a `User-Agent` header.
|
|
54
54
|
*
|