gpt4 book ai didi

javascript - 是否可以使用 webview 注入(inject)我的 javascript 以在任何网页内禁用 javascript?

转载 作者:行者123 更新时间:2023-11-30 00:38:06 25 4
gpt4 key购买 nike

我正在为我的自定义浏览器开发断开连接或 firefox 中的 ghosty 插件,以停止各种网页内的一些跟踪脚本,但未能找到任何帮助来禁用在 webview 中加载的所有网页内的跟踪。

经过一些搜索,我找到了通过从要加载的网页中删除脚本来停止跟踪的方法。但未能找到解决方案以从加载到 webview 中删除所有这些脚本,请帮忙..

最佳答案

好的,所以我找到了在 WebViewClient 的方法 shouldInterceptRequest 的帮助下仅阻止加载页面中的一些 javascript 的解决方案我使用简单的返回空响应,没有任何数据像文档中写的那样像往常一样加载。

Notify the host application of a resource request and allow the application to return the data. If the return value is null, the WebView will continue to load the resource as usual. Otherwise, the return response and data will be used. NOTE: This method is called on a thread other than the UI thread so clients should exercise caution when accessing private data or the view system.

public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
if(myConditionFullFilled){
return new WebResourceResponse("text/css", "UTF-8", null);
}
return super.shouldInterceptRequest(view, url);
}

关于javascript - 是否可以使用 webview 注入(inject)我的 javascript 以在任何网页内禁用 javascript?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43066272/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com