diff --git a/src/pages/impl/player-page.ts b/src/pages/impl/player-page.ts index 0ef0e32..b3b015f 100644 --- a/src/pages/impl/player-page.ts +++ b/src/pages/impl/player-page.ts @@ -8,22 +8,19 @@ export default class PlayerPage extends Page { } public async onLoad() { - let loadingElement; - let titleElement; + const id: string = getPlayerIdFromUrl(); // Get the player's ID from the URL + // Wait for the title element to load, so we know the page is fully loaded + const titleElement = await getElement( + ".title.is-5.player.has-text-centered-mobile", + ); + const removeLoadingElements = await this.addLoadingElement(titleElement); try { - // Wait for the title element to load, so we know the page is fully loaded - titleElement = await getElement( - ".title.is-5.player.has-text-centered-mobile", - ); - const id: string = getPlayerIdFromUrl(); - - loadingElement = await this.addLoadingElement(titleElement); const player: any = await getPlayer(id); - loadingElement(); // Remove the loading element + removeLoadingElements(); // Remove the loading elements await this.addStats(player); // Add our custom stats } catch (error) { - loadingElement(); // Remove the loading element + removeLoadingElements(); // Remove the loading elements if (error.message.includes("inactive")) { await this.addLoadingElement(