Background (feel free to skip)
Ok, I understand this post is kind of weird OR may not relate to everybody, but stick with me here... let me explain.
I am a Software Engineer by day and as part of my profession, I like to program or code to automate any repeatable tasks that I have to do regularly.
This is where CVS coupons come into play. I generally find myself shopping at CVS Pharmacy often and they have a program called ExtraCare. It sends you, the customer, coupons on a daily or weekly basis to show appreciation and help you to save a few dollars here and there.
Note: CVS did not pay me to write this post, I just found this useful and thought maybe, just maybe, others might find it useful.
Anyways, let's get started.
With this guide, you will no longer have to manually click on each βSend to Cardβ button to auto add ExtraCare coupons for your CVS account.
Who is this for?
If all of these conditions apply to you, you might find this automation useful:
- Are you a regular customer of CVS Pharmacy?
- Do you have ExtraCare with CVS and use coupons regularly?
- Do you hate having to manually add coupons every day or week?
Let's Get Started
Step 1
Open
Google Chrome
browser, go over to https://www.cvs.com/
Step 2
Log into your CVS account
Step 3
Once logged in, click on the "ExtraCare" link from the top navigation bar
Step 4
Now, you should be able to see all of your coupons provided through ExtraCare (specifically for you). There are a lot of coupons here and having to manually add each one of these is a pain. THIS is the part we want to automate!
Step 5
First thing we want to do is scroll down to the bottom of the page. Notice, more and more coupons are being loaded as you scroll to the bottom. Keep scrolling until no more coupons are loaded.
Step 6
Ok, now,
right click
on anywhere on the page and click on "Inspect" from the menu
Step 7
This will open up a whole new section on the right side or the bottom of the page.
Step 8
Inside the sidebar, click on "Console" from the top menu
Step 9
Now, copy over this piece of code and paste it right after the
>
sign
(function run() {
const coupons = Array.from(document.querySelectorAll('send-to-card-action'))
.map(e => e.querySelector('.coupon-container .coupon-action.sc-send-to-card-action'))
.filter(Boolean);
const totalCoupons = coupons.length;
console.log(`ποΈ Total coupons to add: ${totalCoupons}`);
coupons.forEach((e, index) => {
setTimeout(() => {
e.click();
const couponsLeft = totalCoupons - index - 1;
console.log(`β¨ Coupon added... ${couponsLeft} more left! β¨`);
if (couponsLeft === 0) {
console.log("π All coupons have been added to your card. Enjoy your savings! π");
}
}, index * 350);
});
if (totalCoupons === 0) {
console.log("π All coupons have been added to your card. Enjoy your savings! π");
}
})();
Step 10
Then, press
ENTER
and watch some magic happen in the background. Notice all the coupons being automatically clicked and added for you.
Step 11
You should see a "Coupons left" counter on the sidebar, it tracks the number of coupons still to be added. Wait until that counter goes all the way down to 0.
Step 12
That's it, now all the coupons should be added to your account.
Now, I understand that this is clearly not a fully automated system, but it should at least help you avoid having to click on more than 100+ coupons on a regular basis. Let me know if you found this helpful at all. I am planning to build on top of this automation to not have to manually follow all these 12 steps, so hopefully, then, it would be even simpler.
Top comments (17)
UPDATE:
It has come to my attention that the previous script no longer works b/c of certain changes to elements in the DOM. So, I have updated the script now. Please feel free to use the latest changes as I hope it should work with recent changes to the UI on the site.
Please let me know if I have missed any weird edge cases or if the script doesn't work for any reason. Thanks!
Thanks for the quick update. This script is so useful
Thank you! works great!
king
Oh no...it's not working for me again. :(
This works awesome!! Is there any way to get this to run periodically, like every week? Ideally I don't want to have to pay for a tool like Zapier to do so
to automate this a bit more, you can add this as a 'bookmarklet'
where you add this a clickable bookmark, and you dont need to go into inspector and console and copy and paste code.
freecodecamp.org/news/what-are-boo...
This thread was SUPER helpful. Make sure to minify the js code for a functional bookmarklet. I used minify-js.com/ and this output works fine in chrome:
javascript: !function(){const o=[...document.querySelectorAll("send-to-card-action")].map((o=>o?.querySelector(".coupon-container .coupon-action.button-red"))).filter((o=>null!==o));let e=o.length;var t,n;o.forEach((t=o=>{o.click(),console.log(
Coupons left: ${e}
),e-=1},n=150,(o,e)=>{setTimeout((()=>{t(o)}),e*n)}))}();If anyone else knows of any other sites that might require similar automation to auto-add coupons to cards, I would love to know more about it, so I can contribute to fixing those as well. Let me know, ty!
Shoprite! :)
THANK YOU! THANK YOU! THANK YOU! This was amazing and SO EASY to do. Saving me a ton of time.
Hey it seems like the script is no longer working as of today. Its returning "undefined". Last time it worked was 4 days ago for me. I guess they made changes to the website, hopefully just some updates and not something to block the automation.
Hey Nazmuz, this recently stopped working unfortunately
I wonder if it was deliberate.
Any chance you'd consider doing this for Shoprite? They just went all digital with their coupons, too. Same format. Takes forever to load each individual coupon to your card on their app.
Can't thank you enough for this. Just an FYI, today I had to paste and return about 5 or 6 times to get all the coupons to copy. Not a problem at all, but just letting you know. THANK YOU again! :)
Thanks a lot, this works wonderfully!