@@ -31,6 +31,9 @@ function extractGameIdFromUrl(url) {
3131// Statuses that indicate a game doesn't need to be claimed
3232const DONE_STATUSES = [ 'claimed' , 'existed' , 'manual' , 'unavailable-in-region' ] ;
3333
34+ // Statuses that indicate we should skip during GamerPower pre-check (but still retry gp-unavailable-in-region)
35+ const GP_DONE_STATUSES = [ 'claimed' , 'existed' , 'manual' ] ;
36+
3437function isGpGameAlreadyClaimed ( storeUrl ) {
3538 const username = getUsername ( PLATFORM , cfg . eg_email ) ;
3639 if ( ! username ) return false ; // Username not known yet
@@ -39,7 +42,7 @@ function isGpGameAlreadyClaimed(storeUrl) {
3942 const games = db . data [ username ] ;
4043 const status = games ?. [ game_id ] ?. status ;
4144
42- if ( status && DONE_STATUSES . includes ( status ) ) {
45+ if ( status && GP_DONE_STATUSES . includes ( status ) ) {
4346 console . log ( `[GamerPower] Already claimed by ${ username } : ${ storeUrl } -> ${ game_id } (${ status } )` ) ;
4447 return true ;
4548 }
@@ -236,13 +239,31 @@ try {
236239
237240 // GamerPower games - verify they are included in the free games list
238241 if ( cfg . eg_check_gp && gpUrls . length > 0 ) {
239- console . log ( `Verifying ${ gpUrls . length } GamerPower giveaways are in Epic's free games list ...` ) ;
242+ console . log ( `Verifying ${ gpUrls . length } GamerPower giveaways...` ) ;
240243 for ( const gpUrl of gpUrls ) {
241244 // Normalize URLs for comparison (remove trailing slashes, query params)
242245 const gpUrlNormalized = gpUrl . split ( '?' ) [ 0 ] . replace ( / \/ $ / , '' ) ;
243246 const found = urls . some ( url => url . split ( '?' ) [ 0 ] . replace ( / \/ $ / , '' ) === gpUrlNormalized ) ;
244247 if ( ! found ) {
245- throw new Error ( `[GamerPower] ${ gpUrl } is NOT in Epic's free games list! Epic's free games: ${ urls . join ( ', ' ) } ` ) ;
248+ // Not in Epic's free games list - check if it's region/platform blocked
249+ console . log ( `[GamerPower] ${ gpUrl } is NOT in Epic's free games list, checking availability...` ) ;
250+ await page . goto ( gpUrl , { waitUntil : 'domcontentloaded' } ) ;
251+
252+ // Check for "unavailable in your platform or region" warning
253+ const unavailableWarning = page . locator ( '[data-testid="WarningLayout"] h1:has-text("unavailable")' ) ;
254+ if ( await unavailableWarning . count ( ) > 0 ) {
255+ const warningText = await unavailableWarning . innerText ( ) ;
256+ console . warn ( `[GamerPower] WARNING: ${ gpUrl } - ${ warningText } ` ) ;
257+ // Mark as unavailable in db so we track it, but don't fail
258+ const gpGameId = gpUrl . split ( '/' ) . pop ( ) ;
259+ db . data [ user ] [ gpGameId ] ||= { title : gpGameId , time : datetime ( ) , url : gpUrl } ;
260+ db . data [ user ] [ gpGameId ] . status = 'gp-unavailable-in-region' ;
261+ continue ; // Skip this game but continue with others
262+ }
263+
264+ // If no warning found, add it to the urls list to attempt claiming
265+ console . log ( `[GamerPower] Adding ${ gpUrl } to claim list (not in Epic's free games list but available)` ) ;
266+ urls . push ( gpUrl ) ;
246267 } else {
247268 console . log ( `[GamerPower] OK: ${ gpUrl } ` ) ;
248269 }
0 commit comments