-
Notifications
You must be signed in to change notification settings - Fork 0
/
c2.js
227 lines (180 loc) · 7.07 KB
/
c2.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
//alert("ahahah")
$( document ).ready(function() {
WritetoMemory()
ReadfromMemory()
ProductcolorRequest()
Findproduct()
clearData()
})
function ReadfromMemory(){
//name read
chrome.storage.local.get(['name'], function(result) {
document.getElementById("order_billing_name").value = result.name
});
//email read
chrome.storage.local.get(['email'], function(result) {
document.getElementById("order_email").value = result.email
});
//phone read
chrome.storage.local.get(['phone'], function(result) {
document.getElementById("order_tel").value = result.phone
});
//address read
chrome.storage.local.get(['address'], function(result) {
document.getElementById("bo").value = result.address
});
//zip read
chrome.storage.local.get(['zip'], function(result) {
document.getElementById("order_billing_zip").value = result.zip
});
//city read
chrome.storage.local.get(['city'], function(result) {
document.getElementById("order_billing_city").value = result.city
});
//state read
chrome.storage.local.get(['state'], function(result) {
document.getElementById("order_billing_state").value = result.state
});
//country read
chrome.storage.local.get(['country'], function(result) {
document.getElementById("order_billing_country").value = result.country
});
//credit card read
chrome.storage.local.get(['ccnum'], function(result) {
document.getElementById("rnsnckrn").value = result.ccnum
});
//exp mon read
chrome.storage.local.get(['expmon'], function(result) {
document.getElementById("credit_card_month").value = result.expmon
});
//exp year read
chrome.storage.local.get(['expyear'], function(result) {
document.getElementById("credit_card_year").value = result.expyear
});
//cvv read
chrome.storage.local.get(['cvv'], function(result) {
document.getElementById("orcer").value = result.cvv
});
}
function WritetoMemory(){
$('#btn').click(function(){
//reload page once save data is hit
document.getElementById('btn').addEventListener('click', chrome.tabs.reload());
//name write
chrome.storage.local.set({'name': document.getElementById("order_billing_name").value = $("#order_billing_name").val()}, function() {
});
//email write
chrome.storage.local.set({'email': document.getElementById("order_email").value = $("#order_email").val()}, function() {
});
//phone write
chrome.storage.local.set({'phone': document.getElementById("order_tel").value = $("#order_tel").val()}, function() {
});
//address write
chrome.storage.local.set({'address': document.getElementById("bo").value = $("#bo").val()}, function() {
});
//zip write
chrome.storage.local.set({'zip': document.getElementById("order_billing_zip").value = $("#order_billing_zip").val()}, function() {
});
//city write
chrome.storage.local.set({'city': document.getElementById("order_billing_city").value = $("#order_billing_city").val()}, function() {
});
//state write
chrome.storage.local.set({'state': document.getElementById("order_billing_state").value = $("#order_billing_state").val()}, function() {
});
//country write
chrome.storage.local.set({'country': document.getElementById("order_billing_country").value = $("#order_billing_country").val()}, function() {
});
//credit card write
chrome.storage.local.set({'ccnum': document.getElementById("rnsnckrn").value = $("#rnsnckrn").val()}, function() {
});
//exp month write
chrome.storage.local.set({'expmon': document.getElementById("credit_card_month").value = $("#credit_card_month").val()}, function() {
});
//exp year write
chrome.storage.local.set({'expyear': document.getElementById("credit_card_year").value = $("#credit_card_year").val()}, function() {
});
//cvv write
chrome.storage.local.set({'cvv': document.getElementById("orcer").value = $("#orcer").val()}, function() {
});
});
}
function ProductcolorRequest(){
$("#submit_req").click(function(){
document.getElementById('submit_req').addEventListener('click', chrome.tabs.reload());
chrome.storage.local.set({'product': $("#productreq").val()}, function() {
});
chrome.storage.local.set({'color': $("#colorreq").val()}, function() {
});
chrome.storage.local.set({'type': $("#type").val()}, function() {
});
chrome.storage.local.set({'size': $("#size").val()}, function() {
});
chrome.storage.local.get(['type'], function(result) {
newUrl = 'https://www.supremenewyork.com/shop/all/'+result.type;
window.open(newUrl)
});
});
}
function clearData(){
//clear all data
$("#clear").click(function(){
document.getElementById('clear').addEventListener('click', chrome.tabs.reload());
chrome.storage.local.clear(function() {
var error = chrome.runtime.lastError;
if (error) {
console.error(error);
}
});
})
}
var i;
i = setInterval(Findproduct(), 500);
if (window.location.href.indexOf("/all") > -1) {
//click the first item
window.location.href = $("a.name-link").attr("href");
}
function Findproduct(){
var Currentitem = $(".protect").html()
var Currentcolor = $("button.selected").attr('data-style-name');
//var size =
chrome.storage.local.get(['product', 'color', 'size'], function(result) {
if(Currentitem.includes(result.product) && Currentcolor == result.color){
var run = false;
$('option').filter(function() {
return ($(this).text() == result.size); //To select Blue
}).prop('selected', true);
//chrome.runtime.sendMessage("Found Item: "+ Currentitem);
if($("input.button").val() == "add to cart"){
$("input.button").click()
run = true;
//chrome.runtime.sendMessage("Added to cart");
if(run==true){
chrome.runtime.sendMessage("Added to cart: \n"+ "------------------------------ \n"+ "Item: " + Currentitem + "\n" + "Color:" + Currentcolor + "\n" + "Size:" + result.size);
setTimeout(checkout, 1000)
}
}
//clear timeout
window.clearInterval(i);
//if name is correct but color is not:
}else if(Currentitem.includes(result.product) && Currentcolor != result.color){
//move to next color
$("button[data-style-name='"+result.color+"']").click()
location.reload();
//if color is correct but name is not:
}else {
//move to next item
$('.next')[0].click();
location.reload();
}
});
}
setTimeout(Checkoutform, 2000)
function checkout(){
$(".button.checkout")[0].click()
}
function Checkoutform(){
if (window.location.href.indexOf("/checkout") > -1) {
$('#order_terms').attr('checked',true)
$(".button")[0].click()
}
}