parsifal/index.mts

48 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-09-15 17:04:35 +02:00
import puppeteer from "puppeteer";
2024-09-17 21:08:41 +02:00
import { readFileSync } from "fs";
2024-09-17 21:02:25 +02:00
import pino from "pino";
const logger = pino({
level: "debug",
});
2024-09-15 17:04:35 +02:00
2024-09-17 21:02:25 +02:00
logger.info("Starting the browser");
2024-09-15 17:04:35 +02:00
const browser = await puppeteer.launch({
headless: false, // Show the browser window
defaultViewport: null, // Don't limit the viewport
args: ["--use-fake-ui-for-media-stream"], // Avoid asking for microphone and camera permissions
});
2024-09-17 21:02:25 +02:00
logger.debug("Browser started, opening the page");
2024-09-15 17:04:35 +02:00
const page = await browser
.pages()
.then((pages) => pages[0] || browser.newPage());
2024-09-18 23:10:28 +02:00
await page.goto("https://meet.freifunk-aachen.de/parsifalove");
logger.debug("Joining meeting");
await page.click('[aria-label="Join meeting"]');
2024-09-15 17:04:35 +02:00
2024-09-17 21:02:25 +02:00
logger.trace("Waiting for the room to load");
2024-09-15 17:04:35 +02:00
await page.waitForSelector("body");
2024-09-17 21:02:25 +02:00
logger.debug("Requesting fullscreen");
2024-09-15 17:04:35 +02:00
await page.evaluate(() => {
document.querySelector("body")!.requestFullscreen();
});
2024-09-17 21:08:41 +02:00
logger.debug("Injecting CSS");
await page.addStyleTag({
content: readFileSync("jitsi-hide.css", "utf-8"),
});
2024-09-17 21:08:57 +02:00
logger.info("All done.");
2024-09-15 17:04:35 +02:00
browser.on("disconnected", () => {
2024-09-17 21:02:25 +02:00
logger.info("Browser disconnected, exiting");
2024-09-15 17:04:35 +02:00
process.exit(0);
});
setInterval(async () => {
if ((await browser.pages()).length === 0) {
2024-09-17 21:02:25 +02:00
logger.info("No pages left, exiting");
2024-09-15 17:04:35 +02:00
process.exit(0);
}
}, 1000);