Skip to content

Commit

Permalink
Mangas Chan: Fix Cloudflare block (#637)
Browse files Browse the repository at this point in the history
* Mangas Chan: Fix Cloudflare block

* Add an interceptor to remove X-Requested-With

* use CharArray instead of List

Co-authored-by: stevenyomi <[email protected]>

---------

Co-authored-by: stevenyomi <[email protected]>
  • Loading branch information
beer-psi and stevenyomi authored Jan 25, 2024
1 parent 2fbb72c commit b49c115
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions multisrc/overrides/mangathemesia/mangaschan/src/MangasChan.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,28 @@ class MangasChan : MangaThemesia(
) {

override val client: OkHttpClient = super.client.newBuilder()
.addInterceptor { chain ->
val request = chain.request()
val headers = request.headers.newBuilder()
.removeAll("X-Requested-With")
.build()

chain.proceed(request.newBuilder().headers(headers).build())
}
.rateLimit(1, 2, TimeUnit.SECONDS)
.build()

override fun headersBuilder() = super.headersBuilder()
.set("X-Requested-With", randomString((10..20).random()))

override val altNamePrefix = "Nomes alternativos: "

override val seriesArtistSelector = ".tsinfo .imptdt:contains(Artista) > i"
override val seriesAuthorSelector = ".tsinfo .imptdt:contains(Autor) > i"
override val seriesTypeSelector = ".tsinfo .imptdt:contains(Tipo) > a"

private fun randomString(length: Int): String {
val charPool = ('a'..'z') + ('A'..'Z')
return CharArray(length) { charPool.random() }.concatToString()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class MangaThemesiaGenerator : ThemeSourceGenerator {
SingleLang("MangaTale", "https://mangatale.co", "id", overrideVersionCode = 2),
SingleLang("MangaWT", "https://mangawt.com", "tr", overrideVersionCode = 5),
SingleLang("Mangayaro", "https://www.mangayaro.id", "id", overrideVersionCode = 1),
SingleLang("Mangás Chan", "https://mangaschan.net", "pt-BR", className = "MangasChan", overrideVersionCode = 2),
SingleLang("Mangás Chan", "https://mangaschan.net", "pt-BR", className = "MangasChan", overrideVersionCode = 3),
SingleLang("Mangás Online", "https://mangasonline.cc", "pt-BR", className = "MangasOnline"),
SingleLang("Manhwa Freak", "https://manhwa-freak.com", "en", overrideVersionCode = 3),
SingleLang("Manhwa Lover", "https://manhwalover.com", "en", isNsfw = true, overrideVersionCode = 1),
Expand Down

0 comments on commit b49c115

Please sign in to comment.