DEV Community

Cover image for Automate Adding CVS Coupons

Automate Adding CVS Coupons

Nazmuz Shakib Pranto on March 12, 2022

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...
Collapse
 
npranto profile image
Nazmuz Shakib Pranto

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!

Collapse
 
jdeen profile image
James Dean

Thanks for the quick update. This script is so useful

Collapse
 
wildcentury501 profile image
Brian McKnight

Thank you! works great!

Collapse
 
cuser profile image
C

Oh no...it's not working for me again. :(

Collapse
 
hellosurbhi profile image
Surbhi

king

Collapse
 
brandenbedoya profile image
Branden Bedoya

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

Collapse
 
madmaxlax profile image
Max Struever

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...

Collapse
 
thetimbuk profile image
M.Andersson

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)}))}();

Collapse
 
npranto profile image
Nazmuz Shakib Pranto

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!

Collapse
 
cuser profile image
C

Shoprite! :)

Collapse
 
tigeruppercut profile image
Tony Jackson

Second for Shoprite

Collapse
 
christy_hagood_dd0909912b profile image
Christy Hagood

THANK YOU! THANK YOU! THANK YOU! This was amazing and SO EASY to do. Saving me a ton of time.

Collapse
 
wildcentury501 profile image
Brian McKnight

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.

Collapse
 
hellosurbhi profile image
Surbhi

Hey Nazmuz, this recently stopped working unfortunately

Collapse
 
wildcentury501 profile image
Brian McKnight

I wonder if it was deliberate.

Collapse
 
cuser profile image
C

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.

Collapse
 
zedx12345 profile image
Must

Thanks a lot, this works wonderfully!

Collapse
 
tigeruppercut profile image
Tony Jackson

This is absolutely amazing. I was just looking online to see if this was possible. Thanks alot

Collapse
 
cuser profile image
C

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! :)