From 5a89721fd83f0d91ebc47eb4d56c407e391f8f80 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Sun, 28 Sep 2025 20:04:45 -0300 Subject: [PATCH] Use regex in server.all to match all routes Remove request interception from KBService Drop request interception to simplify navigation. Add a page.evaluate to strip images, scripts, and stylesheets. --- packages/kb.gbapp/services/KBService.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/packages/kb.gbapp/services/KBService.ts b/packages/kb.gbapp/services/KBService.ts index 46e9b34c..9bee91b5 100644 --- a/packages/kb.gbapp/services/KBService.ts +++ b/packages/kb.gbapp/services/KBService.ts @@ -1691,19 +1691,6 @@ export class KBService implements IGBKBService { const fileName = `${flatLastPath}.html`; const filePath = path.join(directoryPath, fileName); - // Configure request interception before navigation - await page.setRequestInterception(true); - page.on('request', request => { - if (request.resourceType() === 'document') { - request.continue().catch(() => { - // Ignore errors from requests that were already handled - }); - } else { - request.abort().catch(() => { - // Ignore errors from requests that were already handled - }); - } - }); // Navigate with strict timeout and wait for content // Navigate and get content even if page fails to load fully @@ -1717,6 +1704,12 @@ export class KBService implements IGBKBService { // Ignore timeout/navigation errors } + await page.evaluate(() => { + // Remove images, scripts, stylesheets, etc. + const elements = document.querySelectorAll('img, script, link[rel="stylesheet"]'); + elements.forEach(el => el.remove()); + }); + // Get whatever HTML content was loaded const htmlContent = await page.content();