-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathebay.js
478 lines (428 loc) · 21.7 KB
/
ebay.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
savingsArray = [];
coupArray = [];
bestCouponFound = 0;
flagCoupon = [];
function getXMLHTTPRequest() {
req = new XMLHttpRequest();
return req;
}
for(var i=0;i < 200; i++){
flagCoupon[i] = 2;
}
function reportPurchase(){
var curURL = window.location.href;
if(curURL.split('order2.ebay.in').length>1){
chrome.runtime.sendMessage({processDONE: "Ebay"}, function(response) {
});
}
}
reportPurchase();
function changeFlag(i, coupon){
flagCoupon[i] = 1;
setTimeout(function(){postProcessor(coupon, i);},1000);
}
function changeFlag2(i, coupon){
flagCoupon[i] = 0;
}
function removeCompletely(){
}
function postProcessor(coupon, i){
if($('.xo-curtain').css("display")!="block"){
if($('.xo-r-cpn').text()==""){
savings = 0;
}
else {
savings = $('.xo-r-cpn').text().trim().split("Rs.")[1].trim().split(".")[0];
savings = savings.split(",").join("");
savings = parseFloat(savings);
}
savings = parseFloat(savings);
console.log("Savings for " + coupon + " is " + savings);
if(savings > $('.hdc-sav-amt').text()){
var currentSavAmt = parseFloat($('.hdc-sav-amt').text()),
finalSavAmt = savings;
$({c: currentSavAmt}).animate({c: finalSavAmt}, {
step: function(now) {
$('.hdc-sav-amt').text(Math.round(now))
},
duration: 1000,
easing: "linear"
});
}
savingsArray[i] = savings;
if($('#couponRemove').length>0){
if(bestCouponFound==0){
document.getElementById('couponRemove').click();
}
}
setTimeout(function(){changeFlag2(i, coupon);},1000);
}
else {
setTimeout(function(){postProcessor(coupon, i);},1000);
}
}
function preProcessor(i, coupon){
$('#enterCoupon').val(coupon);
document.getElementById('couponApply').click();
console.log("Coupon Code applied " + coupon);
setTimeout(function(){changeFlag(i, coupon);},1000);
}
function temp(coupon, i, lenArray){
if(lenArray==100){
$('.hdc-loading').html('Automatically applying the best coupon now !');
$('.hdc-lb-progress').text("100% Complete");
$('.hdc-lb-fg').css("width", "100%");
preProcessor(i, coupon);
}
else if(i==0||flagCoupon[i-1]==0){
$('.hdc-loading').html('Trying code <span class="hdc-load-curr hdc-bold">' + (i+1) + '</span> of <span class="hdc-load-tot hdc-bold">' + lenArray + '</span>');
var perDone = i/lenArray;
perDone = perDone*100;
perDone = parseInt(perDone);
$('.hdc-lb-progress').text(perDone + "% Complete");
$('.hdc-lb-fg').css("width", perDone + "%");
preProcessor(i, coupon);
}
else {
setTimeout(function(){temp(coupon, i, lenArray);},1000);
}
}
function endProcess(i){
console.log("called with " + i);
if(flagCoupon[i]==0){
console.log("Process terminated");
max = -111111;
ind_req = 1000;
for(m=0;m<savingsArray.length;m++){
if(max < savingsArray[m]){
max = savingsArray[m];
ind_req = m;
}
}
if(max>0){
bestCouponFound = 1;
coup_req = coupArray[ind_req];
flagCoupon[0] = 2;
temp(coup_req, 0, 100);
$('.hatke-discount-cover').css("display", "none");
savings = $('.hdc-sav-amt:eq(0)').text();
$('.hatke-discount-cover:eq(1)').css("display", "block");
var currentSavAmt = 0,
finalSavAmt = max;
$({c: currentSavAmt}).animate({c: finalSavAmt}, {
step: function(now) {
$('.hdc-sav-amt').text(Math.round(now))
},
duration: 1000,
easing: "linear"
});
chrome.runtime.sendMessage({savings: max}, function(response) {});
}
else {
$('.hatke-discount-cover').css("display", "none");
$('.hatke-discount-cover:eq(2)').css("display", "block");
}
console.log(savingsArray);
}
else {
setTimeout(function(){endProcess(i);},1000);
}
}
function addToWatchList() {
var myurl = "http://compare.buyhatke.com/addWatchList.php";
if($('[itemprop="name"]').length > 0){
if(($('[itemprop="name"]').text().split("Details about")).length > 1)
{
var name = $('[itemprop="name"]').eq(0).text().split("about")[1].trim();
}
else
{
var name = $('[itemprop="name"]').eq(0).text().trim();
}
}
else if($('h1').length > 0)
{
var name = $("h1").eq(0).text();
}
if($('[itemprop="price"]').length > 0)
{
var price_val = $('[itemprop="price"]').eq(0).text();
}
else if($(".topPriceRange").length > 0){
var price_val = $(".topPriceRange").eq(0).text();
}
else
{
var price_val = 0;
}
if(price_val.split("Rs.").length > 1)
{
var price = price_val.split("Rs.")[1].split(",").join("").trim();
}
else
{
var price = price_val.split(",").join("").trim();
}
if($('img[itemprop="image"]').length > 0)
{
var image_url = $('img[itemprop="image"]').attr('src');
}
else if($(".img-polaroid").length > 0)
{
var image_url = $(".img-polaroid").attr("src");
}
var prod = name;
var myPrice = price;
var image2 = image_url;
var url = window.location.href;
var filterURL2 = url.split("?ref=")[0];
filterURL2 = filterURL2.split("ref=")[0];
filterURL2 = filterURL2.split("?")[0];
url = filterURL2;
var imgURL2 = chrome.extension.getURL("watch-price1.png");
var parameters = encodeURIComponent(prod) + "~*~*" + myPrice + "~*~*" + encodeURIComponent(image2) + "~*~*" + encodeURIComponent(url) + "~*~*1" ;
chrome.runtime.sendMessage({data: parameters}, function(response) {
//console.log(response.farewell);
});
chrome.runtime.sendMessage({email: "haiKya"}, function(response) {
//console.log(response.farewell)
if(response.farewell=="No"){
var msg = '<div id="addEmailBH"><input id="BhEmail" type="text" value="" style="min-height: 20px;margin-right: 6px;"><input id="BhButton" type="button" value="Enter Email" style="padding: 3px;padding-left: 8px;padding-right: 8px;"><br><div class="line fk-font-12" style="margin-bottom: 4px;">Enter your email if you wanna get a mail when the price drops</div></div>';
$('#addWatchList').after(msg);
var button = document.getElementById("BhButton");
button.addEventListener("click", function(){
addEmailID(document.getElementById('BhEmail').value);
document.getElementById('addEmailBH').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;">Thank You ! An email has been sent to ' + document.getElementById('BhEmail').value + '. Please verify to start receiving price drop notifications. Do check your <b>SPAM</b> folder !</div>'
}, false);
}
else {
var msg = '<div id="addEmailBH"><div class="line fk-font-12" style="margin-bottom: 4px;">Thank You ! A mail will be sent to ' + response.farewell + ' as soon as price drops. <a href="javascript:void();" id="changeEmail" style="color:blue;">Change Email-ID</a></div></div>';
$('#addWatchList').after(msg);
var button = document.getElementById("changeEmail");
button.addEventListener("click", function(){
document.getElementById('addEmailBH').innerHTML = '<div id="addEmailBH"><input id="BhEmail" type="text" value="" style="min-height: 20px;margin-right: 6px;"><input id="BhButton" type="button" value="Enter Email" style="padding: 3px;padding-left: 8px;padding-right: 8px;"><br><div class="line fk-font-12" style="margin-bottom: 4px;">Enter your email if you wanna get a mail when the price drops</div></div>';
var button = document.getElementById("BhButton");
button.addEventListener("click", function(){
addEmailID(document.getElementById('BhEmail').value);
document.getElementById('addEmailBH').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;">Thank You ! An email has been sent to ' + document.getElementById('BhEmail').value + '. Please verify to start receiving price drop notifications. Do check your <b>SPAM</b> folder !</div>'
}, false);
}, false);
}
});
document.getElementById('bhWidget').innerHTML = '<div class="pricealert_hatke"><div class="price_hatke-wrap"><div class="price_hatke-initiated"><span class="price_hatke-type">Set Price:</span><span class="price_hatke-price"><img src="http://compare.buyhatke.com/images/rupeeK.png">' + myPrice + '</span></div><div class="price_hatke-difference"><span class="price_hatke-type">Price Change:</span><span class="price_hatke-price dec-hatke"><img class="dec_rupee-hatke" src="http://compare.buyhatke.com/images/rupeeG.png"><img class="inc_rupee-hatke" src="http://compare.buyhatke.com/images/rupeeR.png">0<div class="inc_dec-hatke-wrap"><img class="inc_dec-hatke" src="http://compare.buyhatke.com/images/price_change1.png"></div></span></div><a href="javascript:void();" id="removeMe2">Remove</a></div></div><div id="addWatchList"></div>';
var button = document.getElementById("removeMe2");
button.addEventListener("click", function(){
removeAlert();
document.getElementById('bhWidget').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;">Thank You ! We appreciate your motive to save energy :)</div>';
}, false);
}
flagToDisp = 0; strToDisp = ""; clsToUse = ""; diff = 0;
chrome.runtime.sendMessage({detailArray: "haiKya"}, function(response) {
arrayRes = response.farewell;
var currentURL = window.location.href;
var filterURL = currentURL.split("?ref=")[0];
filterURL = filterURL.split("ref=")[0];
filterURL = filterURL.split("?")[0];
if($('[itemprop="price"]').length > 0)
{
var price_val = $('[itemprop="price"]').eq(0).text();
}
else if($(".topPriceRange").length > 0){
var price_val = $(".topPriceRange").eq(0).text();
}
else
{
var price_val = 0;
}
if(price_val.split("Rs.").length > 1)
{
var price = price_val.split("Rs.")[1].split(",").join("").trim();
}
else
{
var price = price_val.split(",").join("").trim();
}
myPrice = price;
myPrice = parseFloat(myPrice);
for(i=0;i<response.farewell.length;i++){
var currentURL2 = response.farewell[i].link;
var filterURL2 = currentURL2.split("?ref=")[0];
filterURL2 = filterURL2.split("ref=")[0];
filterURL2 = filterURL2.split("?")[0];
//console.log(filterURL , filterURL2);
if(filterURL2==filterURL || filterURL2 == filterURL + "?" || filterURL2 + "?" == filterURL){
//console.log("match found");
if(myPrice!=0){
response.farewell[i].cur_price = myPrice;
}
if(response.farewell[i].price_added >= response.farewell[i].cur_price){
clsToUse = "dec-hatke";
diff = response.farewell[i].price_added - response.farewell[i].cur_price;
}
else {
clsToUse = "inc-hatke";
diff = response.farewell[i].cur_price - response.farewell[i].price_added;
}
strToDisp = '<div class="pricealert_hatke"><div class="price_hatke-wrap"><div class="price_hatke-initiated"><span class="price_hatke-type">Set Price:</span><span class="price_hatke-price"><img src="http://compare.buyhatke.com/images/rupeeK.png">' + response.farewell[i].price_added + '</span></div><div class="price_hatke-difference"><span class="price_hatke-type">Price Change:</span><span class="price_hatke-price ' + clsToUse + '"><img class="dec_rupee-hatke" src="http://compare.buyhatke.com/images/rupeeG.png"><img class="inc_rupee-hatke" src="http://compare.buyhatke.com/images/rupeeR.png">' + diff + '<div class="inc_dec-hatke-wrap"><img class="inc_dec-hatke" src="http://compare.buyhatke.com/images/price_change1.png"></div></span></div><a href="javascript:void();" id="removeMe2">Remove</a></div></div><div id="addWatchList"></div>';
flagToDisp = 1;
//console.log("Flag " + flagToDisp);
if(flagToDisp==1){
if($('#bhWidget').length>0){
document.getElementById('bhWidget').innerHTML = strToDisp;
var button = document.getElementById("removeMe2");
button.addEventListener("click", function(){
removeAlert();
document.getElementById('bhWidget').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;">Thank You ! We appreciate your motive to save energy :)</div>';
}, false);
}
else {
if($('#why2buy').length>0){
$('#why2buy').before(strToDisp);
}
else if($('.watchListCmp').length>0){
$('.watchListCmp').after(strToDisp);
}
var button = document.getElementById("removeMe2");
button.addEventListener("click", function(){
removeAlert();
document.getElementById('bhWidget').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;">Thank You ! We appreciate your motive to save energy :)</div>';
}, false);
}
}
}
}
//console.log(response.farewell);
});
if(flagToDisp==0){
var imgURL2 = chrome.extension.getURL("watch-price1.png");
if($('#why2buy').length>0){
$('#why2buy').before('<div id="bhWidget"><a id="addWatchList" style="margin-top: 4px;" alt="Add to Watch List" title="Add to BuyHatke Watch List and get notifications on price drop" href="javascript:void();" class="fk-inline-block buy-btn fksk-buy-btn"><img style="margin-left:-12px;" src=' + imgURL2 +'></a></div>');
}
else if($('.watchListCmp').length>0){
$('.watchListCmp').after('<div id="bhWidget"><a id="addWatchList" style="margin-top: 4px;" alt="Add to Watch List" title="Add to BuyHatke Watch List and get notifications on price drop" href="javascript:void();" class="fk-inline-block buy-btn fksk-buy-btn"><img style="margin-left:-12px;" src=' + imgURL2 +'></a></div>');
}
var button = document.getElementById("addWatchList");
if(button != undefined){
button.addEventListener("click", function(){
addToWatchList();
}, false);
}
}
else if($('#why2buy').length>0){
$('#why2buy').before(strToDisp);
}
else if($('.watchListCmp').length>0){
$('.watchListCmp').after(strToDisp);
}
function removeAlert(){
var currentURL = window.location.href;
var filterURL = currentURL.split("?ref=")[0];
filterURL = filterURL.split("ref=")[0];
filterURL = filterURL.split("?")[0];
//console.log("Filtered URL " + filterURL);
chrome.runtime.sendMessage({detailArray: "haiKya"}, function(response) {
for(m=0;m<response.farewell.length;m++){
var url2 = response.farewell[m].link;
url2 = url2.split("?ref=")[0];
url2 = url2.split("ref=")[0];
url2 = url2.split("?")[0];
if(url2==filterURL){
sendId = response.farewell[m].link_id;
chrome.runtime.sendMessage({removeURL: sendId}, function(response) {
//console.log("Removal request sent");
});
}
}
});
}
function applyCoupons(coupons){
couponsArray = coupons.split("~");
var savings = [];
for(var i=0;i<couponsArray.length;i++){
if(couponsArray[i]!=""&&couponsArray[i]!=" "){
var cur = couponsArray[i];
coupArray[i] = cur;
temp(cur, i, couponsArray.length-1);
}
}
endProcess(couponsArray.length-2);
}
function getCoupons(){
for(var i=0;i < 200; i++){
flagCoupon[i] = 2;
}
bestCouponFound = 0;
$('.hatke-discount-cover:eq(0)').css("display", "block");
if($('#couponRemove').length>0){
document.getElementById('couponRemove').click();
}
var httpq4 = new getXMLHTTPRequest();
var ext_id, ext_auth;
chrome.runtime.sendMessage({ext_id: "value"}, function(response) {
ext_id = response.farewell.split("~")[0];
ext_auth = response.farewell.split("~")[1];
var myurl = "http://compare.buyhatke.com/extension/getCoupons.php";
var parameters = "ext_id=" + ext_id + "&auth_val=" + ext_auth + "&pos=4";
httpq4.open("POST", myurl, true);
httpq4.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
httpq4.onreadystatechange = function(){
if (httpq4.readyState == 4) {
if(httpq4.status == 200) {
var mytext = httpq4.responseText;
console.log("Coupons " + mytext);
couponsLength = mytext.split("~").length - 1;
$('.hdc-c-line:eq(0)').text("We are automatically trying " + couponsLength + " coupon codes for you !");
applyCoupons(mytext);
}
}
};
httpq4.send(parameters);
});
}
function removeTheCover(){
if($('.hatke-discount-cover').length>0){
$('.hatke-discount-cover').css("display", "none");
}
}
function addToDOM(){
$('body').append('<div class="hatke-discount-cover" style="display:none;"><div class="hd-cover-bg"></div><div class="hd-cover-main"><a href="#" class="hd-cover-close">x</a><div class="hd-cover-wrap"><header class="hd-cover-head"><a href="http://compare.buyhatke.com/"><img src="http://compare.buyhatke.com/images/buyhatke_logo_big.png"></a></header><div class="hd-cover_content"><h3 class="hdc-head">Finding out the best coupon for you !</h3><div class="hdc-content-main"><div class="hdc-c-line">We are automatically getting coupon codes for you.</div><div class="hdc-loading_bar"><div class="hdc-lb-bg hdc-lb"><span class="hdc-lb-progress">40% Complete</span><div class="hdc-lb hdc-lb-fg" style="width:40%;"></div></div></div><div class="hdc-c-line hdc-center"><div class="bubblingG"><span id="bubblingG_1"></span><span id="bubblingG_2"></span><span id="bubblingG_3"></span></div><span class="hdc-loading"></span></div><div class="hdc-savings"><div class="hdc-total-savings"><span class="WebRupee">Rs.</span> <span class="hdc-sav-amt">0</span></div> saved till now</div></div></div></div></div></div>');
$('body').append('<div class="hatke-discount-cover" style="display:none;"><div class="hd-cover-bg"></div><div class="hd-cover-main"><a href="#" class="hd-cover-close">x</a><div class="hd-cover-wrap"><header class="hd-cover-head"><a href="http://compare.buyhatke.com/"><img src="http://compare.buyhatke.com/images/buyhatke_logo_big.png"></a></header><div class="hd-cover_content"><h3 class="hdc-head">Yippie!</h3><div class="hdc-content-main"><div class="hdc-c-line">Congratulations! You have saved a total of <div class="hdc-total-savings"><span class="WebRupee">Rs.</span> <span class="hdc-sav-amt">0</span>!</div></div><div class="hdc-button-wrap"><div href="#" class="hdc-button"><div class="hdc-share"><span class="its-title">Share Your Joy:</span> <div class="is-sp is-fb"><a href="https://www.facebook.com/sharer/sharer.php?s=100&p%5Btitle%5D=Have%20you%20started%20saving%20via%20Buyhatke%20?&p%5Bsummary%5D=Yippie%20!%20I%20just%20saved%20by%20automatically%20applying%20best%20coupon%20via%20Buyhatke&p%5Burl%5D=http%3A%2F%2Fextension.buyhatke.com&p%5Bimages%5D%5B0%5D=http://compare.buyhatke.com/pricegraph.jpg.pagespeed.ce.DJYFBY26i2.jpg" target="_blank" class="is-logo is-l-fb"></a></div><div class="is-sp is-tw"><a href="http://twitter.com/home?status=Try%20the%20amazing%20CompareHatke%20Chrome%20Extension!+http%3A%2F%2Fextension.buyhatke.com" target="_blank" class="is-logo is-l-tw"></a></div><div class="is-sp is-gp"><a href="https://plus.google.com/share?url=http%3A%2F%2Fextension.buyhatke.com" target="_blank" class="is-logo is-l-gp"></a></div></div></div><a href="#" class="hdc-button">Finish</a></div><footer class="hdc-footer"><div class="hdc-feedback">Give us a <a href="http://buyh.tk/r5" target="_blank">feedback</a></div></footer></div></div></div></div></div>');
$('body').append('<div class="hatke-discount-cover" style="display:none;"><div class="hd-cover-bg"></div><div class="hd-cover-main"><a href="#" class="hd-cover-close">x</a><div class="hd-cover-wrap"><header class="hd-cover-head"><a href="http://compare.buyhatke.com/"><img src="http://compare.buyhatke.com/images/buyhatke_logo_big.png"></a></header><div class="hd-cover_content"><h3 class="hdc-head">Sorry! No Coupons Found</h3><div class="hdc-content-main"><div class="hdc-c-line">Sorry. We were unable to find any suitable coupons for your product.</div><div class="hdc-c-line"> But still you saved your precious time ! :)</div><div class="hdc-button-wrap"><a href="#" class="hdc-button">Finish</a></div><footer class="hdc-footer"><div class="hdc-feedback">Give us a <a href="http://buyh.tk/r5" target="_blank">feedback</a></div><div class="hdc-share"><span class="its-title">Share:</span><div class="is-sp is-fb"><a href="https://www.facebook.com/sharer/sharer.php?s=100&p%5Btitle%5D=Have%20you%20started%20saving%20via%20Buyhatke%20?&p%5Bsummary%5D=Yippie%20!%20I%20just%20saved%20by%20automatically%20applying%20best%20coupon%20via%20Buyhatke&p%5Burl%5D=http%3A%2F%2Fextension.buyhatke.com&p%5Bimages%5D%5B0%5D=http://compare.buyhatke.com/pricegraph.jpg.pagespeed.ce.DJYFBY26i2.jpg" target="_blank" class="is-logo is-l-fb"></a></div><div class="is-sp is-tw"><a href="http://twitter.com/home?status=Try%20the%20amazing%20CompareHatke%20Chrome%20Extension!+http%3A%2F%2Fextension.buyhatke.com" target="_blank" class="is-logo is-l-tw"></a></div><div class="is-sp is-gp"><a href="https://plus.google.com/share?url=http%3A%2F%2Fextension.buyhatke.com" target="_blank" class="is-logo is-l-gp"></a></div></div></footer></div></div></div></div></div>');
var buttons = document.getElementsByClassName('hd-cover-close');
buttons[0].addEventListener("click", function(){
removeTheCover();
}, false);
buttons[1].addEventListener("click", function(){
removeTheCover();
}, false);
buttons[2].addEventListener("click", function(){
removeTheCover();
}, false);
var buttons2 = document.getElementsByClassName('hdc-button');
buttons2[1].addEventListener("click", function(){
removeTheCover();
}, false);
buttons2[2].addEventListener("click", function(){
removeTheCover();
}, false);
}
function couponCheck(){
var curURL = window.location.href;
console.log("CP Check was called");
if(curURL.split('ebay.in/_sparkrop').length>1){
var imgURL = chrome.extension.getURL("apply-coupon.png");
console.log("TEst passed");
if($('#roProceed2Pay').length>0){
$('#roProceed2Pay').after("<a id='couponClick' href='javascript:void();'><img style='margin-left:65px;' src='" + imgURL + "'></a>");
addToDOM();
var button = document.getElementById("couponClick");
button.addEventListener("click", function(){
getCoupons();
}, false);
}
else {
setTimeout(function(){couponCheck();},1000);
}
}
}
couponCheck();