1const puppeteer = require('puppeteer');
2
3(async() => {
4 const browser = await puppeteer.launch();
5 const page = await browser.newPage();
6 await page.exposeFunction('onCustomEvent', text => console.log(text));
7 await page.goto('https://www.time.ir', {waitUntil: 'networkidle0'});
8 await page.evaluate(() => {
9 $('#digitalClock').bind("DOMSubtreeModified", function(e) {
10 window.onCustomEvent(e.currentTarget.textContent.trim());
11 });
12 });
13})();