Created
August 20, 2021 15:23
-
-
Save smaharj1/73adb59ced50599925060418f4d78367 to your computer and use it in GitHub Desktop.
Add all the Amex Offers to the card...
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
/** | |
You need to already be in https://global.americanexpress.com/offers/eligible route. | |
This script will automatically add all the offers to the card. | |
To Run this script: | |
- Login to Amex and go to the above URL. | |
- Open 'Inspect Element' | |
- Go to Scripts tab and copy this script. | |
- Run this script. | |
*/ | |
let buttons = document.getElementsByClassName('btn offer-cta'); | |
function timeout(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
function getNewButtons() { | |
let newButtons = document.getElementsByClassName('btn offer-cta'); | |
let filtered = [] | |
for (let i = 0; i < newButtons.length; i++) { | |
if (newButtons[i].textContent === 'Add to Card') { | |
filtered.push(newButtons[i]); | |
} | |
} | |
return filtered; | |
} | |
async function begin() { | |
for (let i =0; i < buttons.length; i++) { | |
if (buttons[i].textContent === 'Add to Card') { | |
console.log('clicking ', i) | |
buttons[i].click(); | |
console.log('clicked...') | |
await timeout(2000); | |
console.log('timeout done') | |
} | |
} | |
buttons = getNewButtons(); | |
if (buttons.length > 0) { | |
console.log("Recursing...") | |
await begin(); | |
} | |
} | |
begin(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment