-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
41 lines (31 loc) · 1.25 KB
/
script.js
File metadata and controls
41 lines (31 loc) · 1.25 KB
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
let puppeteer = require(`puppeteer`);
let scroll = require(`./scrollToBottom.js`);
let timeGetter = require(`./timeGetter.js`);
let conversions = require(`./conversions.js`);
// let url = `https://www.youtube.com/playlist?list=PLRBp0Fe2GpglTnOLbhyrHAVaWsCIEX53Y`; //long
// let url = `https://www.youtube.com/playlist?list=PL-Jc9J83PIiHQauwBZgwHtUwtwwofqU6Z`;
// let url = `https://www.youtube.com/playlist?list=PL4cUxeGkcC9gfoKa5la9dsdCNpuey2s-V`;
let url = `https://www.youtube.com/playlist?list=PL-Jc9J83PIiFRR58Ezyy2z3gYhPA0lKmt`;
// let url = `https://www.youtube.com/playlist?list=PL-Jc9J83PIiEeD3I4VXETPDmzJ3Z1rWb4`;
let tab;
async function delay(time) {
return new Promise(function(resolve) {
setTimeout(resolve, time)
});
}
(async function fn(){
let browserOpenPromise = puppeteer.launch({
headless: true,
defaultViewport: null,
args: [`--incognito`]
});
let browser = await browserOpenPromise;
let tabs = await browser.pages();
tab = tabs[0];
await tab.goto(url);
await tab.waitForSelector(`body`);
await scroll.fn(tab);
let totalTimeInSeconds = await timeGetter.fn(tab);
console.log(conversions.notation(totalTimeInSeconds));
console.log(totalTimeInSeconds);
})();