ReaperScans(en): Fix webview block (#3139)

Fix webview
This commit is contained in:
bapeey 2024-05-20 05:52:23 -05:00 committed by Draff
parent 86e45b2678
commit 934ca4a97f
2 changed files with 16 additions and 1 deletions

View File

@ -1,7 +1,7 @@
ext {
extName = 'Reaper Scans'
extClass = '.ReaperScans'
extVersionCode = 48
extVersionCode = 49
}
apply from: "$rootDir/common.gradle"

View File

@ -53,8 +53,18 @@ class ReaperScans : ParsedHttpSource() {
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
.rateLimit(1, 2, TimeUnit.SECONDS)
.addInterceptor { chain ->
val request = chain.request()
val headers = request.headers.newBuilder()
.removeAll("X-Requested-With")
.build()
chain.proceed(request.newBuilder().headers(headers).build())
}
.build()
override fun headersBuilder(): Headers.Builder = super.headersBuilder()
.set("X-Requested-With", randomString((1..20).random())) // For WebView, removed in interceptor
// Popular
override fun popularMangaRequest(page: Int) = GET("$baseUrl/comics?page=$page", headers)
@ -336,6 +346,11 @@ class ReaperScans : ParsedHttpSource() {
private fun Elements.imgAttr(): String = this.first()!!.imgAttr()
private fun randomString(length: Int): String {
val charPool = ('a'..'z') + ('A'..'Z')
return List(length) { charPool.random() }.joinToString("")
}
// Unused
override fun searchMangaNextPageSelector() = throw UnsupportedOperationException()