Skip to content

Commit

Permalink
Infinityscans: fix cloudflare issues (#1067)
Browse files Browse the repository at this point in the history
fix cloudflare issues
  • Loading branch information
Secozzi authored Feb 6, 2024
1 parent cfa3489 commit 59f1417
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/en/infinityscans/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'InfinityScans'
extClass = '.InfinityScans'
extVersionCode = 3
extVersionCode = 4
isNsfw = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,17 @@ class InfinityScans : HttpSource() {
.rateLimit(1)
.build()

override fun headersBuilder() = super.headersBuilder()
.add("Referer", "$baseUrl/")
override fun headersBuilder() = super.headersBuilder().apply {
add("Referer", "$baseUrl/")
}

private val apiHeaders = headersBuilder().apply {
add("Accept", "*/*")
add("Sec-Fetch-Dest", "empty")
add("Sec-Fetch-Mode", "cors")
add("Sec-Fetch-Site", "same-origin")
add("X-Requested-With", "XMLHttpRequest")
}.build()

private val json: Json by injectLazy()

Expand All @@ -64,10 +73,6 @@ class InfinityScans : HttpSource() {
// Search

override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val searchHeaders = headersBuilder().apply {
add("X-Requested-With", "XMLHttpRequest")
}.build()

val url = baseUrl.toHttpUrl().newBuilder()
.addPathSegments("ajax/comics")
.addQueryParameter("page", page.toString())
Expand Down Expand Up @@ -98,6 +103,10 @@ class InfinityScans : HttpSource() {

if (query.isNotBlank()) url.addQueryParameter("title", query)

val searchHeaders = apiHeaders.newBuilder().apply {
set("Referer", url.build().newBuilder().removePathSegment(0).build().toString())
}.build()

return GET(url.build(), searchHeaders)
}

Expand Down Expand Up @@ -206,13 +215,11 @@ class InfinityScans : HttpSource() {
add("comic_id", id)
}.build()

val chapterHeaders = headersBuilder().apply {
add("Accept", "*/*")
val chapterHeaders = apiHeaders.newBuilder().apply {
add("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
add("Host", baseUrl.toHttpUrl().host)
add("Origin", baseUrl)
set("Referer", url.toString())
add("X-Requested-With", "XMLHttpRequest")
}.build()

val chapterListData = client.newCall(
Expand Down Expand Up @@ -249,12 +256,10 @@ class InfinityScans : HttpSource() {
)
}.build()

val pageListHeaders = headersBuilder().apply {
add("Accept", "*/*")
val pageListHeaders = apiHeaders.newBuilder().apply {
add("Host", url.host)
add("Origin", baseUrl)
set("Referer", url.toString())
add("X-Requested-With", "XMLHttpRequest")
}.build()

val pageListData = client.newCall(
Expand Down

0 comments on commit 59f1417

Please sign in to comment.