Last active
February 18, 2024 08:45
-
-
Save peckjon/ecfc6beef7b8a2b0ce6e5efb3e818887 to your computer and use it in GitHub Desktop.
Clip all QFC 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
// ==UserScript== | |
// @name Clip all QFC coupons | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Click every "clip" coupon button on the QFC coupons page www.qfc.com/savings/cl/coupons/ | |
// @author peckjon | |
// @authorurl https://greasyfork.org/en/users/824205-peckjon | |
// @include http*://*qfc.com/savings/cl/coupons* | |
// @icon https://www.google.com/s2/favicons?domain=qfc.com | |
// @grant none | |
// @license MIT | |
// ==/UserScript== | |
var offerButtons = [] | |
var offerClicker = function(index) { | |
if(index < offerButtons.length) { | |
if (document.body.textContent.includes("reached the maximum")) { | |
console.log("Maximum number of coupons reached"); | |
} else { | |
console.log("Clicking offer button "+(index+1)+" of "+offerButtons.length); | |
offerButtons[index].click(); | |
setTimeout(function(){ offerClicker(index+1) }, 500); | |
if (offerButtons.length>0 && index>=offerButtons.length-1) { | |
console.log("Scrolling to obtain more coupons..."); | |
window.scrollBy(0,1000); | |
setTimeout(offerKickoff, 3000); | |
} | |
} | |
} | |
} | |
var offerKickoff = function() { | |
offerButtons = Array.from(document.getElementsByClassName("CouponCard-button")).filter(btn => btn.textContent == "Clip"); | |
console.log("Found "+offerButtons.length+" QFC offer buttons"); | |
if(offerButtons.length > 0) { | |
offerClicker(0); | |
} else { | |
setTimeout(offerKickoff, 3000); | |
} | |
} | |
setTimeout(offerKickoff, 3000); |
Thanks for raising this @didibus !
I've updated the script here and also added it to https://greasyfork.org/en/scripts?set=521681
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It says it's an invalid user script in Tampermonkey?