Last active
November 2, 2024 18:12
-
-
Save dten/34b01a625977f6ec87389e750facee2b to your computer and use it in GitHub Desktop.
ShopTo PSN Gift Card price ordering
This file contains hidden or 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
// Only works when logged out cause otherwise the prices are images | |
// https://www.shopto.net/en/sony-gift-card/ | |
{ | |
let prices = [...document.querySelectorAll('.itemlist__info:not(:has(.not_available))')] | |
.map(e => { | |
let gc = e.querySelector('.itemlist__description')?.innerText.match(/Gift Card (\D)([\d\.]+)/) | |
let gold = e.querySelector('.memb-badge-container')?.innerText.match(/([\d\.]+)/) | |
return { | |
currency: gc?.[1], | |
card: gc?.[2], | |
gold_price: gold?.[1] | |
} | |
}) | |
.filter(r => r.gold_price && r.card) | |
.map(r => Object.assign(r, { percent: parseFloat(r.gold_price) / parseFloat(r.card) })) | |
.sort((a, b) => a.percent - b.percent) | |
console.table(prices) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment