mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 01:51:51 +01:00
[Cloudflare] Fix SyntaxError due to recent js challenge changes. (#1876)
From Anorov/cloudflare-scrape#193 Related issues: inorichi/tachiyomi-extensions#894
This commit is contained in:
parent
3f2d375a53
commit
10e1106760
@ -1,11 +1,7 @@
|
|||||||
package eu.kanade.tachiyomi.network
|
package eu.kanade.tachiyomi.network
|
||||||
|
|
||||||
import com.squareup.duktape.Duktape
|
import com.squareup.duktape.Duktape
|
||||||
import okhttp3.CacheControl
|
import okhttp3.*
|
||||||
import okhttp3.HttpUrl
|
|
||||||
import okhttp3.Interceptor
|
|
||||||
import okhttp3.Request
|
|
||||||
import okhttp3.Response
|
|
||||||
|
|
||||||
class CloudflareInterceptor : Interceptor {
|
class CloudflareInterceptor : Interceptor {
|
||||||
|
|
||||||
@ -48,18 +44,18 @@ class CloudflareInterceptor : Interceptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val js = operation
|
val js = operation
|
||||||
.replace(Regex("""a\.value = (.+ \+ t\.length).+"""), "$1")
|
.replace(Regex("""a\.value = (.+ \+ t\.length(\).toFixed\(10\))?).+"""), "$1")
|
||||||
.replace(Regex("""\s{3,}[a-z](?: = |\.).+"""), "")
|
.replace(Regex("""\s{3,}[a-z](?: = |\.).+"""), "")
|
||||||
.replace("t.length", "${domain.length}")
|
.replace("t.length", "${domain.length}")
|
||||||
.replace("\n", "")
|
.replace("\n", "")
|
||||||
|
|
||||||
val result = duktape.evaluate(js) as Double
|
val result = duktape.evaluate(js) as String
|
||||||
|
|
||||||
val cloudflareUrl = HttpUrl.parse("${url.scheme()}://$domain/cdn-cgi/l/chk_jschl")!!
|
val cloudflareUrl = HttpUrl.parse("${url.scheme()}://$domain/cdn-cgi/l/chk_jschl")!!
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.addQueryParameter("jschl_vc", challenge)
|
.addQueryParameter("jschl_vc", challenge)
|
||||||
.addQueryParameter("pass", pass)
|
.addQueryParameter("pass", pass)
|
||||||
.addQueryParameter("jschl_answer", "$result")
|
.addQueryParameter("jschl_answer", result)
|
||||||
.toString()
|
.toString()
|
||||||
|
|
||||||
val cloudflareHeaders = originalRequest.headers()
|
val cloudflareHeaders = originalRequest.headers()
|
||||||
|
Loading…
Reference in New Issue
Block a user