Created
October 19, 2023 17:53
-
-
Save tadcrazio/13e9929307af5cfcfc2fc87ec6e605ff to your computer and use it in GitHub Desktop.
Clip all Kroger coupons
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
//Kroger limits to 200 coupons, this will add the first 200.. | |
// Get all coupon cards | |
const couponCards = document.querySelectorAll('.CouponCard-wrapper'); | |
// Scroll to the bottom of the page | |
window.scrollTo(0, document.body.scrollHeight); | |
// Loop through each coupon card and clip the coupon | |
couponCards.forEach(couponCard => { | |
const clipButton = couponCard.querySelector('button[data-testid^="CouponActionButton-"]'); | |
if (clipButton && clipButton.textContent === 'Clip') { | |
clipButton.click(); | |
} | |
}); | |
// Check if there are more coupons to clip | |
const nextPageButton = document.querySelector('button[aria-label="Next Page"]'); | |
if (nextPageButton) { | |
nextPageButton.click(); | |
// Wait for the next page to load | |
setTimeout(() => { | |
// Repeat the clipping process for the next page | |
const newCouponCards = document.querySelectorAll('.CouponCard-wrapper'); | |
newCouponCards.forEach(couponCard => { | |
const clipButton = couponCard.querySelector('button[data-testid^="CouponActionButton-"]'); | |
if (clipButton && clipButton.textContent === 'Clip') { | |
clipButton.click(); | |
} | |
}); | |
}, 1000); // Adjust the delay as needed | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment