|
|
|
|
@ -38,6 +38,7 @@ public class CustomWebView extends WebView { |
|
|
|
|
private AlertDialog dialog; |
|
|
|
|
private Runnable timer; |
|
|
|
|
private String from; |
|
|
|
|
private boolean sub; |
|
|
|
|
private String key; |
|
|
|
|
|
|
|
|
|
public static CustomWebView create(@NonNull Context context) { |
|
|
|
|
@ -72,13 +73,14 @@ public class CustomWebView extends WebView { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public CustomWebView start(String key, String from, Map<String, String> headers, String url, ParseCallback callback) { |
|
|
|
|
public CustomWebView start(String key, String from, Map<String, String> headers, String url, ParseCallback callback, boolean sub) { |
|
|
|
|
App.post(timer, Constant.TIMEOUT_PARSE_WEB); |
|
|
|
|
this.callback = callback; |
|
|
|
|
setUserAgent(headers); |
|
|
|
|
loadUrl(url, headers); |
|
|
|
|
this.from = from; |
|
|
|
|
this.key = key; |
|
|
|
|
this.sub = sub; |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -88,10 +90,11 @@ public class CustomWebView extends WebView { |
|
|
|
|
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { |
|
|
|
|
String url = request.getUrl().toString(); |
|
|
|
|
String host = request.getUrl().getHost(); |
|
|
|
|
if (TextUtils.isEmpty(host) || ApiConfig.get().getAds().contains(host)) return empty; |
|
|
|
|
if (url.contains("challenges.cloudflare.com/cdn-cgi/")) App.post(() -> showDialog()); |
|
|
|
|
Map<String, String> headers = request.getRequestHeaders(); |
|
|
|
|
if (isVideoFormat(headers, url)) interrupt(headers, url); |
|
|
|
|
if (TextUtils.isEmpty(host) || ApiConfig.get().getAds().contains(host)) return empty; |
|
|
|
|
if (url.contains("challenges.cloudflare.com/cdn-cgi")) App.post(() -> showDialog()); |
|
|
|
|
if (sub && url.contains("player/?url=")) onParseAdd(headers, url); |
|
|
|
|
else if (isVideoFormat(headers, url)) interrupt(headers, url); |
|
|
|
|
return super.shouldInterceptRequest(view, request); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -152,6 +155,10 @@ public class CustomWebView extends WebView { |
|
|
|
|
onParseSuccess(headers, url); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void onParseAdd(Map<String, String> headers, String url) { |
|
|
|
|
App.post(() -> CustomWebView.create(App.get()).start(key, from, headers, url, callback, false)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void onParseSuccess(Map<String, String> headers, String url) { |
|
|
|
|
if (callback != null) callback.onParseSuccess(headers, url, from); |
|
|
|
|
App.post(() -> stop(false)); |
|
|
|
|
|