In daily work, we need to injects the specified script into the webpage’s content at a specific time for advanced customization features. For example, network requests monitor, custom css for element, performance data collection.
For different features, we want to control code's injection time(document start, document end), control that whether to inject the script into the main frame or all frames. Perhaps we want to control injected document, only inject javascrip for one party website.
Stakeholders
Stakeholders include:
WebView provider: Apple, Google, deciders on how to enhance WebView's user script injection capability.
WebView user: Native Business rely on WebView to build advanced customization features by javascript.
End user: Users of the App indirectly using the Features implemented by WebView.
Analysis
WKUserScript in WKWebView provide develop with user script injection capability.
It's hard to use android WebView to inject javascript before html loaded.
We cannot unregister WKUserScript or control injected website in WKWebView.
Related W3C deliverables and/or work items
Perhaps the specification could mandate that all WebViews must provide develop with user script injection capability.
How is the issue solved in the Browser, and what’s more is needed?
In Safari, we can inject a script that we have written from a Safari app extension into a webpage. Injecting a Script into a Webpage
Maybe, user script can communicate with other user script.
UserScript injection in WebView
Submitter(s)
Jiasheng Wu
Motivation
In daily work, we need to injects the specified script into the webpage’s content at a specific time for advanced customization features. For example, network requests monitor, custom css for element, performance data collection. For different features, we want to control code's injection time(document start, document end), control that whether to inject the script into the main frame or all frames. Perhaps we want to control injected document, only inject javascrip for one party website.
Stakeholders
Stakeholders include:
WebView provider: Apple, Google, deciders on how to enhance WebView's user script injection capability. WebView user: Native Business rely on WebView to build advanced customization features by javascript. End user: Users of the App indirectly using the Features implemented by WebView.
Analysis
WKUserScript in WKWebView provide develop with user script injection capability. It's hard to use android WebView to inject javascript before html loaded. We cannot unregister WKUserScript or control injected website in WKWebView.
Related W3C deliverables and/or work items
Perhaps the specification could mandate that all WebViews must provide develop with user script injection capability.
How is the issue solved in the Browser, and what’s more is needed?