I have used page.addScriptTag
to inject js
files.
...
await page.addScriptTag({url: 'https://code.jquery.com/jquery-3.2.1.min.js'})
...
page.addScriptTag - documentation
Working example using puppeteer: 0.12.0
import { launch } from 'puppeteer'
(async () => {
const browser = await launch({headless: false});
const page = await browser.newPage();
await page.goto('https://example.com', {waitUntil: 'networkidle'});
await page.addScriptTag({url: 'https://code.jquery.com/jquery-3.2.1.min.js'});
await page.close();
await browser.close();
})();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…