|
|
|
|
@ -32,7 +32,7 @@ import com.orhanobut.logger.Logger; |
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.LinkedHashSet; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
@ -43,10 +43,11 @@ public class CustomWebView extends WebView implements DialogInterface.OnDismissL |
|
|
|
|
|
|
|
|
|
private static final Pattern PLAYER = Pattern.compile("player/.*[?&][^=&]+=https?://"); |
|
|
|
|
private static final String BLANK = "about:blank"; |
|
|
|
|
private static final int MAX_URLS = 5; |
|
|
|
|
|
|
|
|
|
private LinkedHashSet<String> urls; |
|
|
|
|
private WebResourceResponse empty; |
|
|
|
|
private ParseCallback callback; |
|
|
|
|
private HashSet<String> urls; |
|
|
|
|
private WebDialog dialog; |
|
|
|
|
private Runnable timer; |
|
|
|
|
private boolean detect; |
|
|
|
|
@ -66,8 +67,8 @@ public class CustomWebView extends WebView implements DialogInterface.OnDismissL |
|
|
|
|
|
|
|
|
|
@SuppressLint("SetJavaScriptEnabled") |
|
|
|
|
public void initSettings() { |
|
|
|
|
this.urls = new HashSet<>(); |
|
|
|
|
this.timer = () -> stop(true); |
|
|
|
|
this.urls = new LinkedHashSet<>(); |
|
|
|
|
this.empty = new WebResourceResponse("text/plain", "utf-8", new ByteArrayInputStream("".getBytes())); |
|
|
|
|
getSettings().setSupportZoom(true); |
|
|
|
|
getSettings().setUseWideViewPort(true); |
|
|
|
|
@ -117,8 +118,8 @@ public class CustomWebView extends WebView implements DialogInterface.OnDismissL |
|
|
|
|
String host = request.getUrl().getHost(); |
|
|
|
|
if (TextUtils.isEmpty(host) || isAd(host)) return empty; |
|
|
|
|
Map<String, String> headers = request.getRequestHeaders(); |
|
|
|
|
if (url.contains("challenges.cloudflare.com/turnstile")) App.post(() -> showDialog()); |
|
|
|
|
if (detect && PLAYER.matcher(url).find() && urls.add(url)) onParseAdd(headers, url); |
|
|
|
|
if (url.contains("/cdn-cgi/challenge-platform/")) App.post(() -> showDialog()); |
|
|
|
|
if (detect && PLAYER.matcher(url).find() && addUrl(url)) onParseAdd(headers, url); |
|
|
|
|
else if (isVideoFormat(url)) onParseSuccess(headers, url); |
|
|
|
|
return super.shouldInterceptRequest(view, request); |
|
|
|
|
} |
|
|
|
|
@ -143,6 +144,11 @@ public class CustomWebView extends WebView implements DialogInterface.OnDismissL |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean addUrl(String url) { |
|
|
|
|
if (urls.size() > MAX_URLS) urls.clear(); |
|
|
|
|
return urls.add(url); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void showDialog() { |
|
|
|
|
if (dialog != null || App.activity() == null) return; |
|
|
|
|
if (getParent() != null) ((ViewGroup) getParent()).removeView(this); |
|
|
|
|
|