Skip to content

Commit

Permalink
MyReadingManga fix webview block (#6617)
Browse files Browse the repository at this point in the history
* MyReadingManga fix bug "Not found"

* MyReadingManga fix bug "Not found" in view-mode
  • Loading branch information
Hayanek authored Dec 18, 2024
1 parent 68b3952 commit 02aefd0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/all/myreadingmanga/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'MyReadingManga'
extClass = '.MyReadingMangaFactory'
extVersionCode = 53
extVersionCode = 54
isNsfw = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Headers
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import org.jsoup.Jsoup
Expand All @@ -29,10 +28,21 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin
// Basic Info
override val name = "MyReadingManga"
final override val baseUrl = "https://myreadingmanga.info"
override val client: OkHttpClient = network.cloudflareClient
override fun headersBuilder(): Headers.Builder =
super.headersBuilder()
.set("User-Agent", USER_AGENT)
.add("X-Requested-With", randomString((1..20).random()))
override val client = network.cloudflareClient.newBuilder()
.addInterceptor { chain ->
val request = chain.request()
val headers = request.headers.newBuilder().apply {
removeAll("X-Requested-With")
}.build()

chain.proceed(request.newBuilder().headers(headers).build())
}
.build()

override val supportsLatest = true

// Popular - Random
Expand Down Expand Up @@ -321,6 +331,11 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin
}

companion object {
private const val USER_AGENT = "Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.230 Mobile Safari/537.36"
private const val USER_AGENT = "Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Mobile Safari/537.36"
}

private fun randomString(length: Int): String {
val charPool = ('a'..'z') + ('A'..'Z')
return List(length) { charPool.random() }.joinToString("")
}
}

0 comments on commit 02aefd0

Please sign in to comment.