Skip to content

Commit

Permalink
fix: add startup delay
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasparker committed Jun 4, 2024
1 parent d2097f2 commit e822681
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions userscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
(function() {
'use strict';

const STARTUP_DELAY = 5000;
const ACTION_DELAY = 1000;
const DISPLAY_STATISTICS = true;

Expand All @@ -24,18 +25,22 @@
let couponsClipped = false;
let statisticsSent = false;

setInterval(function() {
if(!couponsLoaded) {
loadCoupons();
} else if(!couponsClipped) {
clipCoupons();
}
else if(DISPLAY_STATISTICS && !statisticsSent) {
alert(`Safeway Coupon Auto-clipper\n\nCoupons Clipped: ${totalCouponsClipped + totalCouponsExpired}`);
statisticsSent = true;
}
setTimeout(function() {

setInterval(function() {
if(!couponsLoaded) {
loadCoupons();
} else if(!couponsClipped) {
clipCoupons();
}
else if(DISPLAY_STATISTICS && !statisticsSent) {
alert(`Safeway Coupon Auto-clipper\n\nCoupons Clipped: ${totalCouponsClipped + totalCouponsExpired}`);
statisticsSent = true;
}

}, ACTION_DELAY);

}, ACTION_DELAY)
}, STARTUP_DELAY);

function loadCoupons() {
let loadMoreButton = document.querySelector('.btn.load-more');
Expand Down

0 comments on commit e822681

Please sign in to comment.