vogler / free-games-claimer

Automatically claims free games on the Epic Games Store, Amazon Prime Gaming and GOG.
GNU Affero General Public License v3.0
2.49k stars 151 forks source link

Epic not clicking "Place Order" button #84

Closed permster closed 1 year ago

permster commented 1 year ago

As the title states, it gets stuck waiting on the place order window. The log stops here when waiting:

2023-03-02 23:28:18.692 started checking epic-games
Signed in as <epic_username>
Free games: [ 'https://store.epicgames.com/en-US/p/rise-of-industry-0af838' ]
Current free game: Rise of Industry
  Not in library yet! Click GET.

Then it finally times out with the following:

[AggregateError: All promises were rejected] {
  [errors]: [
    locator.click: Timeout 100000ms exceeded.
    =========================== logs ===========================
    waiting for frameLocator('#webPurchaseContainer iframe').locator('button:has-text("I Agree")')
    ============================================================
        at file:///fgc/epic-games.js:159:37 {
      name: 'TimeoutError'
    },
    page.waitForSelector: Timeout 100000ms exceeded.
    =========================== logs ===========================
    waiting for locator('text=Thank you for buying') to be visible
    ============================================================
        at file:///fgc/epic-games.js:159:51 {
      name: 'TimeoutError'
    }
  ]
}

This might be related to #75 but it looks slightly different and when I connect novnc it still doesn't work. I can see it just sit there at the place order screen until it times out.

Tried it multiple times and finally after 4 times of checking novnc it was able to click place order.

ALERTua commented 1 year ago

I have the same issue

xBlackPoison357x commented 1 year ago

same issue

vogler commented 1 year ago

Same fix as for #75.

xBlackPoison357x commented 1 year ago

Same fix as for #75.

I downloaded the above fix and this issue is still present for me.

vogler commented 1 year ago

@xBlackPoison357x Mh, I ran it and it claimed the game for me, so I can't test it again. Need some details: docker or native (headless?), logs, EU account?, did it claim the game? (noticed text at the end is just 'Thank you'). To make sure it's the same issue, put in await page.pause(); after https://github.com/vogler/free-games-claimer/blob/07ce17f8e3d42869a7798cde81bb0e8f443f329c/epic-games.js#L154 run it (not headless) and see what happens (click should work, then pause).

xBlackPoison357x commented 1 year ago

I'm using native, US account. It didn't claim the game, attached is the error I'm getting and the screenshot. Adding await page.pause(); did not fix it.

rise-of-industry-0af838_2023-03-07 09 05 27 092 error

vogler commented 1 year ago

Adding await page.pause(); did not fix it.

It was supposed to open the Playwright inspector and pause after the click. Yours did not. Are you running the correct code?

xBlackPoison357x commented 1 year ago

Yes, it did but didn't click. I recorded it from the time I started it until it timed out: https://youtu.be/hcAYSrzUBI0

vogler commented 1 year ago

Ok, that's how it was for me without the delay. Try increasing it, maybe to 155. Don't need to click continue - if the click does not work, the rest will timeout/fail anyway.

xBlackPoison357x commented 1 year ago

I increased it to 155 and it gets stuck at the same point.

vogler commented 1 year ago

Hard to say then. I guess you have to play around a bit to see what's the issue. Try adding await page.waitForTimeout(2000); before the click (it may be that it clicks before an event handler is attached). Does it work if you step through it with PWDEBUG=1?

xBlackPoison357x commented 1 year ago

await page.waitForTimeout(2000); did not work but when I did PWDEBUG=1 it went thru til a captcha, believe I've been trying to to many times. Going to try later when I don't hit a captcha but I believe PWDEBUG worked.

vogler commented 1 year ago

Captcha only comes after 'Place Order', so it likely worked, the question is what's different. If you're stepping through the code with PWDEBUG, there are many delays between the steps. Could be those. Did you move the mouse over the browser window?

xBlackPoison357x commented 1 year ago

I ran it again with the page.waitfortimeout(2000) and only SHOW=1 and had my mouse over the browser and it worked. In 2 days when the next free game drops I'm going to retest without SHOW=1 and just page.waitfortimeout(2000) and see if it works.

vogler commented 1 year ago

image Just tried it again with a different account and it also worked without any changes besides the fix from two days ago.

xBlackPoison357x commented 1 year ago

I'm not sure what it is then. I switched to the docker version and I'm still getting stuck at the same part.

ich777 commented 1 year ago

New install here in Docker on Unraid, same over here.

vogler commented 1 year ago

No problems with Docker here either: image

Are you really running the latest code? Do you have some log? What's the host OS & arch? How long does it run in total? @xBlackPoison357x you said it worked before without docker - also without your changes?

xBlackPoison357x commented 1 year ago

Without docker I only had it work once when I had my mouse over the browser and page.waitfortimeout(2000). It never worked for me without modifying. Below is from when I ran it in docker. freegame

EthanC commented 1 year ago

I'm experiencing this issue as well with the latest Docker image. I've set FGC to run every hour and it fails each time.

Image Hash

voglerr/free-games-claimer:latest@sha256:df30563e88a7e6343cce9b056e48dd3bd648460b7e9694155a5b9ebe08af7cec

Logs

2023-03-09 21:40:48.692 started checking epic-games
Signed in as Ethan
Free games: [ 'https://store.epicgames.com/en-US/p/call-of-the-sea' ]
Current free game: Call of the Sea
  Not in library yet! Click GET.
[AggregateError: All promises were rejected] {
  [errors]: [
    locator.click: Timeout 60000ms exceeded.
    =========================== logs ===========================
    waiting for frameLocator('#webPurchaseContainer iframe').locator('button:has-text("I Agree")')
    ============================================================
        at file:///fgc/epic-games.js:168:37 {
      name: 'TimeoutError'
    },
    page.waitForSelector: Timeout 60000ms exceeded.
    =========================== logs ===========================
    waiting for locator('text=Thank you for buying') to be visible
    ============================================================
        at file:///fgc/epic-games.js:168:51 {
      name: 'TimeoutError'
    }
  ]
}
  Failed to claim! To avoid captchas try to get a new IP address.

Video

https://user-images.githubusercontent.com/16727756/224168079-eab9ac50-e588-4dc2-ba9e-7e67feeea045.mp4

Docker Compose

version: "3"
services:
  free-games-claimer:
    container_name: free-games-claimer
    image: voglerr/free-games-claimer:latest
    environment:
      WIDTH: 1280
      HEIGHT: 720
      NOTIFY: discord://XXXXXXXXXX
      EMAIL: XXXXXXXXXX
      EG_PASSWORD: XXXXXXXXXX
      EG_OTPKEY: XXXXXXXXXX
      PG_PASSWORD: XXXXXXXXXX
      PG_OTPKEY: XXXXXXXXXX
      GOG_PASSWORD: XXXXXXXXXX
    ports:
      - 5900:5900
      - 6080:6080
    volumes:
      - /home/ethan/free-games-claimer:/fgc/data
vogler commented 1 year ago

Image Hash

voglerr/free-games-claimer:latest@sha256:df30563e88a7e6343cce9b056e48dd3bd648460b7e9694155a5b9ebe08af7cec

Can't find that hash. image

Why don't you use ghcr.io/vogler/free-games-claimer like in the Readme? https://github.com/vogler/free-games-claimer/pkgs/container/free-games-claimer/versions shows all the images with hash - also can't find yours there.

vogler commented 1 year ago

Below is from when I ran it in docker.

@xBlackPoison357x Ok, so no difference for you whether docker or not. Can you check what exactly is needed for you to make it work without interaction? Is adding await page.waitForTimeout(2000); enough? I can't check since it works for me as is.

@EthanC do you also have a non-EU account?

The problem is that you need to check the browser to see if the 'Place Order' click worked (or if it's some other issue), but shouldn't interact with it (also not move the mouse over it) to find out what makes it work without interaction.

vogler commented 1 year ago

Just noticed that it will likely not complain if a captcha is shown for non-EU accounts since it will block here before: https://github.com/vogler/free-games-claimer/blob/0cfb9d29aa686d6dcc9b8179258ff4647af0e782/epic-games.js#L168

So make sure that the issue is not that you get challenged with a captcha after trying too often.

I'll fix the code to also detect captchas for non-EU accounts later.

EthanC commented 1 year ago

I've just switched to the ghcr.io/vogler/free-games-claimer image. Running docker images --digests reports a hash that matches the one seen in your screenshot above. I'm also using Watchtower to check for a new image every hour.

ghcr.io/vogler/free-games-claimer   latest    sha256:20195e7fedccff31ada39a694c522ce3bc3d4a2a139f2af2041697e34f0df049   df30563e88a7   8 hours ago     972MB

I'm on a North American account, yes. In my video above, I did not interact with the browser in any way.

xBlackPoison357x commented 1 year ago

Just tested my non docker again with await page.waitForTimeout(2000); before the click but this time without having a browser and not moving my mouse over it and it worked.

vogler commented 1 year ago

I added await page.waitForTimeout(2000); before 'Place Order'. Let me know if that's still not working for someone.

Assumption to verify: it takes some time for the click event handler to attach. For me the 11ms click delay are enough, for others not. Playwright has some actionability checks which apparently are not enough, so ideally wait until event handler is attached instead of the 2s waiting hack.

DuzAwe commented 1 year ago

Still not working for me, EU account. Running once a week.

2023-03-09 22:39:43.920 started checking epic-games
Signed in as xxxx
Free games: [ 'https://store.epicgames.com/en-US/p/call-of-the-sea' ]
Current free game: Call of the Sea
  Not in library yet! Click GET.
[AggregateError: All promises were rejected] {
  [errors]: [
    locator.click: Timeout 60000ms exceeded.
    =========================== logs ===========================
    waiting for frameLocator('#webPurchaseContainer iframe').locator('button:has-text("I Agree")')
    ============================================================
        at file:///fgc/epic-games.js:160:37 {
      name: 'TimeoutError'
    },
    page.waitForSelector: Timeout 60000ms exceeded.
    =========================== logs ===========================
    waiting for locator('text=Thank you for buying') to be visible
    ============================================================
        at file:///fgc/epic-games.js:160:51 {
      name: 'TimeoutError'
    }
  ]
}
vogler commented 1 year ago

@DuzAwe to debug:

  1. Make sure you have the new version that waits for 2s before the click.
  2. Check in the browser if the click on 'Place Order' is really the issue.
  3. If so, provide some details on how you run it. Does it work with a higher timeout (e.g. 10s)?
DuzAwe commented 1 year ago

Afraid I have claimed it, so I will have to update when the next game goes up. In the browser, nothing happened just sat on the epic store until it timed out. I am using the Unraid Template, with the defaults. edit Appreciate the work and app.

  Failed to claim! To avoid captchas try to get a new IP address.
Not signed in anymore.
  Failed to claim! To avoid captchas try to get a new IP address.
  Failed to claim! To avoid captchas try to get a new IP address.
    page.waitForSelector: Timeout 60000ms exceeded.
    =========================== logs ===========================
    waiting for locator('text=Thank you for buying') to be visible
    ============================================================
        at file:///fgc/epic-games.js:160:51 {
      name: 'TimeoutError'
    }
  ]
}
2023-03-09 20:03:30.291 started checking gog
Login timeout is 180 seconds!
Using email and password from environment.
Signed in as 'XXX'
Currently no free giveaway!
Xvfb display server created screen with resolution 1280x1280
VNC is running on port 5900 (no password!)
noVNC (VNC via browser) is running on http://localhost:6080

2023-03-09 22:39:43.920 started checking epic-games
Signed in as XXX
Free games: [ 'https://store.epicgames.com/en-US/p/call-of-the-sea' ]
Current free game: Call of the Sea
  Not in library yet! Click GET.
[AggregateError: All promises were rejected] {
  [errors]: [
    locator.click: Timeout 60000ms exceeded.
    =========================== logs ===========================
    waiting for frameLocator('#webPurchaseContainer iframe').locator('button:has-text("I Agree")')
    ============================================================
        at file:///fgc/epic-games.js:160:37 {
      name: 'TimeoutError'
    },
    page.waitForSelector: Timeout 60000ms exceeded.
    =========================== logs ===========================
    waiting for locator('text=Thank you for buying') to be visible
    ============================================================
        at file:///fgc/epic-games.js:160:51 {
      name: 'TimeoutError'
    }
  ]
}
2023-03-09 22:41:12.592 started checking gog
Signed in as 'XXX'
Currently no free giveaway!
Xvfb display server created screen with resolution 1280x1280
VNC is running on port 5900 (no password!)
noVNC (VNC via browser) is running on http://localhost:6080

2023-03-10 12:03:17.398 started checking epic-games
Signed in as XXX
Free games: [ 'https://store.epicgames.com/en-US/p/call-of-the-sea' ]
Current free game: Call of the Sea
  Not in library yet! Click GET.
[AggregateError: All promises were rejected] {
  [errors]: [
    locator.click: Timeout 60000ms exceeded.
    =========================== logs ===========================
    waiting for frameLocator('#webPurchaseContainer iframe').locator('button:has-text("I Agree")')
    ============================================================
        at file:///fgc/epic-games.js:160:37 {
      name: 'TimeoutError'
    },
    page.waitForSelector: Timeout 60000ms exceeded.
    =========================== logs ===========================
    waiting for locator('text=Thank you for buying') to be visible
    ============================================================
        at file:///fgc/epic-games.js:160:51 {
      name: 'TimeoutError'
    }
  ]
}
2023-03-10 12:04:47.721 started checking gog
Signed in as 'XXX'
Currently no free giveaway!
Xvfb display server created screen with resolution 1280x1280
VNC is running on port 5900 (no password!)
noVNC (VNC via browser) is running on http://localhost:6080

2023-03-10 12:07:30.573 started checking epic-games
Signed in as XXX
Free games: [ 'https://store.epicgames.com/en-US/p/call-of-the-sea' ]
Current free game: Call of the Sea
  Already in library! Nothing to claim.
2023-03-10 12:08:19.401 started checking gog
Signed in as 'XXX'
Currently no free giveaway!
vogler commented 1 year ago

Afraid I have claimed it

Manually?

What version of the image were you running?

I am using the Unraid Template, with the defaults.

I think that doesn't update the image before every run. @Nackophilz

DuzAwe commented 1 year ago

Aye manually, inside the vnc session. I am unsure of the image version, there are issues with how unraid updates that won't be fixed until the next version. I updated it last night.

Nackophilz commented 1 year ago

Indeed, the default setting of Unraid, does not update before each RUN, it is the way it works. On my side it works very well for all my containers (even if there is a lot of update)

@DuzAwe what update problem are you talking about? Oo Unraid does notify the update periodicall (once per day ? i dont remember the periodicity) , or if you search manually, and it constantly points to the latest version of the package released by Ralf... ^^

You can even auto update you're container apps with a plugin available on unraid

There is no problem with how unraid update docker app, or i dont see it on the unraid forum/issue/discord

DuzAwe commented 1 year ago

https://forums.unraid.net/topic/94946-docker-version-not-available/ Even with the "fix" installed, there are still issues. There are messages in the discord about github not polling correctly for updates. Limetech has said there will be no more patches for 6.11 and it will be addressed in 6.12 The unraid template has --pull=always set but it does not always work.

Nackophilz commented 1 year ago

I dont have any problem with my docker update on my side ...

I think you have a problem with your server specifically, if the --pull=always set dont always work, you have a problem ^^

vogler commented 1 year ago

I'll fix the code to also detect captchas for non-EU accounts later.

Should be fixed now.

DuzAwe commented 1 year ago

Still dying here.

docker pull ghcr.io/vogler/free-games-claimer
Using default tag: latest
latest: Pulling from vogler/free-games-claimer
Digest: sha256:76b8bde4587d93811110cb621853b613339f2b330453b152b747bb2f186096a8
Status: Image is up to date for ghcr.io/vogler/free-games-claimer:latest
ghcr.io/vogler/free-games-claimer:latest
Xvfb display server created screen with resolution 1280x1280
VNC is running on port 5900 (no password!)
noVNC (VNC via browser) is running on http://localhost:6080

2023-03-16 15:41:43.484 started checking epic-games
Signed in as xxx
Free games: [
  'https://store.epicgames.com/en-US/p/warhammer-40000-gladius-relics-of-war'
]
Current free game: Warhammer 40,000: Gladius - Relics of War
  Not in library yet! Click GET.
[AggregateError: All promises were rejected] {
  [errors]: [
    locator.click: Timeout 60000ms exceeded.
    =========================== logs ===========================
    waiting for frameLocator('#webPurchaseContainer iframe').locator('button:has-text("I Agree")')
    ============================================================
        at file:///fgc/epic-games.js:169:37 {
      name: 'TimeoutError'
    },
    page.waitForSelector: Timeout 60000ms exceeded.
    =========================== logs ===========================
    waiting for locator('text=Thank you for buying') to be visible
    ============================================================
        at file:///fgc/epic-games.js:169:51 {
      name: 'TimeoutError'
    }
  ]
}
2023-03-16 15:42:59.840 started checking gog
Signed in as 'xxx'
Currently no free giveaway!
vogler commented 1 year ago

Still dying here.

@DuzAwe You pulled the new image but are somehow still running old code (there's no more Promise.all on line 169).

DuzAwe commented 1 year ago

Removed and readded. Same problem new error.

Login timeout is 180 seconds!
Using email and password from environment.
Signed in as 'XXX'
Currently no free giveaway!
Xvfb display server created screen with resolution 1280x1280
VNC is running on port 5900 (no password!)
noVNC (VNC via browser) is running on http://localhost:6080

2023-03-16 17:39:45.990 started checking epic-games
Signed in as XXX
Free games: [
  'https://store.epicgames.com/en-US/p/warhammer-40000-gladius-relics-of-war'
]
Current free game: Warhammer 40,000: Gladius - Relics of War
  Not in library yet! Click GET.
page.waitForSelector: Timeout 60000ms exceeded.
=========================== logs ===========================
waiting for locator('text=Thank you for buying') to be visible
============================================================
    at file:///fgc/epic-games.js:180:20 {
  name: 'TimeoutError'
}
2023-03-16 17:41:05.941 started checking gog
Signed in as 'XXX'
Currently no free giveaway!
vogler commented 1 year ago

Maybe the 2s are not enough for you. What hardware are you using? Try increasing 2000 to 10000 and also the click delay to e.g. 200. https://github.com/vogler/free-games-claimer/blob/4f1ca53d1b8936b62e720ae44ef5071724dbd482/epic-games.js#L162-L163

EnumC commented 1 year ago

I can reproduce the same issue on Docker. noVNC shows that it successfully navigated to the checkout page in less than 5 seconds, but it is not reliably clicking on "Place Order". Re-running the script four times was successful. This is on a workstation with AMD 5600X, Docker Windows w/ Portainer edge client. Pulled the latest image just before running the following.

Xvfb display server created screen with resolution 1280x1280

VNC is running on port 5900 (no password!)

noVNC (VNC via browser) is running on http://localhost:6080

2023-03-17 01:58:35.671 started checking epic-games

Signed in as XX

Free games: [

  'https://store.epicgames.com/en-US/p/warhammer-40000-gladius-relics-of-war'

]

Current free game: Warhammer 40,000: Gladius - Relics of War

  Not in library yet! Click GET.

page.waitForSelector: Timeout 60000ms exceeded.

=========================== logs ===========================

waiting for locator('text=Thank you for buying') to be visible

============================================================

    at file:///fgc/epic-games.js:180:20 {

  name: 'TimeoutError'

}

  Failed to claim! To avoid captchas try to get a new IP address.

... above lines repeat three times.

Xvfb display server created screen with resolution 1280x1280

VNC is running on port 5900 (no password!)

noVNC (VNC via browser) is running on http://localhost:6080

2023-03-17 02:02:41.689 started checking epic-games

Signed in as XX

Free games: [

  'https://store.epicgames.com/en-US/p/warhammer-40000-gladius-relics-of-war'

]

Current free game: Warhammer 40,000: Gladius - Relics of War

  Not in library yet! Click GET.

  Claimed successfully!
vogler commented 1 year ago

@EnumC Interesting, shouldn't be slow hardware for you (maybe slow internet connection?), but it really seems to be some timing issue since it worked the fourth time. I'll investigate re. event handler, otherwise do some retry with exponential backoff.

xamindar commented 1 year ago

I came on here to start this issue and see that it is already reported. Just adding that I am experiencing this as well. For the epic store it gets all the way to the place order screen then just sits there not clicking the place order button until it times out (and I receive a failed notification).

xamindar commented 1 year ago

My logs:

2023-03-17 17:31:45.886 started checking epic-games
Signed in as <snip>
Free games: [
  'https://store.epicgames.com/en-US/p/warhammer-40000-gladius-relics-of-war'
]
Current free game: Warhammer 40,000: Gladius - Relics of War
  Not in library yet! Click GET.
page.waitForSelector: Timeout 60000ms exceeded.
=========================== logs ===========================
waiting for locator('text=Thank you for buying') to be visible
============================================================
    at file:///fgc/epic-games.js:189:20 {
  name: 'TimeoutError'
}
  Failed to claim! To avoid captchas try to get a new IP address.
2023-03-17 17:33:05.278 started checking prime-gaming
Signed in as <snip>
Number of already claimed games (total): 15
Number of free unclaimed games (Prime Gaming): 0
Number of free unclaimed games (external stores): 0
2023-03-17 17:33:13.737 started checking gog
Signed in as '<snip>'
Currently no free giveaway!
xamindar commented 1 year ago

After 6 fails while I watched the container try over and over again, it finally claimed it on the 7th try. It appears it may not wait for the "purchase" button to go enabled on the order page before it attempts only once to click the button. Just a guess from my observations.

vogler commented 1 year ago

Some debugging. Current solution that fails for some people:

await page.waitForTimeout(2000); // waiting for a fixed time is not a good idea

However, comparing the button's initial innerHTML() with the one after 500ms gives:

<div class="payment-loading"><svg class="payment-loading__loader" viewBox="0 0 50 50"><circle class="payment-loading__path" cx="25" cy="25" r="20" fill="none" stroke-width="3"></circle></svg><div class="payment-loading--loading payment-loading__container payment-loading__container--blur"><span>Place Order</span></div></div>

and

<div class="payment-loading"><div class="payment-loading__container"><span>Place Order</span></div></div>

So I can adjust the selector and hopefully that's a stable solution for everyone.