Inject custom JS scripts
User scripts (aka content scripts) is a powerful tool that unlocks many possibilities such as: content customization, security and privacy protection, enriching web app functionality. Injected scripts can also be a workaround when another WebView feature is not available: for example, due to the lack of granular cookie control in native WebView APIs, one method is to inject a script to augment document.cookie API.
ArkWeb
ArkWeb allows injecting scripts into web documents for execution via the WebviewController.runJavaScript() and WebviewController.runJavaScriptExt() interfaces. It also supports configuring scripts to run at specific events in the web page loading lifecycle using the runJavaScriptOnDocumentStart, runJavaScriptOnDocumentEnd, and runJavaScriptOnHeadEnd properties. Furthermore, developers can register script objects that can be accessed by web pages through the javaScriptProxy property or the WebviewController.registerJavaScriptProxy method. See example.