From 4055ec44c7aa05918a4d96a236be7767d344c31f Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Thu, 19 Jan 2023 01:26:27 +0100 Subject: [PATCH] fix for #46: "This product is currently unavailable in your region" --- epic-games.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/epic-games.js b/epic-games.js index c52095e..27624af 100644 --- a/epic-games.js +++ b/epic-games.js @@ -145,7 +145,13 @@ try { // it then creates an iframe for the purchase await page.waitForSelector('#webPurchaseContainer iframe'); // TODO needed? const iframe = page.frameLocator('#webPurchaseContainer iframe'); - await iframe.locator('button:has-text("Place Order")').click(); + if (await Promise.any([ + iframe.locator('button:has-text("Place Order")').click(), + iframe.locator(':has-text("unavailable in your region")').waitFor().then(_ => 'unavailable'), + ]) == 'unavailable') { // can't continue loop from the promise + console.error(' This product is unavailable in your region!'); + continue; + }; // I Agree button is only shown for EU accounts! https://github.com/vogler/free-games-claimer/pull/7#issuecomment-1038964872 const btnAgree = iframe.locator('button:has-text("I Agree")');