Skip to content

Instantly share code, notes, and snippets.

@PLNech
Last active November 17, 2024 14:21
Show Gist options
  • Save PLNech/765ab455cb2131214ab4af79c020bf3e to your computer and use it in GitHub Desktop.
Save PLNech/765ab455cb2131214ab4af79c020bf3e to your computer and use it in GitHub Desktop.
EPIC Games - How Much is my free games Library's worth?

A quick tutorial to estimating your account's value

Example result running on a friend's library, who's been actively collecting Epic free games of the Week since 2020: image

Setup the page in your browser, then click on all transactions you wan to count

I load the Epic Games | Transactions page and notice that you can click each block to reveal that info (triggers a network call) :

image

Once clicked and loaded the page contains this data: image

I notice in my browser the class given to the <td> holding the list price data is ".am-1c0kwh0": image If you see a different class (it's likely randomized, maybe at each site build deploy), change that part of the code ;)

Run some JS in your console

You can then run my script. In a compressed nutshell I run in my console:

count=0;sum=0.0;$.find(".am-1c0kwh0").filter((e) => !e.innerText.startsWith("+")).forEach(e => {count++;let text=e.innerText.replace("€", "").trim();sum += 1 + parseInt(text);}); console.log("Total", count, "games, purchase value:", sum, "euros!");(sum > 2500) ? ":O" : ":)";

This results in an output similar to

> Total 220 games, purchase value: 4712 euros!
":O" 

The code expanded and explained

Here's a verbose version of the above, so that you can adjust my local assumptions for eventual language/currency differences:

var count=0; // To sum how many games we analyze
var sum=0.0; // To sum how much games cost
let selector = ".am-1c0kwh0"; // Class observed in my browser inspector on the <td> holding the price data
$.find(selector).filter((e) => !e.innerText.startsWith("+")).forEach(e => {
    // The above filter to remove some "Epic Rewards" line on a purchase which broke the addition
    count++; 
    let text=e.innerText.replace("€", "").trim(); // Remove the chars which prevent parsing the price as Number 
    console.log(`Adding ${text} to ${sum}...`); 
    sum += 1 + parseInt(text); // So a game listed at 19.99 euros gets rounded to 1 + 19 = 20 euros
    }); 
console.log("Total", count, "jeux, à l'achat :", sum, "euros !"); 
(sum > 2500) ? ":O" : ":)"; // Return value because if each console run returns one, then why look so undefined

Notes

  • The code could be made more generic by finding which <td> holds a price text, then using its class? Left as an exercise for the reader
  • Excluding that one game you paid, or deducing its cost, could be meaningful to someone else than me
  • Maybe we can do without clicking 200 games one by one first, waiting on a blocked UI between two instances of visual feedback. You may automate a click event on all these? I personally found it fun to do. If you like idle games this might be your jam too, you're welcome
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment