-
Notifications
You must be signed in to change notification settings - Fork 863
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
Feat: added a new parameter -js to javascript injection in headless #2066
base: dev
Are you sure you want to change the base?
Conversation
httpx v1.6.9 release prep
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.27.0 to 0.31.0. - [Commits](golang/crypto@v0.27.0...v0.31.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
…abot/go_modules/golang.org/x/crypto-0.31.0
@michael2to3 thank you for the PR, can you please create issue and link back to this PR with information including use case and example. |
Well done: #2067 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should execute if the flag isn't an empty string, regardless of whether the user uses the -ss
/-screenshot
flag. There should also be a dedicated method for this, separate from the ScreenshotWithBody
method (something like EvalJavaScript
, etc.). It should run after the DOM Content Loaded page lifecycle event.
@@ -390,6 +392,7 @@ func ParseOptions() *Options { | |||
flagSet.BoolVarP(&options.NoHeadlessBody, "exclude-headless-body", "ehb", false, "enable excluding headless header from json output"), | |||
flagSet.DurationVarP(&options.ScreenshotTimeout, "screenshot-timeout", "st", 10*time.Second, "set timeout for screenshot in seconds"), | |||
flagSet.DurationVarP(&options.ScreenshotIdle, "screenshot-idle", "sid", 1*time.Second, "set idle time before taking screenshot in seconds"), | |||
flagSet.StringSliceVarP(&options.JavascriptInject, "javascript-inject", "js", nil, "set javascript to inject", goflags.StringSliceOptions), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flagSet.StringSliceVarP(&options.JavascriptInject, "javascript-inject", "js", nil, "set javascript to inject", goflags.StringSliceOptions), | |
flagSet.StringSliceVarP(&options.JavascriptInject, "javascript-code", "jsc", nil, "execute JavaScript code after DOM content loaded", goflags.StringSliceOptions), |
Now the
-js
and--javascript-inject
options execute code in the session browser without a head to change, for example, "local storage` or any other scriptsExample:
index.html
t.js tt.js ttt.js
If something needs improvement, then write, I am open to change