summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-11-11 01:38:44 +0300
committereug-vs <eug-vs@keemail.me>2020-11-11 01:40:39 +0300
commitb0c94a3d312ae9c417c2f0bcb47392306b6b972d (patch)
tree6a48a27fc726732886fab8ac668e169788c9d32a
parentc687f40c206e1d1f874e91dd396c8d68c64c83f2 (diff)
downloadbsu-fantom-b0c94a3d312ae9c417c2f0bcb47392306b6b972d.tar.gz
feat: provide fillAttendance as onJoin() callback
-rw-r--r--src/attendConference.js3
-rw-r--r--src/index.js16
2 files changed, 13 insertions, 6 deletions
diff --git a/src/attendConference.js b/src/attendConference.js
index 80dc1c5..c2a3de6 100644
--- a/src/attendConference.js
+++ b/src/attendConference.js
@@ -1,9 +1,10 @@
const { clickElementByXPath } = require('./utils.js');
-const attendConference = async page => {
+const attendConference = async (page, onJoin) => {
// Join as "Listen only"
await clickElementByXPath(page, '//span[contains(text(),"Listen only")]');
+ if (typeof(onJoin) === 'function') onJoin();
console.log('Joined the conference');
// Wait 5 seconds
diff --git a/src/index.js b/src/index.js
index 5345587..d240be0 100644
--- a/src/index.js
+++ b/src/index.js
@@ -31,18 +31,24 @@ puppeteer.launch({ headless: true })
page.waitForNavigation() // Wait until the next page loads
]);
- // Launch a meeting
+ // Launch the conference in a new tab
const conferencePagePromise = new Promise(resolve => browser.on(
'targetcreated',
target => resolve(target.page())
));
await clickElementBySelector(page, 'input#join_button_input');
const conferencePage = await conferencePagePromise;
- await attendConference(conferencePage);
- // Fill up the attendance
- await page.goBack();
- await clickElementBySelector(page, 'li.attendance');
+ // Prepare onJoin callback
+ const fillAttendance = async () => {
+ await page.goBack();
+ await clickElementBySelector(page, 'li.attendance');
+ // TODO: actually fill the attendance
+ console.log('Attendance filled');
+ };
+
+ await attendConference(conferencePage, fillAttendance);
+ await browser.close();
})
.catch(e => console.log(e));