Replace `injectFile` to `injectScript` and add `injectCSS`
See original GitHub issueWhen 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 to injectScript
and also add a injectCSS
method.
Just an idea though 😃.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Replace injectFile to injectScript and add injectCSS #949
CSS injecting seems to be possible when #947 is landed. All reactions.
Read more >Inject CSS stylesheet as string using Javascript
There are a couple of ways this could be done, but the simplest approach is to create a <style> element, set its textContent...
Read more >How To Inject CSS Code Into an HTML Page?
gulp-inject is a plugin to inject stylesheets and javascript references into the HTML file. This will allow us to add a placeholder in...
Read more >puppeteer 0.12.0 on Node.js Yarn
#892 - Add addStyleTag(url) API; #949 - Replace injectFile to injectScript and add injectCSS; #1010 - ElementHandle screenshot does not count padding (or ......
Read more >Create a Chrome Extension to Inject Script | by Piyush Dubey
A guide to creating a chrome extension to inject any script into the client application. Create a Chrome Extension to Inject script.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@vsemozhetbyt
injectFile
injects from file system, whereasaddStyleTag
adds a url. I’d rather unify the two methods since it’s confusing.Something like:
addScriptTag
andaddStyleTag
currently already work with a local file path, that’s what the tests do as well. Not sure if it’s a good idea though, that’s probably the reason whyinjectFile
exists.If we would go with your solution, an object with
url
andpath
, it might be nice to have acontent
option as well.