Note
This document was written by Gemini and may contain errors.
hiroba-js is a TypeScript library for scraping data from the website donderhiroba.jp. It aims to provide programmatic access to player data by making HTTP requests and parsing the resulting HTML.
npm install hiroba-jsThe DonderHiroba class is the core of the library, managing interactions with donderhiroba.jp. An instance of this class represents a logged-in user's session and provides various methods for fetching and managing their data.
A DonderHiroba instance holds the state of a logged-in user, including their session token and cached data. It provides methods to interact with the website on behalf of the user.
-
token?: string: The session token for the logged-in user. This token is required to make authenticated requests to the website. -
namcoLogined: boolean: A boolean value that indicates whether the user is logged into their Namco ID. This is set totrueafter a successful login. -
cardLogined: boolean: A boolean value that indicates whether the user is logged into a specific Taiko card. This is set totrueafter a successful card login. -
currentLogin: CardData | null: An object containing the data of the currently logged-in card. It isnullif no card is logged in. -
cardList: CardData[]: An array ofCardDataobjects, representing the user's Taiko cards. -
clearData: Map<string, ClearData>: AMapobject that stores the clear data for each song. The key is the song number (string), and the value is aClearDataobject. -
scoreData: Map<string, ScoreData>: AMapobject that stores the score data for each song. The key is the song number (string), and the value is aScoreDataobject. -
ticket: string | null: A string value that is required for certain actions, such as changing the nickname. It isnullif no ticket has been fetched.
-
constructor(token?: string): Creates a newDonderHirobainstance.token(string, optional): A session token can be provided to initialize the instance with a specific login session.
-
checkNamcoLogined(): Promise<boolean>: Checks if the user is logged into their Namco ID. This will log the user out of their card.- Returns: A
Promisethat resolves withtrueif the user is logged in, andfalseotherwise.
- Returns: A
-
checkCardLogined(): Promise<boolean>: Checks if the user is logged into a specific Taiko card. This may log the user out of their Namco ID.- Returns: A
Promisethat resolves withtrueif the user is logged in, andfalseotherwise.
- Returns: A
-
reloadCardList(): Promise<void>: Reloads the list of the user's Taiko cards. -
cardLogin(taikoNumber: string): Promise<void>: Logs into a specific Taiko card.taikoNumber(string): The Taiko number of the card to log in with.
-
updateClearData(genre?: keyof typeof Const.genre): Promise<Record<string, ClearData>>: Updates the clear data for a specific genre and returns the updated data.genre(keyof typeof Const.genre, optional): The genre to update the clear data for. If not provided, all genres will be updated.- Returns: A
Promisethat resolves with aRecordobject containing the updated clear data, with the song number as the key.
-
updateScoreData(songNo: string, difficulty?: Difficulty): Promise<ScoreData | null>: Updates the score data for a specific song and difficulty and returns the updated data.songNo(string): The song number to update the score data for.difficulty(Difficulty, optional): The difficulty to update the score data for. If not provided, all difficulties will be updated.- Returns: A
Promisethat resolves with the updatedScoreDataobject, ornullif the song was not found.
-
updateRecord(): Promise<void>: Refreshes the song score data. -
changeName(newName: string): Promise<CardData | null>: Changes the user's nickname.newName(string): The new nickname.- Returns: A
Promisethat resolves with the updatedCardDataobject, ornullif the nickname change failed.
-
getTicket(): Promise<string | null>: Fetches a ticket value required for certain actions.- Returns: A
Promisethat resolves with the ticket value, ornullif the ticket could not be fetched.
- Returns: A
The DonderHiroba class provides several static namespaces and methods that can be called directly without creating an instance. These static members are primarily used for fetching HTML from specific pages (request), parsing that HTML (parse), or combining multiple requests and parsing steps to perform a specific function (func).
This static method of the DonderHiroba class logs into donderhiroba.jp using an email and password, creates a DonderHiroba instance, and returns it. If a taikoNumber is provided, it will also perform a card login for that Taiko number.
- Arguments:
options(object):email(string): The email address registered ondonderhiroba.jp.password(string): The password registered ondonderhiroba.jp.taikoNumber(string, optional): The Taiko number to log in with.
- Returns:
Promise<DonderHiroba>: APromisethat resolves with a logged-in instance of theDonderHirobaclass.
The DonderHiroba.func namespace is an object containing high-level functions that combine functions from request and parse to perform specific tasks. For example, the getCardList function fetches the HTML with request.cardList and then parses it with parse.cardList to return the final result.
- Key Methods:
getSessionToken(credentials: { email: string, password: string }): Promise<string>: Logs in with an email and password to get a session token.getCardList(data?: { token?: string }): Promise<CardData[]>: Fetches the list of cards registered to the account.cardLogin(data: { token?: string, taikoNumber: string, cardList?: CardData[] }): Promise<CardData>: Logs in with a specific Taiko number.getClearData(data?: { token?: string, genre?: keyof typeof Const.genre }): Promise<ClearData[]>: Fetches the clear data.getScoreData(data: { token?: string, songNo: string, difficulty?: Difficulty }): Promise<ScoreData | null>: Fetches the score data for a song.getDaniData(data?: { token?: string, daniNo?: number }): Promise<DaniData | DaniData[] | null>: Fetches the Dan-i Dojo play data.getCompeDetail(data: { token?: string, compeId: string }): Promise<CompeDetail | null>: Fetches the details of a competition.getCompeRanking(data: { token?: string, compeId: string }): Promise<RankingData[] | null>: Fetches the ranking data for a competition.getCompeData(data: { token?: string, compeId: string }): Promise<CompeData | null>: Fetches both the details and ranking data for a competition.getCurrentLogin(data?: { token?: string }): Promise<CardData | null>: Fetches the data of the currently logged-in card.updateRecord(data: { token?: string }): Promise<void>: Refreshes the song score data.changeName(data: { token?: string, ticket: string, newName: string }): Promise<void>: Changes the nickname.getTicket(data?: { token?: string }): Promise<string | null>: Fetches theticketvalue required for changing the nickname.
The DonderHiroba.request namespace is an object containing functions that send HTTP requests to specific pages on donderhiroba.jp and return the resulting HTML string. Most of these functions accept a token argument to maintain the login state.
- Key Methods:
cardList(data?: { token?: string }): Promise<string>: Fetches the HTML of the card selection page.clearData(data?: { token?: string, genre?: keyof typeof Const.genre }): Promise<string | string[]>: Fetches the HTML of the clear data page.scoreData(data: { token?: string, songNo: string, difficulty?: Difficulty }): Promise<string | string[]>: Fetches the HTML of the score data page.daniData(data?: { token?: string, daniNo?: number }): Promise<string | string[]>: Fetches the HTML of the Dan-i Dojo data page.compeDetail(data: { token?: string, compeId: string }): Promise<string>: Fetches the HTML of the competition details page.compeRanking(data: { token?: string, compeId: string }): Promise<string>: Fetches the HTML of the competition ranking page.currentLogin(data?: { token?: string }): Promise<string>: Fetches the HTML of the main page to get the currently logged-in card information.ticket(data?: { token?: string }): Promise<string>: Fetches the HTML of the My Page.
The DonderHiroba.parse namespace is an object containing functions that parse the HTML strings obtained through DonderHiroba.request and convert them into meaningful data structures (objects or arrays).
- Key Methods:
cardList(html: string): CardData[]: Parses the card list HTML and returns an array ofCardDataobjects.clearData(html: string | string[]): ClearData[]: Parses the clear data HTML and returns an array ofClearDataobjects.scoreData(data: { html: string | string[], songNo: string }): ScoreData | null: Parses the score data HTML and returns aScoreDataobject.daniData(data: { html: string, daniNo: number } | { html: string, daniNo: number }[]): DaniData | DaniData[] | null: Parses the Dan-i Dojo data HTML and returns aDaniDataobject or an array of objects.compeDetail(html: string): CompeDetail | null: Parses the competition details HTML and returns aCompeDetailobject.compeRanking(html: string): RankingData[] | null: Parses the competition ranking HTML and returns an array ofRankingDataobjects.currentLogin(html: string): CardData | null: Parses the main page HTML and returns the currently logged-inCardDataobject.ticket(html: string): string | null: Parses theticketvalue from the My Page HTML.