yt-dlp support
This commit is contained in:
23
node_modules/whatsapp-web.js/src/util/Puppeteer.js
generated
vendored
Normal file
23
node_modules/whatsapp-web.js/src/util/Puppeteer.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Expose a function to the page if it does not exist
|
||||
*
|
||||
* NOTE:
|
||||
* Rewrite it to 'upsertFunction' after updating Puppeteer to 20.6 or higher
|
||||
* using page.removeExposedFunction
|
||||
* https://pptr.dev/api/puppeteer.page.removeexposedfunction
|
||||
*
|
||||
* @param {object} page - Puppeteer Page instance
|
||||
* @param {string} name
|
||||
* @param {Function} fn
|
||||
*/
|
||||
async function exposeFunctionIfAbsent(page, name, fn) {
|
||||
const exist = await page.evaluate((name) => {
|
||||
return !!window[name];
|
||||
}, name);
|
||||
if (exist) {
|
||||
return;
|
||||
}
|
||||
await page.exposeFunction(name, fn);
|
||||
}
|
||||
|
||||
module.exports = {exposeFunctionIfAbsent};
|
||||
Reference in New Issue
Block a user