forked from y-t-bot/youtube-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
24 lines (19 loc) · 762 Bytes
/
index.js
File metadata and controls
24 lines (19 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const { chromium } = require("playwright");
require("dotenv").config();
(async () => {
const browser = await chromium.launch({ headless: false });
const context = await browser.newContext({
proxy: process.env.PROXY ? { server: process.env.PROXY } : undefined,
});
const page = await context.newPage();
console.log("[INFO] Navigating to YouTube...");
await page.goto("https://youtube.com");
// Example action: search and play a video
await page.fill("input#search", "lofi hip hop radio");
await page.keyboard.press("Enter");
await page.waitForTimeout(3000);
await page.click("ytd-video-renderer a#thumbnail");
console.log("[INFO] Playing video...");
await page.waitForTimeout(15000); // watch 15s
await browser.close();
})();