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 20, 2022
1 parent 48e1859 commit f46fd75
Showing 1 changed file with 32 additions and 36 deletions.
68 changes: 32 additions & 36 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,47 +29,43 @@ var date = "", convocation = "", res = "", ok = false;
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));
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;
}
convocation = text[text.length - 1];
text.pop()
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;
}

page.keyboard.down('Shift')
page.keyboard.press('Enter')
page.keyboard.up('Shift')

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;
}
}
if (ok) {
page.click("span[data-testid='send']")
ok = false;
}
}
catch (e) {
console.log(e)
}
catch {}
}
}
catch (err) {
Expand Down

0 comments on commit f46fd75

Please sign in to comment.