Click all the coupons on BJ's Wholesale Club website
< 脚本 BJ's Wholesale Club Coupon Clicker 的反馈
Looks like a nice adjustment, unfortunately I'm no longer a member so cant test for inclusion.
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址
I made some adjustments if you want to include them
Added a start button + a little status bar on the page below the coupon tabs
Either way, thanks for the script! This saves so much time, just wish Costco did the same
var couponAttribute = "";
var totalCoupon = 0;
function clipCoupons(index, elements, limit, count){
if (elements == "undefined") {
elements = document.querySelectorAll(".gray-btn");
count = elements.length;
clipCoupons(0, elements, 1000, count);
console.log("Next Page...");
} else if (index < count){
elements[index].click();
totalCoupon++;
index++;
console.log("Clipping Coupon #" + totalCoupon);
document.querySelector('p[class="clipCount"]').innerText = " Clipping Coupon #" + totalCoupon;
setTimeout(()=>{
clipCoupons(index, elements, 1000, count);
}, 750)
} else {
if(document.querySelectorAll("button.next-prev").length >= 1) {
var paginationButtons = document.querySelectorAll("button.next-prev");
for(var i = 0; i < paginationButtons.length; i++) {
if (paginationButtons[i].innerHTML.includes("Next",1)) {
paginationButtons[i].click();
break;
}
}
setTimeout(()=>{
clipCoupons(0, "undefined", 1000, 0);
}, 3000)
} else {
printEnd();
}
}
}
function printEnd(){
console.log('Finished');
}
window.addEventListener('load', () => {
addButton('Clip All', function() {totalCoupon = 0; console.log('Beginning Coupon Clipping...!'); clipCoupons(0, "undefined", 1000, 0);})
})
function addButton(text, onclick, cssObj) {
cssObj = cssObj || {width: '60px',height: '30px'}
let button = document.createElement('button'), btnStyle = button.style
button.style = "display: inline-block; "
button.className = "clipAll"
button.id = "clipAll"
document.querySelector('div[class="col-md-6 col-lg-4 col-12 mb-3 mb-md-0 searchBar"]').appendChild(button)
button.innerHTML = text
button.onclick = onclick
Object.keys(cssObj).forEach(key => btnStyle[key] = cssObj[key])
let clipCount = document.createElement('p')
clipCount.style = "display: contents; margin: 5; padding-left: 5;"
clipCount.id = "clipCount"
clipCount.className = "clipCount"
clipCount.innerHTML = totalCoupon || "Waiting to start"
document.querySelector('div[class="col-md-6 col-lg-4 col-12 mb-3 mb-md-0 searchBar"]').appendChild(clipCount);
}