From cc527a3a3335c29bce38cf8c23bb097a4f51c7e6 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Sun, 29 Sep 2024 11:27:07 +0200 Subject: [PATCH] Correct async calls to init scrapers --- public/script.js | 2 +- public/scripts/scrapers.js | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/public/script.js b/public/script.js index b0ca08f6a..b64104cc5 100644 --- a/public/script.js +++ b/public/script.js @@ -959,7 +959,7 @@ async function firstLoadInit() { initCfg(); initLogprobs(); initInputMarkdown(); - initScrapers(); + await initScrapers(); doDailyExtensionUpdatesCheck(); await hideLoader(); await fixViewport(); diff --git a/public/scripts/scrapers.js b/public/scripts/scrapers.js index 09d42edb1..5a21dedd0 100644 --- a/public/scripts/scrapers.js +++ b/public/scripts/scrapers.js @@ -37,14 +37,14 @@ export class ScraperManager { * Register a scraper to be used by the Data Bank. * @param {Scraper} scraper Instance of a scraper to register */ - static registerDataBankScraper(scraper) { + static async registerDataBankScraper(scraper) { if (ScraperManager.#scrapers.some(s => s.id === scraper.id)) { console.warn(`Scraper with ID ${scraper.id} already registered`); return; } if (scraper.init) { - scraper.init(); + await scraper.init(); } ScraperManager.#scrapers.push(scraper); @@ -571,11 +571,11 @@ class YouTubeScraper { } } -export function initScrapers() { - ScraperManager.registerDataBankScraper(new FileScraper()); - ScraperManager.registerDataBankScraper(new Notepad()); - ScraperManager.registerDataBankScraper(new WebScraper()); - ScraperManager.registerDataBankScraper(new MediaWikiScraper()); - ScraperManager.registerDataBankScraper(new FandomScraper()); - ScraperManager.registerDataBankScraper(new YouTubeScraper()); +export async function initScrapers() { + await ScraperManager.registerDataBankScraper(new FileScraper()); + await ScraperManager.registerDataBankScraper(new Notepad()); + await ScraperManager.registerDataBankScraper(new WebScraper()); + await ScraperManager.registerDataBankScraper(new MediaWikiScraper()); + await ScraperManager.registerDataBankScraper(new FandomScraper()); + await ScraperManager.registerDataBankScraper(new YouTubeScraper()); }