Skip to content

Instantly share code, notes, and snippets.

@Smart123s
Last active November 26, 2022 09:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Smart123s/d19618be655bbfbfd34d50197c72597f to your computer and use it in GitHub Desktop.
Save Smart123s/d19618be655bbfbfd34d50197c72597f to your computer and use it in GitHub Desktop.
Tutorial on how to set up a cron job that claims games given away on gog.com every day.

Intro

In this tutorial I'm going to guide you through setting up a cron job, that opens https://www.gog.com/giveaway/claim every day, which adds the game currently on giveaway to your account. I'm going to use a Raspberry Pi with Raspberry Pi OS, but any Linux distro should work, as long as it's powered on during the time you plan to run the cron job. If you don't have a Raspberry Pi at home, I'd recommend using a free VPS. Google Cloud and Oracle Cloud both offer a reliable, and free VPS. For the setup, I'm going to use Chrome, but any browser is feasible.

Getting a session cookie

You can do this on your desktop machine.

  1. Install the EditThisCookie extension (Firefox version is also available).
  2. Right click EditThisCookie icon in the extensions toolbar, then click Options.
  3. A new tab should hvae opened. Click on options in the left sidebar, then set the "Choose the preferred export format for cookies" to "Netscape HTTP Cookie File". cookie_export_format
  4. [Optional] Open a new incognito tab (you can also use a regular tab, but incognito is recommended to not interfere with your existing (or future) gog.com session). Don't forget to allow the extension to run in incognito tabs.
  5. Go to gog.com and log in
  6. Click on the EditThisCookie icon in the extensions toolbar, then click the export button.
  7. Create a new text file, and paste in the cookies you've copied in the previous step.
  8. Save the file to the machine you are going to run the cron job on. I have it saved on my Raspberry Pi at /home/pi/.config/gog-cookie.txt

Creating the cron job

For this part, I'll be using Raspberry Pi OS (via SSH)

  1. Install cronie with sudo apt install cron
  2. Edit your cron jobs with crontab -e
  3. Add a new line at the end with the following contents:
1 1 * * * curl 'https://www.gog.com/giveaway/claim' -b "<REPLACE_THIS_WITH_COOKIE_FILE_LOCATION>" -c "<REPLACE_THIS_WITH_COOKIE_FILE_LOCATION>"

This will open https://www.gog.com/giveaway/claim with cookies from the file we saved above every day at 01:01. If you'd like to change the time, use https://crontab.guru/. I also have a user-agent added to the request, that's optional. It'd make curl look (a bit more like) Chrome. To add it, append the following at the end of the line: -H "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"

  1. Save the file (if you are using nano, press Ctr + X, then y then Enter)

That's it

If you have any questions, or improvements, feel free to leave a comment below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment