Created
September 10, 2020 16:27
-
-
Save supermarsx/0b20eb69b81044914b3f02408befbcc1 to your computer and use it in GitHub Desktop.
Simple page script injection with puppeteer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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