Skip to content

Instantly share code, notes, and snippets.

@dten
Last active November 2, 2024 18:12
Show Gist options
  • Save dten/34b01a625977f6ec87389e750facee2b to your computer and use it in GitHub Desktop.
Save dten/34b01a625977f6ec87389e750facee2b to your computer and use it in GitHub Desktop.
ShopTo PSN Gift Card price ordering
// 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