parsifal/index.mts
2024-09-18 23:10:28 +02:00

47 lines
1.3 KiB
TypeScript

import puppeteer from "puppeteer";
import { readFileSync } from "fs";
import pino from "pino";
const logger = pino({
level: "debug",
});
logger.info("Starting the browser");
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
});
logger.debug("Browser started, opening the page");
const page = await browser
.pages()
.then((pages) => pages[0] || browser.newPage());
await page.goto("https://meet.freifunk-aachen.de/parsifalove");
logger.debug("Joining meeting");
await page.click('[aria-label="Join meeting"]');
logger.trace("Waiting for the room to load");
await page.waitForSelector("body");
logger.debug("Requesting fullscreen");
await page.evaluate(() => {
document.querySelector("body")!.requestFullscreen();
});
logger.debug("Injecting CSS");
await page.addStyleTag({
content: readFileSync("jitsi-hide.css", "utf-8"),
});
logger.info("All done.");
browser.on("disconnected", () => {
logger.info("Browser disconnected, exiting");
process.exit(0);
});
setInterval(async () => {
if ((await browser.pages()).length === 0) {
logger.info("No pages left, exiting");
process.exit(0);
}
}, 1000);