Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
feat: Return game instance when it's ready
Browse files Browse the repository at this point in the history
  • Loading branch information
oliversalzburg committed Jul 17, 2021
1 parent f1f8c04 commit 3701d16
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/userscript/source/UserScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,15 @@ export class UserScript {
this.resetActivitySummary();
}

static async waitForGame(timeout = 30000): Promise<void> {
static async waitForGame(timeout = 30000): Promise<GamePage> {
cdebug(`Waiting for game... (timeout: ${Math.round(timeout / 1000)}s)`);

if (timeout < 0) {
throw new Error("Unable to find game page.");
}

if (UserScript._isGameLoaded()) {
return;
return mustExist(UserScript._window.gamePage);
}

await sleep(2000);
Expand Down

0 comments on commit 3701d16

Please sign in to comment.