Hi @Mike Bruggs
Probably Discord damaged your code, but I tried:
// await page.waitForSelector('ytd-watch-flexy', { timeout: 10000 }); // Adjust the selector and timeout as necessary
console.log(`Page is ready for processing:`);
console.log("fdsfds");
// Execute JS in the page context to find the caption URL
const captionUrl = await page.evaluate(() => {
const scripts = Array.from(document.querySelectorAll('script'));
for (const script of scripts) {
const match = script.textContent?.match(/https:\/\/www.youtube.com\/api\/timedtext?[^"]+/);
if (match) {
return match[0];
}
}
return null;
});
console.log("fdsfds", captionUrl);
if (captionUrl) {
console.log(`Found caption URL: ${captionUrl}`);
console.log("jhdgfjdfdsfds");
console.log({
url: request.loadedUrl,
title: await page.title(),
captionUrl,
});
console.log("g7fd8sgfdsfds");
} else {
console.log(`No caption URL found on ${request.loadedUrl}`);
}
In my Puppeteer extension and it woked well