Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jasiukiewicztymon authored Mar 19, 2022
1 parent d361291 commit 48e1859
Showing 1 changed file with 37 additions and 26 deletions.
63 changes: 37 additions & 26 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function sleep(milliseconds) {
}

// datas
var date = "", convocation = "", res = "";
var date = "", convocation = "", res = "", ok = false;

(async () => {
try {
Expand All @@ -28,34 +28,45 @@ var date = "", convocation = "", res = "";
try {
await page.waitForSelector('strong');
const text = await page.evaluate(() => Array.from(document.querySelectorAll('strong')[document.querySelectorAll('strong').length - 1].parentElement.querySelectorAll('strong'), element => element.textContent));
for (var j = 0; j < text.length; j++) {
convocation = text[j];
date = convocation.substr((convocation.indexOf('.') - 2), 5)
if (!data.date.includes(date)) {
for (var i = 0; i < data.place.length; i++) {
e = data.place[i];
if (convocation.toLowerCase().includes(e)) {
(async function type() {
res = date + " " + e + ", " + data.name + " dispo"

for (var j = 0; j < res.length; j++) {
page.keyboard.press(res[j]);
}

try {
page.click("span[data-testid='send']")
}
catch {}

data.date.push(date);
fs.writeFile('./data.json', JSON.stringify(data), function writeJSON(err) {
if (err) return console.log(err);
});
})();
break;
while (text.length != 0) {
for (var i = 0; i < text.length; i++) {
if (i == 0)
break;
convocation = text[0];
text.shift()
date = convocation.substr((convocation.indexOf('.') - 2), 5)
if (!data.date.includes(date)) {
for (var i = 0; i < data.place.length; i++) {
e = data.place[i];
if (convocation.toLowerCase().includes(e)) {
(async function type() {
res = date + " " + e + ", " + data.name + " dispo"

for (var j = 0; j < res.length; j++) {
page.keyboard.press(res[j]);
ok = true;
}

try {
page.click("span[data-testid='send']")
}
catch {}

data.date.push(date);
fs.writeFile('./data.json', JSON.stringify(data), function writeJSON(err) {
if (err) return console.log(err);
});
})();
break;
}
}
}
}

if (ok) {
page.keyboard.press('Enter');
ok = false;
}
}
}
catch {}
Expand Down

0 comments on commit 48e1859

Please sign in to comment.