Skip to content

Instantly share code, notes, and snippets.

@supermarsx
Created September 10, 2020 16:27
Show Gist options
  • Save supermarsx/0b20eb69b81044914b3f02408befbcc1 to your computer and use it in GitHub Desktop.
Save supermarsx/0b20eb69b81044914b3f02408befbcc1 to your computer and use it in GitHub Desktop.
Simple page script injection with puppeteer
/*
pageSimpleScriptInjection
Simple page script injection with puppeteer
parameters
page (object) - Puppeteer page object
*/
async function pageSimpleScriptInjection(page, scriptName) {
scriptName = scriptName || "injectedScript.js";
// Adding injectedScript.js
console.log(`Adding ${scriptName} > (page)`);
await page.addScriptTag({
path: scriptName
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment