-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscriptps5.js
60 lines (55 loc) · 1.79 KB
/
scriptps5.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
const axios = require("axios");
const nodemailer = require("nodemailer");
const smtpTransport = require("nodemailer-smtp-transport");
const transporter = nodemailer.createTransport(
smtpTransport({
service: "Gmail",
auth: {
user: "[email protected]",
pass: "YourPass",
},
})
);
// hashtag #preorder in subject for ifttt trigger
const mailOptions = {
from: "[email protected]",
to: "[email protected]",
subject: "#preorderPS5 kravitz open the pre-order of the PS5",
text: "kravitz open the pre-order",
};
const mailList = ["[email protected]", "[email protected]"];
const urlNintedo =
"https://www.kravitz.co.il/10024224-%D7%A7%D7%95%D7%A0%D7%A1%D7%95%D7%9C%D7%94-ni" +
"ntendo-swtich-v1-1#";
const urlPs5 =
"https://www.kravitz.co.il/10032968-%D7%A7%D7%95%D7%A0%D7%A1%D7%95%D7%9C%D7%94-so" +
"ny-ps5";
const addToCart = "button action primary tocart sprite";
async function makeGetRequest() {
let res = await axios.get(urlPs5);
if (res.status >= 200 && res.status < 300) {
console.log(`status is ${res.statusText}, status number is ${res.status}`);
if (res.data.toLowerCase().includes(addToCart.toLowerCase())) {
//pre order open
console.log(`there is "add to cart" now`);
// send mail
mailList.forEach((address) => {
mailOptions.to = address;
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
console.log(error);
} else {
console.log("Email sent: " + info.response);
}
});
});
} else {
console.log(`still no "add to cart"`);
}
} else {
console.log(
`bad status, status is ${res.statusText}, status number is ${res.status}`
);
}
}
setInterval(makeGetRequest, 10000);