Last active
September 25, 2023 20:25
-
-
Save jameswang14/d971dfaef31b298b8dd845dce6ff99c2 to your computer and use it in GitHub Desktop.
Redeem all Chase offers
This file contains 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
// Go to all offers page | |
function waitForElm(selector) { | |
return new Promise(resolve => { | |
if (document.querySelector(selector)) | |
{ | |
return resolve(document.querySelector(selector)); | |
} | |
const observer = new MutationObserver(mutations => { | |
if (document.querySelector(selector)) { | |
observer.disconnect(); | |
resolve(document.querySelector(selector)); | |
} | |
}); | |
observer.observe(document.body, { | |
childList: true, | |
subtree: true | |
}); | |
}); | |
} | |
const addElements = document.querySelectorAll("a[class='sixersoffers__cta']") | |
for (let i = 0; i < addElements.length; i++) { | |
const addEle = await waitForElm(`li[class="offerListItem${i}"]`) | |
await addEle.querySelector('span').click() | |
await new Promise(r => setTimeout(r, 2000)); | |
const closeElm = await waitForElm("a[class='flyout-close']") | |
await closeElm.click() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment