Skip to content

Instantly share code, notes, and snippets.

@jfoo1984
Last active February 22, 2023 07:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jfoo1984/c4b892c621b635c81a2ec121985b2d4b to your computer and use it in GitHub Desktop.
Save jfoo1984/c4b892c621b635c81a2ec121985b2d4b to your computer and use it in GitHub Desktop.
Browser inspector JS snippet to click all Amex offers
// Works as of 08/2021
// Paste this code into the console of the Inspector / Developer tools of your browser
// Adapted from code snippet at: https://dannydealguru.com/quickly-add-all-amex-offers/
//
// USAGE NOTES:
// 1. As a rule of thumb, do not blindly copy / paste code from the Internet into your bank / cc account pages.
// That is a good way to allow a bad actor to gain unauthorized access to your accounts or otherwise do harm.
// This script finds all of the `Add to Card` buttons on the page, then find the merchants associated with those buttons,
// then logs each merchant name and clicks a button every 2 seconds.
// 2. If you want to add certain offers to specific cards, make sure to do that manually first. This script will
// add every available offer to the currently selected card
//
const offerButtons = Array.from(document.getElementsByClassName("btn btn-sm btn-fluid offer-cta btn-secondary"))
.filter(btn => btn.title == "Add to Card");
const offerMerchants = Array.from(document.getElementsByClassName("offer-info offer-column margin-b-md-down col-md-5"))
.map((offerInfo) => offerInfo.lastChild.innerHTML );
for (let index = 0; index < offerButtons.length; ++index) {
// Wait 2 seconds to be nice to AMEX servers
setTimeout(() => {
console.log(`Clicking offer button for ${offerMerchants[index]}`);
offerButtons[index].click()
}, 2000 * index, index);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment