-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcouponClicker.js
130 lines (117 loc) · 4.43 KB
/
couponClicker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
running = false;
var brands = ["Always","Arrowhead","Ben\\ \\&\\ Jerry\\'s","belVita","Bounce","Bounty",
"Breyers","Bush\\'s","Clorox","Charmin","Cheerios","Cheez-it","Coca-Cola","Comforts",
"Cottonelle","Country\\ Crock","Crest","Dasani","Dawn","Dial","DIGIORNO","Dove","Energizer",
"Febreze","Fiber\\ One","Frito-Lay","Gatorade","Guerrero","General\\ Mills","Ghirardelli",
"Gillette","Glad","Goldfish","Hefty","Heinz","Hormel","Huggies","Hungry\\ Jack","Kellogg\\'s",
"Kraft","Jennie-O","Jimmy\\ Dean","Listerine","Luvs","Lysol","Marie\\ Callender\\'s","Nabisco",
"Naked\\ Juice","Nature\\ Valley","Old\\ Spice","Pampers","PediaSure","PHILADELPHIA","Playtex",
"Rubbermaid","Sabra","Secret","Silk","Simple\\ Truth","Soft\\ Soap","Softsoap","Special\\ K",
"Store\\ Brand","Swiffer","TAMPAX","Tide","Tostitos","TUMS","Venus","vitaminwater","Welch\\'s",
"Windex","Ziploc","ZzzQuil"];
// var ignore_labels = ["Lithium","Men+Care® Hair Products","Always DISCREET","Dove® Beauty Bar"];
function clickCategories() {
$(".all_categories input").prop("checked", true)
$(".all_categories input").trigger("click")
}
function couponClicks() {
if (running) {
console.log("couponClicker->couponClicks is still running");
return;
}
running = true;
clickCategories();
setTimeout(function(){
var coupons_to_add = 0;
for (var i=0; i<brands.length; i++) {
if ($("#"+brands[i]).length) {
coupons_to_add ++;
$("#"+brands[i]).prop("checked", true)
$("#"+brands[i]).trigger("click")
}
}
if (!coupons_to_add) {
alert("No new coupons to add");
running = false;
} else {
setTimeout(function(){
$('.coupon_action').trigger("click")
running = false;
console.log("couponClicker->couponClicks is done running");
alert(coupons_to_add + " coupon(s) added");
}, 1);
}
}, 1);
}
function loadCoupons(cb) {
var list = $(".couponlist li")
var buttons = $('.coupon_action')
if (list.length != buttons.length) {
list.trigger("focus");
setTimeout(function() {
loadCoupons(cb)
},1)
} else {
cb();
}
}
function couponClicksPhone() {
if (running) {
alert("couponClicker->couponClicksPhone is still running");
return;
}
running = true;
$(".all_categories option").attr("selected", "selected")
$(".all_categories").trigger("change")
setTimeout(function(){
var brands_to_add = false;
var current_brands = $(".current_brands option");
current_brands.each(function(i, el){
var v = el.value;
var brand = v.replace(/\ \(.*/, "");
if (brands.indexOf(brand) > -1) {
brands_to_add = true;
el.setAttribute("selected","selected");
}
})
current_brands.parent().trigger("change");
if (!brands_to_add) {
alert("No new coupons to add");
running = false;
} else {
setTimeout(function(){
loadCoupons(function(){
var coupon_buttons = $('.coupon_action')
// coupon_buttons.each(function(i, el) {
// var label = el.children[0].innerHTML;
// for (var i=0; i<ignore_labels.length; i++) {
// }
// })
var total_coupons = coupon_buttons.length
coupon_buttons.trigger("click");
running = false;
console.log("couponClicker->couponClicks is done running");
alert(total_coupons + " coupon(s) added");
})
}, 1);
}
}, 1);
}
// function brandsInverted() {
// clickCategories();
// setTimeout(function(){
// $(".current_brands input").prop("checked", true)
// $(".current_brands input").trigger("click")
// setTimeout(function(){
// for (var i=0; i<brands.length; i++) {
// if ($("#"+brands[i]).length) {
// $("#"+brands[i]).prop("checked", false)
// $("#"+brands[i]).trigger("click")
// }
// }
// }, 1000);
// }, 1000);
// }
// document.getElementsByClassName('unclip')[0].click();setTimeout(function(){document.getElementsByClassName("removecpn")[0].click();}, 300);
// javascript:(function(){if(typeof cpn_script=='undefined'){cpn_script=document.createElement('SCRIPT');cpn_script.type='text/javascript';cpn_script.src='https://server.com/couponClicker.js';cpn_script.onload=function(){couponClicks();};document.getElementsByTagName('head')[0].appendChild(cpn_script);}else{couponClicks();}})();
// javascript:(function(){if(typeof cpn_script=='undefined'){cpn_script=document.createElement('SCRIPT');cpn_script.type='text/javascript';cpn_script.src='https://server.com/couponClicker.js';cpn_script.onload=function(){couponClicksPhone();};document.getElementsByTagName('head')[0].appendChild(cpn_script);}else{couponClicksPhone();}})();