From 02c176521497c81d7711385c6c1b743eca430549 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Fri, 4 Sep 2026 15:43:11 +0200 Subject: [PATCH] =?UTF-8?q?F=C3=BCge=20Unterst=C3=BCtzung=20f=C3=BCr=20das?= =?UTF-8?q?=20Akzeptieren=20von=20Cookie-Zustimmungen=20hinzu:=20Implement?= =?UTF-8?q?iere=20eine=20Funktion,=20die=20verschiedene=20Consent-Dialoge?= =?UTF-8?q?=20automatisch=20akzeptiert.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/utils/mytischtennis-client.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/server/utils/mytischtennis-client.js b/server/utils/mytischtennis-client.js index 34626cd..861f337 100644 --- a/server/utils/mytischtennis-client.js +++ b/server/utils/mytischtennis-client.js @@ -34,13 +34,29 @@ async function loginDirect(email, password) { } async function loginWithBrowser(email, password) { - const browser = await chromium.launch({ headless: true }) + const browser = await chromium.launch({ headless: true, args: ['--disable-dev-shm-usage'] }) try { const page = await browser.newPage() // Das myTT-CAPTCHA wird erst nach dem Laden der Seite erzeugt. Der Ablauf // entspricht der erprobten Integration im Trainingstagebuch. + const acceptConsentDialog = async (waitMs = 0) => { + if (waitMs) await page.waitForTimeout(waitMs) + for (const selector of [ + '#onetrust-accept-btn-handler', 'button:has-text("Alle akzeptieren")', + 'button:has-text("Akzeptieren")', 'button:has-text("Einverstanden")', + 'button:has-text("Zustimmen")', '[data-testid="accept-button"]', '.cmp-accept-all', '.accept-all-btn' + ]) { + try { + const button = page.locator(selector).first() + if (await button.count()) { await button.click({ timeout: 2_500 }); await page.waitForTimeout(800); return true } + } catch { /* try next CMP selector */ } + } + return false + } await page.goto(BASE_URL, { waitUntil: 'domcontentloaded', timeout: 30_000 }).catch(() => {}) + if (!await acceptConsentDialog()) await acceptConsentDialog(2_500) await page.goto(`${BASE_URL}/login?next=%2F`, { waitUntil: 'domcontentloaded', timeout: 45_000 }) + if (!await acceptConsentDialog()) await acceptConsentDialog(1_500) await page.locator('input[name="email"]').fill(email) await page.locator('input[name="password"]').fill(password)