New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace injectFile
to injectScript
and add injectCSS
#949
Comments
CSS injecting seems to be possible when #947 is landed. |
@vsemozhetbyt Something like: page.addScriptTag({
url: '...', // either URL or PATH could be specified
path: '..',
}); |
If we would go with your solution, an object with page.addScriptTag({
url: '...',
path: '..',
content: `document.write('Hello World')`
}); |
@aslushnikov Let me know what the preferred path forward is for this. Happy to do a PR to fix this. |
@SamVerschueren Your suggestion with url/path/content options sounds good to me: page.addScriptTag({
url: '...',
path: '..',
content: `document.write('Hello World')`
}); if you have time, I'd be happy to review a PR. (note: please make sure to use sourceURL for the 'content' option of the addScriptTag/addStyleTag methods). If you're short on time, I'd rather do it myself: this is one of the bugs that we'd like to have closed soon. |
I'll try to work on it today. Can you elaborate on
Or do you mean
|
That's right, I meant |
PR send! |
…peteer#996) This patch: - deprecates injectFile as it was confused with the addScriptTag - accepts an options object in addScriptTag which supports properties url, path and content. - accepts an options object in addStyleTag which supports properties url, path and content. Fixes puppeteer#949. BREAKING CHANGE: - the addStyleTag/addScriptTag have changed; - the injectFile was removed in favor of (addStyleTag({path:}).
When browsing trough the docs and using the API, I noticed that Puppeteer has an
injectFile
method. The name might be confusing, because you might think it works for a CSS file as well. I think it would be better to rename this method toinjectScript
and also add ainjectCSS
method.Just an idea though :).
The text was updated successfully, but these errors were encountered: