Skip to content

Instantly share code, notes, and snippets.

@dbaynard
Last active August 24, 2021 01:38
Show Gist options
  • Save dbaynard/bd2a9910f71a1ba0a27738c042d60b7a to your computer and use it in GitHub Desktop.
Save dbaynard/bd2a9910f71a1ba0a27738c042d60b7a to your computer and use it in GitHub Desktop.
Show price changes in amazon basket or after adding item
// Paste into dev console
[...document.querySelectorAll(".a-list-item, .huc-v2-item-msg")].map(x => {
const lims = x.innerText.match(/from £([0-9.]+) to £([0-9.]+)/)?.slice(1,3);
if (!!lims) {
const p = lims[1] - lims[0];
const y = 100*p/lims[0];
return [p, `£${p.toFixed(2)} (${y.toFixed(1)} %): ${x.innerText}`];
}
}).filter(x => !!x).sort((a,b) => b[0] - a[0]).forEach(([_,v]) => console.log(v));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment