Last active
September 24, 2020 10:13
-
-
Save SMUsamaShah/76bd8258fc52e087bda6437e16324370 to your computer and use it in GitHub Desktop.
Filter Epic Game Store by Price
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// open https://www.epicgames.com/store/en-US/browse?pageSize=1000 | |
// paste in console and run | |
function filterEpicGames(min = 0, max = 15) { | |
let games = document.querySelectorAll("#dieselReactWrapper > div > div[class*='AppPage__bodyContainer'] > main > div > div > div > div > div > section > div > div > div > section > div > section > section > ul > li > a > div > div > div[class*='OfferCard__meta']"); | |
let c = 1; | |
for (let i = 0; i < games.length; i++) { | |
let name = games[i].firstChild.innerText; | |
let priceText = (games[i].lastChild.lastChild.lastChild ? games[i].lastChild.lastChild.lastChild.lastChild.nodeValue : games[i].lastChild.lastChild.nodeValue); | |
let price = 0; | |
switch (priceText) { | |
case 'Coming Soon': price = -1; break; | |
case 'Free': price = 0; break; | |
default: price = parseFloat(priceText.substr(1)); | |
} | |
// list matches in console | |
if (price >= min && price <= max) console.log((c++) + '. ' + price + ' - ' + name); | |
// hide all non matching games from page | |
if (price >= min && price <= max) { | |
games[i].parentElement.parentElement.parentElement.parentElement.style.display = 'initial'; | |
} else { | |
games[i].parentElement.parentElement.parentElement.parentElement.style.display = 'none'; | |
} | |
} | |
} | |
filterEpicGames(0, 15); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment