-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkadowclubBot.js
143 lines (122 loc) · 5 KB
/
kadowclubBot.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
const { Builder, By, Key, until } = require('selenium-webdriver');
const { Options } = require('selenium-webdriver/chrome');
const nodemailer = require('nodemailer');
const smtpConfig = require('./smtp.json');
const sleep = (waitTimeInMs) => new Promise(resolve => setTimeout(resolve, waitTimeInMs));
// Liste de noms masculins et féminins
const names = ["Maxime", "Sophie", "Julien", "Claire", "Guillaume", "Élise", "Mathieu", "Camille", "Nicolas", "Chloé"];
// Sélectionne un nom aléatoirement dans la liste
function getRandomName() {
return names[Math.floor(Math.random() * names.length)];
}
// Utilisation dans la partie de votre code
async function sendEmail(emailaddress, winningText, screenshot) {
let transporter = nodemailer.createTransport({
host: smtpConfig.Smtp.Host,
port: smtpConfig.Smtp.Port,
auth: {
user: smtpConfig.Smtp.Identifiant,
pass: smtpConfig.Smtp.Pass
}
});
let info = await transporter.sendMail({
from: smtpConfig.Smtp.Identifiant,
to: "YourEmail.com",
subject: `Gagné: ${winningText}`,
text: `Adresse Email: ${emailaddress}\nGagné: ${winningText}`,
attachments: [{
filename: 'screenshot.png',
path: './screenshot.png' // Chemin vers le fichier
}]
});
console.log("Message sent: %s", info.messageId);
}
async function MenphisBot() {
// try {
// exec("pkill -f chrome");
// } catch { }
let browser;
try {
let options = new Options();
options.addArguments('user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1');
browser = await new Builder().forBrowser('chrome').setChromeOptions(options).build();
let emailaddress = "";
await browser.get("https://g.kadow.club/?venueId=6299fa4a8232143f18aacb2b&placeName=Memphis%20METZ%20SEMECOURT&utm_source=qrcode");
await sleep(5000);
await browser.findElement(By.xpath("/html/body/div/div[2]/div[3]/a/span")).click();
await sleep(5000);
await browser.findElement(By.xpath("/html/body/div[3]/div/div/div/div/div/div[3]/a/span")).click();
await sleep(5000);
try {
await browser.findElement(By.xpath("/html/body/div[1]/div[2]/div[4]/div[2]/div[4]/div/a")).click();
} catch { }
await sleep(5000);
let tabs = await browser.getAllWindowHandles();
await browser.switchTo().window(tabs[0]);
await sleep(10000);
await browser.findElement(By.xpath("/html/body/div[1]/div[2]/div[2]/div[3]/a/span")).click();
await sleep(30000);
try {
const randomName = getRandomName();
await browser.findElement(By.xpath("/html/body/div[3]/div/div/div/div/div/form/div[1]/div/div/input")).sendKeys(randomName, Key.RETURN);
await sleep(2000);
await browser.executeScript('window.open("newURL");');
let tab = await browser.getAllWindowHandles();
await browser.switchTo().window(tab[2]);
await browser.get("https://www.mohmal.com/fr");
await sleep(5000);
await browser.findElement(By.xpath("/html/body/div[1]/main/div[1]/div[3]/a")).click();
await sleep(5000);
let emailElement = await browser.findElement(By.xpath("/html/body/div/div[1]/div[2]/div[3]/div[1]"));
emailaddress = await emailElement.getAttribute('data-email');
console.log(emailaddress);
} catch (error) {
await browser.quit();
await MenphisBot();
}
await sleep(5000);
await browser.switchTo().window(tabs[0]);
await sleep(3000);
await browser.findElement(By.xpath("/html/body/div[3]/div/div/div/div/div/form/div[2]/div/div/input")).sendKeys(emailaddress, Key.RETURN);
await sleep(3000);
await sleep(5000);
try {
tabs = await browser.getAllWindowHandles();
await browser.switchTo().window(tabs[2]);
} catch (error) {
console.log(error); await browser.quit();
await MenphisBot();
}
await sleep(5000);
await browser.findElement(By.xpath("//html/body/div/div[1]/div[3]/div[2]/div/a")).click();
await sleep(5000);
await browser.findElement(By.xpath("/html/body/div/div[1]/div[6]/table/tbody/tr/td[1]/a")).click();
await sleep(15000);
try {
let pageSource = await browser.getPageSource();
let match = pageSource.match(/vous avez gagné(.*?)!/);
let winningText = match && match[0] ? match[0] : '';
await browser.executeScript("window.scrollBy(0,500)");
let screenshot = await browser.takeScreenshot();
require('fs').writeFileSync('screenshot.png', screenshot, 'base64');
await sendEmail(emailaddress, winningText); // Send email
} catch (e) {
console.log('Erreur lors de la récupération du texte', e);
}
} catch (e) {
await browser.quit();
console.log(e);
await MenphisBot(); // Redémarre la fonction en cas d'erreur
} finally {
if (browser) {
await browser.quit();
await MenphisBot(); // Redémarre la fonction en cas d'erreur
}
}
}
async function main() {
while (true) {
await MenphisBot();
}
}
main().catch(err => console.error(err));