Now that the Discover Double Cashback is finally coming in, you may be looking into redeeming your Discover cashback in various ways, such as gift cards. But say you’ve just redeemed for a bunch of gift cards, and you want to easily grab the codes off the redemption page. Normally this would involve a lot of copy and pasting while switching back and forth between windows, but I’ve wrote a simple script so you can grab ALL the e-gift codes and PINs straight from the page.
- Open up your Javascript console. You can access the Javascript console on Chrome with the following methods:
- Use the keyboard shortcut Command + Option + J (Mac) or Control+ Shift + J (Windows/Linux).
- Select > More Tools > JavaScript Console.
- Go to this site and paste the displayed code into the Javascript console:
You will then see the e-gift card codes and PINs printed out to your Javascript console.
If you’d like a bookmarklet, you can add it at this site
No need to use jquery for every single thing; the DOM has great primitives.
const lines = document.querySelectorAll('.ecertificate-content').map((node) => {
const dds = node.querySelectorAll('.dd');
return${dds[0].textContent}\t${dds[1].textContent}
;
});
console.log(lines.join('\n'));
Damn. Thanks! I’ll let Michael update the post.
Cool name by the way. Guess your parents saw technology before it happened 😉
[…] reader notified me that the script to grab all egiftcard codes from Discover could be cleaned up and simplified a bit. Also I noticed that WordPress was mangling the code […]
I have been trying to get this to work in Chrome (updated completely up to date), but keep getting an error after running the script: undefined