-
Notifications
You must be signed in to change notification settings - Fork 51
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
[Feature]: Control script injection for individual frames #4375
Labels
feature request
feature request
Comments
Have you checked icorewebview2frame2::ExecuteScript ? |
Sorry I forgot to add this information: I'm on .NET, ExecuteScript only has an asynchronous wrapper. |
I did a super hacky workaround where the injected script fetches the actual scripts from a host object and runs them with |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the feature/enhancement you need
I'd like to be able to inject different scripts into individual frames. An
AddScriptToExecuteOnDocumentCreatedAsync
method forCoreWebView2Frame
might be sufficient. I'm using WebView2 in a .NET WPF app via theMicrosoft.Web.WebView2
package.The scenario/use case where you would use this feature
I'm injecting scripts that contain a subscriber ID and access token for the page, as well as JS code that uses this information for connecting to a backend service. However, I want the scripts to be different for each iframe because I want to treat them as unique subscribers. Some scripts I want to inject to the top level frame only, to avoid information leakage in case that top level frame loads some external page. The behavior and API for injecting scripts should be the same for windows created with
window.open()
and iframes.How important is this request to you?
Impactful. My app's user experience would be significantly compromised without it.
Suggested implementation
No response
What does your app do? Is there a pending deadline for this request?
I'm currently experimenting with various WV2 methods and events, my working theory is this:
FrameCreated
event handlerFrameNavigationStarting
event handler, and start a sequence when I inject scripts and then navigate the frame - unfortunately there's no reference to the frame in the event args, so this is probably a dead end.The text was updated successfully, but these errors were encountered: