mirror of
https://github.com/maxswa/osrs-json-hiscores.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c43858eac1 | ||
|
|
0d0081f4f6 | ||
|
|
3570f0f07d | ||
|
|
3ddda54e02 | ||
|
|
388f01522a | ||
|
|
24b3de2a29 | ||
|
|
fc7897d4c7 | ||
|
|
72ea31490f | ||
|
|
66825955c1 | ||
|
|
4b4bf8c702 | ||
|
|
53981e7468 | ||
|
|
a90e5b98dd | ||
|
|
16a975f10b | ||
|
|
c800501188 | ||
|
|
8a320df015 | ||
|
|
169462c446 | ||
|
|
317a972314 | ||
|
|
c558f8402c |
@@ -144,6 +144,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
|||||||
| Dagannoth Rex | `dagannothRex` |
|
| Dagannoth Rex | `dagannothRex` |
|
||||||
| Dagannoth Supreme | `dagannothSupreme` |
|
| Dagannoth Supreme | `dagannothSupreme` |
|
||||||
| Deranged Archaeologist | `derangedArchaeologist` |
|
| Deranged Archaeologist | `derangedArchaeologist` |
|
||||||
|
| Duke Sucellus | `dukeSucellus` |
|
||||||
| General Graardor | `generalGraardor` |
|
| General Graardor | `generalGraardor` |
|
||||||
| Giant Mole | `giantMole` |
|
| Giant Mole | `giantMole` |
|
||||||
| Grotesque Guardians | `grotesqueGuardians` |
|
| Grotesque Guardians | `grotesqueGuardians` |
|
||||||
@@ -166,6 +167,8 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
|||||||
| Tempoross | `tempoross` |
|
| Tempoross | `tempoross` |
|
||||||
| The Gauntlet | `gauntlet` |
|
| The Gauntlet | `gauntlet` |
|
||||||
| The Corrupted Gauntlet | `corruptedGauntlet` |
|
| The Corrupted Gauntlet | `corruptedGauntlet` |
|
||||||
|
| The Leviathan | `leviathan` |
|
||||||
|
| The Whisperer | `whisperer` |
|
||||||
| Theatre Of Blood | `theatreOfBlood` |
|
| Theatre Of Blood | `theatreOfBlood` |
|
||||||
| Theatre Of Blood: Hard Mode | `theatreOfBloodHardMode` |
|
| Theatre Of Blood: Hard Mode | `theatreOfBloodHardMode` |
|
||||||
| Thermonuclear Smoke Devil | `thermonuclearSmokeDevil` |
|
| Thermonuclear Smoke Devil | `thermonuclearSmokeDevil` |
|
||||||
@@ -173,6 +176,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
|||||||
| Tombs of Amascut: Expert Mode | `tombsOfAmascutExpertMode` |
|
| Tombs of Amascut: Expert Mode | `tombsOfAmascutExpertMode` |
|
||||||
| TzKal-Zuk | `tzKalZuk` |
|
| TzKal-Zuk | `tzKalZuk` |
|
||||||
| TzTok-Jad | `tzTokJad` |
|
| TzTok-Jad | `tzTokJad` |
|
||||||
|
| Vardorvis | `vardorvis` |
|
||||||
| Venenatis | `venenatis` |
|
| Venenatis | `venenatis` |
|
||||||
| Vetion | `vetion` |
|
| Vetion | `vetion` |
|
||||||
| Vorkath | `vorkath` |
|
| Vorkath | `vorkath` |
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ test('Parse CSV to json', () => {
|
|||||||
4342,1655
|
4342,1655
|
||||||
966,2951
|
966,2951
|
||||||
10151,1
|
10151,1
|
||||||
|
1289,2477
|
||||||
1288,2407
|
1288,2407
|
||||||
377,4669
|
377,4669
|
||||||
545,1567
|
545,1567
|
||||||
@@ -134,6 +135,8 @@ test('Parse CSV to json', () => {
|
|||||||
18823,23
|
18823,23
|
||||||
63,375
|
63,375
|
||||||
2870,6
|
2870,6
|
||||||
|
2871,7
|
||||||
|
2872,8
|
||||||
6984,138
|
6984,138
|
||||||
23,923141
|
23,923141
|
||||||
4043,2000
|
4043,2000
|
||||||
@@ -141,6 +144,7 @@ test('Parse CSV to json', () => {
|
|||||||
289,13070
|
289,13070
|
||||||
489,8
|
489,8
|
||||||
967,47
|
967,47
|
||||||
|
968,48
|
||||||
11155,223
|
11155,223
|
||||||
1940,272
|
1940,272
|
||||||
8623,1340
|
8623,1340
|
||||||
@@ -215,6 +219,7 @@ test('Parse CSV to json', () => {
|
|||||||
dagannothRex: { rank: 4342, score: 1655 },
|
dagannothRex: { rank: 4342, score: 1655 },
|
||||||
dagannothSupreme: { rank: 966, score: 2951 },
|
dagannothSupreme: { rank: 966, score: 2951 },
|
||||||
derangedArchaeologist: { rank: 10151, score: 1 },
|
derangedArchaeologist: { rank: 10151, score: 1 },
|
||||||
|
dukeSucellus: { rank: 1289, score: 2477 },
|
||||||
generalGraardor: { rank: 1288, score: 2407 },
|
generalGraardor: { rank: 1288, score: 2407 },
|
||||||
giantMole: { rank: 377, score: 4669 },
|
giantMole: { rank: 377, score: 4669 },
|
||||||
grotesqueGuardians: { rank: 545, score: 1567 },
|
grotesqueGuardians: { rank: 545, score: 1567 },
|
||||||
@@ -237,6 +242,8 @@ test('Parse CSV to json', () => {
|
|||||||
tempoross: { rank: 18823, score: 23 },
|
tempoross: { rank: 18823, score: 23 },
|
||||||
gauntlet: { rank: 63, score: 375 },
|
gauntlet: { rank: 63, score: 375 },
|
||||||
corruptedGauntlet: { rank: 2870, score: 6 },
|
corruptedGauntlet: { rank: 2870, score: 6 },
|
||||||
|
leviathan: { rank: 2871, score: 7 },
|
||||||
|
whisperer: { rank: 2872, score: 8 },
|
||||||
theatreOfBlood: { rank: 6984, score: 138 },
|
theatreOfBlood: { rank: 6984, score: 138 },
|
||||||
theatreOfBloodHardMode: { rank: 23, score: 923141 },
|
theatreOfBloodHardMode: { rank: 23, score: 923141 },
|
||||||
thermonuclearSmokeDevil: { rank: 4043, score: 2000 },
|
thermonuclearSmokeDevil: { rank: 4043, score: 2000 },
|
||||||
@@ -244,6 +251,7 @@ test('Parse CSV to json', () => {
|
|||||||
tombsOfAmascutExpertMode: { rank: 289, score: 13070 },
|
tombsOfAmascutExpertMode: { rank: 289, score: 13070 },
|
||||||
tzKalZuk: { rank: 489, score: 8 },
|
tzKalZuk: { rank: 489, score: 8 },
|
||||||
tzTokJad: { rank: 967, score: 47 },
|
tzTokJad: { rank: 967, score: 47 },
|
||||||
|
vardorvis: { rank: 968, score: 48 },
|
||||||
venenatis: { rank: 11155, score: 223 },
|
venenatis: { rank: 11155, score: 223 },
|
||||||
vetion: { rank: 1940, score: 272 },
|
vetion: { rank: 1940, score: 272 },
|
||||||
vorkath: { rank: 8623, score: 1340 },
|
vorkath: { rank: 8623, score: 1340 },
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
8,99,200000000
|
8,99,200000000
|
||||||
11,99,200000000
|
11,99,200000000
|
||||||
32,99,200000000
|
32,99,200000000
|
||||||
159,99,200000000
|
157,99,200000000
|
||||||
15,99,200000000
|
15,99,200000000
|
||||||
12,99,200000000
|
12,99,200000000
|
||||||
9,99,200000000
|
9,99,200000000
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
3,99,200000000
|
3,99,200000000
|
||||||
25,99,200000000
|
25,99,200000000
|
||||||
5,99,200000000
|
5,99,200000000
|
||||||
23,99,200000000
|
24,99,200000000
|
||||||
12,99,200000000
|
12,99,200000000
|
||||||
2,99,200000000
|
2,99,200000000
|
||||||
19,99,200000000
|
19,99,200000000
|
||||||
@@ -27,11 +27,11 @@
|
|||||||
-1,-1
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
|
764013,22
|
||||||
-1,-1
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
-1,-1
|
480246,22
|
||||||
347584,22
|
|
||||||
-1,-1
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
@@ -88,6 +88,10 @@
|
|||||||
-1,-1
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
|
196,186
|
||||||
|
-1,-1
|
||||||
|
-1,-1
|
||||||
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
|
|||||||
|
Can't render this file because it has a wrong number of fields in line 25.
|
39
package.json
39
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "osrs-json-hiscores",
|
"name": "osrs-json-hiscores",
|
||||||
"version": "2.14.0",
|
"version": "2.15.0",
|
||||||
"description": "The Old School Runescape API wrapper that does more!",
|
"description": "The Old School Runescape API wrapper that does more!",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
@@ -61,7 +61,8 @@
|
|||||||
"@typescript-eslint"
|
"@typescript-eslint"
|
||||||
],
|
],
|
||||||
"extends": [
|
"extends": [
|
||||||
"eslint-config-airbnb-typescript",
|
"airbnb-base",
|
||||||
|
"airbnb-typescript/base",
|
||||||
"prettier"
|
"prettier"
|
||||||
],
|
],
|
||||||
"ignorePatterns": [
|
"ignorePatterns": [
|
||||||
@@ -72,7 +73,8 @@
|
|||||||
"trailingComma": "none",
|
"trailingComma": "none",
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"semi": true,
|
"semi": true,
|
||||||
"singleQuote": true
|
"singleQuote": true,
|
||||||
|
"endOfLine": "auto"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"transform": {
|
"transform": {
|
||||||
@@ -91,27 +93,24 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"jsdom": "^16.3.0",
|
"jsdom": "^22.1.0",
|
||||||
"useragent-generator": "^1.1.0"
|
"useragent-generator": "^1.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^26.0.21",
|
"@types/jest": "^29.5.3",
|
||||||
"@types/jsdom": "^16.2.3",
|
"@types/jsdom": "^21.1.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.19.0",
|
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
||||||
"@typescript-eslint/parser": "^4.19.0",
|
"@typescript-eslint/parser": "^6.0.0",
|
||||||
"eslint": "^7.22.0",
|
"eslint": "^8.44.0",
|
||||||
"eslint-config-airbnb-typescript": "^12.3.1",
|
"eslint-config-airbnb-typescript": "^17.1.0",
|
||||||
"eslint-config-prettier": "^8.1.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
"eslint-plugin-import": "^2.22.1",
|
"eslint-plugin-import": "^2.27.5",
|
||||||
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
||||||
"eslint-plugin-react": "^7.23.1",
|
|
||||||
"eslint-plugin-react-hooks": "^4.2.0",
|
|
||||||
"husky": "^5.2.0",
|
"husky": "^5.2.0",
|
||||||
"jest": "^26.6.3",
|
"jest": "^29.6.1",
|
||||||
"lint-staged": "^10.5.4",
|
"lint-staged": "^13.2.3",
|
||||||
"np": "^7.7.0",
|
"np": "^7.7.0",
|
||||||
"prettier": "^2.2.1",
|
"prettier": "^3.0.0",
|
||||||
"ts-jest": "^26.5.4",
|
"ts-jest": "^29.1.1",
|
||||||
"typescript": "^4.2.3"
|
"typescript": "^5.1.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { AxiosResponse } from 'axios';
|
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||||
import { BinaryData, JSDOM } from 'jsdom';
|
import { BinaryData, JSDOM } from 'jsdom';
|
||||||
import {
|
import {
|
||||||
Player,
|
Player,
|
||||||
@@ -38,15 +38,20 @@ import {
|
|||||||
* Screen scrapes the hiscores to get the formatted rsn of a player.
|
* Screen scrapes the hiscores to get the formatted rsn of a player.
|
||||||
*
|
*
|
||||||
* @param rsn Username of the player.
|
* @param rsn Username of the player.
|
||||||
|
* @param config Optional axios request config object.
|
||||||
* @returns Formatted version of the rsn.
|
* @returns Formatted version of the rsn.
|
||||||
*/
|
*/
|
||||||
export async function getRSNFormat(rsn: string): Promise<string> {
|
export async function getRSNFormat(
|
||||||
|
rsn: string,
|
||||||
|
config?: AxiosRequestConfig
|
||||||
|
): Promise<string> {
|
||||||
validateRSN(rsn);
|
validateRSN(rsn);
|
||||||
|
|
||||||
const url = getPlayerTableURL('main', rsn);
|
const url = getPlayerTableURL('main', rsn);
|
||||||
try {
|
try {
|
||||||
const response = await httpGet<string | Buffer | BinaryData | undefined>(
|
const response = await httpGet<string | Buffer | BinaryData | undefined>(
|
||||||
url
|
url,
|
||||||
|
config
|
||||||
);
|
);
|
||||||
const dom = new JSDOM(response.data);
|
const dom = new JSDOM(response.data);
|
||||||
const anchor = dom.window.document.querySelector(
|
const anchor = dom.window.document.querySelector(
|
||||||
@@ -106,12 +111,8 @@ export function parseStats(csv: string): Stats {
|
|||||||
const [leaguePoints] = activityObjects.splice(0, 1);
|
const [leaguePoints] = activityObjects.splice(0, 1);
|
||||||
const bhObjects = activityObjects.splice(0, BH_MODES.length);
|
const bhObjects = activityObjects.splice(0, BH_MODES.length);
|
||||||
const clueObjects = activityObjects.splice(0, CLUES.length);
|
const clueObjects = activityObjects.splice(0, CLUES.length);
|
||||||
const [
|
const [lastManStanding, pvpArena, soulWarsZeal, riftsClosed] =
|
||||||
lastManStanding,
|
activityObjects.splice(0, 4);
|
||||||
pvpArena,
|
|
||||||
soulWarsZeal,
|
|
||||||
riftsClosed
|
|
||||||
] = activityObjects.splice(0, 4);
|
|
||||||
const bossObjects = activityObjects.splice(0, BOSSES.length);
|
const bossObjects = activityObjects.splice(0, BOSSES.length);
|
||||||
|
|
||||||
const skills: Skills = skillObjects.reduce<Skills>((prev, curr, index) => {
|
const skills: Skills = skillObjects.reduce<Skills>((prev, curr, index) => {
|
||||||
@@ -174,7 +175,10 @@ export async function getStats(
|
|||||||
];
|
];
|
||||||
const shouldGetFormattedRsn = options?.shouldGetFormattedRsn ?? true;
|
const shouldGetFormattedRsn = options?.shouldGetFormattedRsn ?? true;
|
||||||
|
|
||||||
const mainRes = await httpGet<string>(getStatsURL('main', rsn));
|
const mainRes = await httpGet<string>(
|
||||||
|
getStatsURL('main', rsn),
|
||||||
|
options?.axiosConfigs?.main
|
||||||
|
);
|
||||||
if (mainRes.status === 200) {
|
if (mainRes.status === 200) {
|
||||||
const emptyResponse: AxiosResponse<string> = {
|
const emptyResponse: AxiosResponse<string> = {
|
||||||
status: 404,
|
status: 404,
|
||||||
@@ -187,10 +191,15 @@ export async function getStats(
|
|||||||
mode: Extract<Gamemode, 'ironman' | 'hardcore' | 'ultimate'>
|
mode: Extract<Gamemode, 'ironman' | 'hardcore' | 'ultimate'>
|
||||||
): Promise<AxiosResponse<string>> =>
|
): Promise<AxiosResponse<string>> =>
|
||||||
otherGamemodes.includes(mode)
|
otherGamemodes.includes(mode)
|
||||||
? httpGet<string>(getStatsURL(mode, rsn)).catch((err) => err)
|
? httpGet<string>(
|
||||||
|
getStatsURL(mode, rsn),
|
||||||
|
options?.axiosConfigs?.[mode]
|
||||||
|
).catch((err) => err)
|
||||||
: emptyResponse;
|
: emptyResponse;
|
||||||
const formattedName = shouldGetFormattedRsn
|
const formattedName = shouldGetFormattedRsn
|
||||||
? await getRSNFormat(rsn).catch(() => undefined)
|
? await getRSNFormat(rsn, options?.axiosConfigs?.rsn).catch(
|
||||||
|
() => undefined
|
||||||
|
)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const player: Player = {
|
const player: Player = {
|
||||||
@@ -258,17 +267,19 @@ export async function getStats(
|
|||||||
*
|
*
|
||||||
* @param rsn Username of the player.
|
* @param rsn Username of the player.
|
||||||
* @param mode Gamemode to fetch ranks for.
|
* @param mode Gamemode to fetch ranks for.
|
||||||
|
* @param config Optional axios request config object.
|
||||||
* @returns Stats object.
|
* @returns Stats object.
|
||||||
*/
|
*/
|
||||||
export async function getStatsByGamemode(
|
export async function getStatsByGamemode(
|
||||||
rsn: string,
|
rsn: string,
|
||||||
mode: Gamemode = 'main'
|
mode: Gamemode = 'main',
|
||||||
|
config?: AxiosRequestConfig
|
||||||
): Promise<Stats> {
|
): Promise<Stats> {
|
||||||
validateRSN(rsn);
|
validateRSN(rsn);
|
||||||
if (!GAMEMODES.includes(mode)) {
|
if (!GAMEMODES.includes(mode)) {
|
||||||
throw Error('Invalid game mode');
|
throw Error('Invalid game mode');
|
||||||
}
|
}
|
||||||
const response = await httpGet<string>(getStatsURL(mode, rsn));
|
const response = await httpGet<string>(getStatsURL(mode, rsn), config);
|
||||||
if (response.status !== 200) {
|
if (response.status !== 200) {
|
||||||
throw Error('Player not found');
|
throw Error('Player not found');
|
||||||
}
|
}
|
||||||
@@ -280,7 +291,8 @@ export async function getStatsByGamemode(
|
|||||||
export async function getSkillPage(
|
export async function getSkillPage(
|
||||||
skill: SkillName,
|
skill: SkillName,
|
||||||
mode: Gamemode = 'main',
|
mode: Gamemode = 'main',
|
||||||
page: number = 1
|
page: number = 1,
|
||||||
|
config?: AxiosRequestConfig
|
||||||
): Promise<PlayerSkillRow[]> {
|
): Promise<PlayerSkillRow[]> {
|
||||||
if (!GAMEMODES.includes(mode)) {
|
if (!GAMEMODES.includes(mode)) {
|
||||||
throw Error('Invalid game mode');
|
throw Error('Invalid game mode');
|
||||||
@@ -291,7 +303,10 @@ export async function getSkillPage(
|
|||||||
}
|
}
|
||||||
const url = getSkillPageURL(mode, skill, page);
|
const url = getSkillPageURL(mode, skill, page);
|
||||||
|
|
||||||
const response = await httpGet<string | Buffer | BinaryData | undefined>(url);
|
const response = await httpGet<string | Buffer | BinaryData | undefined>(
|
||||||
|
url,
|
||||||
|
config
|
||||||
|
);
|
||||||
const dom = new JSDOM(response.data);
|
const dom = new JSDOM(response.data);
|
||||||
const playersHTML = dom.window.document.querySelectorAll(
|
const playersHTML = dom.window.document.querySelectorAll(
|
||||||
'.personal-hiscores__row'
|
'.personal-hiscores__row'
|
||||||
@@ -323,12 +338,14 @@ export async function getSkillPage(
|
|||||||
* @param activity Name of the activity or boss to fetch hiscores for.
|
* @param activity Name of the activity or boss to fetch hiscores for.
|
||||||
* @param mode Gamemode to fetch ranks for.
|
* @param mode Gamemode to fetch ranks for.
|
||||||
* @param page Page number.
|
* @param page Page number.
|
||||||
|
* @param config Optional axios request config object.
|
||||||
* @returns Array of `PlayerActivityRow` objects.
|
* @returns Array of `PlayerActivityRow` objects.
|
||||||
*/
|
*/
|
||||||
export async function getActivityPage(
|
export async function getActivityPage(
|
||||||
activity: ActivityName,
|
activity: ActivityName,
|
||||||
mode: Gamemode = 'main',
|
mode: Gamemode = 'main',
|
||||||
page: number = 1
|
page: number = 1,
|
||||||
|
config?: AxiosRequestConfig
|
||||||
): Promise<PlayerActivityRow[]> {
|
): Promise<PlayerActivityRow[]> {
|
||||||
if (!GAMEMODES.includes(mode)) {
|
if (!GAMEMODES.includes(mode)) {
|
||||||
throw Error('Invalid game mode');
|
throw Error('Invalid game mode');
|
||||||
@@ -339,7 +356,10 @@ export async function getActivityPage(
|
|||||||
}
|
}
|
||||||
const url = getActivityPageURL(mode, activity, page);
|
const url = getActivityPageURL(mode, activity, page);
|
||||||
|
|
||||||
const response = await httpGet<string | Buffer | BinaryData | undefined>(url);
|
const response = await httpGet<string | Buffer | BinaryData | undefined>(
|
||||||
|
url,
|
||||||
|
config
|
||||||
|
);
|
||||||
const dom = new JSDOM(response.data);
|
const dom = new JSDOM(response.data);
|
||||||
const playersHTML = dom.window.document.querySelectorAll(
|
const playersHTML = dom.window.document.querySelectorAll(
|
||||||
'.personal-hiscores__row'
|
'.personal-hiscores__row'
|
||||||
|
|||||||
15
src/types.ts
15
src/types.ts
@@ -1,3 +1,5 @@
|
|||||||
|
import { AxiosRequestConfig } from 'axios';
|
||||||
|
|
||||||
export type Gamemode =
|
export type Gamemode =
|
||||||
| 'main'
|
| 'main'
|
||||||
| 'ironman'
|
| 'ironman'
|
||||||
@@ -84,6 +86,7 @@ export type Boss =
|
|||||||
| 'dagannothRex'
|
| 'dagannothRex'
|
||||||
| 'dagannothSupreme'
|
| 'dagannothSupreme'
|
||||||
| 'derangedArchaeologist'
|
| 'derangedArchaeologist'
|
||||||
|
| 'dukeSucellus'
|
||||||
| 'generalGraardor'
|
| 'generalGraardor'
|
||||||
| 'giantMole'
|
| 'giantMole'
|
||||||
| 'grotesqueGuardians'
|
| 'grotesqueGuardians'
|
||||||
@@ -106,6 +109,8 @@ export type Boss =
|
|||||||
| 'tempoross'
|
| 'tempoross'
|
||||||
| 'gauntlet'
|
| 'gauntlet'
|
||||||
| 'corruptedGauntlet'
|
| 'corruptedGauntlet'
|
||||||
|
| 'leviathan'
|
||||||
|
| 'whisperer'
|
||||||
| 'theatreOfBlood'
|
| 'theatreOfBlood'
|
||||||
| 'theatreOfBloodHardMode'
|
| 'theatreOfBloodHardMode'
|
||||||
| 'thermonuclearSmokeDevil'
|
| 'thermonuclearSmokeDevil'
|
||||||
@@ -113,6 +118,7 @@ export type Boss =
|
|||||||
| 'tombsOfAmascutExpertMode'
|
| 'tombsOfAmascutExpertMode'
|
||||||
| 'tzKalZuk'
|
| 'tzKalZuk'
|
||||||
| 'tzTokJad'
|
| 'tzTokJad'
|
||||||
|
| 'vardorvis'
|
||||||
| 'venenatis'
|
| 'venenatis'
|
||||||
| 'vetion'
|
| 'vetion'
|
||||||
| 'vorkath'
|
| 'vorkath'
|
||||||
@@ -183,4 +189,13 @@ export interface GetStatsOptions {
|
|||||||
* @defaultvalue `true`
|
* @defaultvalue `true`
|
||||||
*/
|
*/
|
||||||
shouldGetFormattedRsn?: boolean;
|
shouldGetFormattedRsn?: boolean;
|
||||||
|
/**
|
||||||
|
* Map of configs for each requests that can take place in the `getStats` function.
|
||||||
|
*/
|
||||||
|
axiosConfigs?: Partial<Record<Gamemode, AxiosRequestConfig>> & {
|
||||||
|
/**
|
||||||
|
* The axios request config object to use for the RSN format request.
|
||||||
|
*/
|
||||||
|
rsn?: AxiosRequestConfig;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ export const BOSSES: Boss[] = [
|
|||||||
'dagannothRex',
|
'dagannothRex',
|
||||||
'dagannothSupreme',
|
'dagannothSupreme',
|
||||||
'derangedArchaeologist',
|
'derangedArchaeologist',
|
||||||
|
'dukeSucellus',
|
||||||
'generalGraardor',
|
'generalGraardor',
|
||||||
'giantMole',
|
'giantMole',
|
||||||
'grotesqueGuardians',
|
'grotesqueGuardians',
|
||||||
@@ -114,6 +115,8 @@ export const BOSSES: Boss[] = [
|
|||||||
'tempoross',
|
'tempoross',
|
||||||
'gauntlet',
|
'gauntlet',
|
||||||
'corruptedGauntlet',
|
'corruptedGauntlet',
|
||||||
|
'leviathan',
|
||||||
|
'whisperer',
|
||||||
'theatreOfBlood',
|
'theatreOfBlood',
|
||||||
'theatreOfBloodHardMode',
|
'theatreOfBloodHardMode',
|
||||||
'thermonuclearSmokeDevil',
|
'thermonuclearSmokeDevil',
|
||||||
@@ -121,6 +124,7 @@ export const BOSSES: Boss[] = [
|
|||||||
'tombsOfAmascutExpertMode',
|
'tombsOfAmascutExpertMode',
|
||||||
'tzKalZuk',
|
'tzKalZuk',
|
||||||
'tzTokJad',
|
'tzTokJad',
|
||||||
|
'vardorvis',
|
||||||
'venenatis',
|
'venenatis',
|
||||||
'vetion',
|
'vetion',
|
||||||
'vorkath',
|
'vorkath',
|
||||||
@@ -172,6 +176,7 @@ export const FORMATTED_BOSS_NAMES: FormattedBossNames = {
|
|||||||
dagannothRex: 'Dagannoth Rex',
|
dagannothRex: 'Dagannoth Rex',
|
||||||
dagannothSupreme: 'Dagannoth Supreme',
|
dagannothSupreme: 'Dagannoth Supreme',
|
||||||
derangedArchaeologist: 'Deranged Archaeologist',
|
derangedArchaeologist: 'Deranged Archaeologist',
|
||||||
|
dukeSucellus: 'Duke Sucellus',
|
||||||
generalGraardor: 'General Graardor',
|
generalGraardor: 'General Graardor',
|
||||||
giantMole: 'Giant Mole',
|
giantMole: 'Giant Mole',
|
||||||
grotesqueGuardians: 'Grotesque Guardians',
|
grotesqueGuardians: 'Grotesque Guardians',
|
||||||
@@ -194,6 +199,8 @@ export const FORMATTED_BOSS_NAMES: FormattedBossNames = {
|
|||||||
tempoross: 'Tempoross',
|
tempoross: 'Tempoross',
|
||||||
gauntlet: 'The Gauntlet',
|
gauntlet: 'The Gauntlet',
|
||||||
corruptedGauntlet: 'The Corrupted Gauntlet',
|
corruptedGauntlet: 'The Corrupted Gauntlet',
|
||||||
|
leviathan: 'The Leviathan',
|
||||||
|
whisperer: 'The Whisperer',
|
||||||
theatreOfBlood: 'Theatre of Blood',
|
theatreOfBlood: 'Theatre of Blood',
|
||||||
theatreOfBloodHardMode: 'Theatre of Blood: Hard Mode',
|
theatreOfBloodHardMode: 'Theatre of Blood: Hard Mode',
|
||||||
thermonuclearSmokeDevil: 'Thermonuclear Smoke Devil',
|
thermonuclearSmokeDevil: 'Thermonuclear Smoke Devil',
|
||||||
@@ -201,6 +208,7 @@ export const FORMATTED_BOSS_NAMES: FormattedBossNames = {
|
|||||||
tombsOfAmascutExpertMode: 'Tombs of Amascut: Expert Mode',
|
tombsOfAmascutExpertMode: 'Tombs of Amascut: Expert Mode',
|
||||||
tzKalZuk: 'TzKal-Zuk',
|
tzKalZuk: 'TzKal-Zuk',
|
||||||
tzTokJad: 'TzTok-Jad',
|
tzTokJad: 'TzTok-Jad',
|
||||||
|
vardorvis: 'Vardorvis',
|
||||||
venenatis: 'Venenatis',
|
venenatis: 'Venenatis',
|
||||||
vetion: "Vet'ion",
|
vetion: "Vet'ion",
|
||||||
vorkath: 'Vorkath',
|
vorkath: 'Vorkath',
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import axios from 'axios';
|
import axios, { AxiosRequestConfig } from 'axios';
|
||||||
import * as ua from 'useragent-generator';
|
import * as ua from 'useragent-generator';
|
||||||
import { Gamemode, SkillName, ActivityName } from '../types';
|
import { Gamemode, SkillName, ActivityName } from '../types';
|
||||||
import {
|
import {
|
||||||
@@ -96,12 +96,16 @@ export const rsnFromElement = (el: Element | null) => {
|
|||||||
* @param url URL to run a `GET` request against.
|
* @param url URL to run a `GET` request against.
|
||||||
* @returns Axios response.
|
* @returns Axios response.
|
||||||
*/
|
*/
|
||||||
export const httpGet = <Response>(url: string) =>
|
export const httpGet = <Response>(
|
||||||
|
url: string,
|
||||||
|
config: AxiosRequestConfig = {}
|
||||||
|
) =>
|
||||||
axios.get<Response>(url, {
|
axios.get<Response>(url, {
|
||||||
headers: {
|
headers: {
|
||||||
// without User-Agent header requests may be rejected by DDoS protection mechanism
|
// without User-Agent header requests may be rejected by DDoS protection mechanism
|
||||||
'User-Agent': ua.firefox(80)
|
'User-Agent': ua.firefox(80)
|
||||||
}
|
},
|
||||||
|
...config
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user