Update chillxextractor

This commit is contained in:
V3u47ZoN 2025-05-03 09:05:40 +00:00 committed by GitHub
parent 36a480cd46
commit 5b66e204ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 9 deletions

View file

@ -44,6 +44,7 @@ class ChillxExtractor(private val client: OkHttpClient, private val headers: Hea
url = it.url, url = it.url,
quality = it.quality, quality = it.quality,
videoUrl = it.videoUrl, videoUrl = it.videoUrl,
headers = it.headers,
audioTracks = it.audioTracks, audioTracks = it.audioTracks,
subtitleTracks = playlistUtils.fixSubtitles(it.subtitleTracks), subtitleTracks = playlistUtils.fixSubtitles(it.subtitleTracks),
) )

View file

@ -10,6 +10,7 @@ import android.webkit.WebResourceResponse
import android.webkit.WebView import android.webkit.WebView
import android.webkit.WebViewClient import android.webkit.WebViewClient
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Headers import okhttp3.Headers
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
@ -60,8 +61,8 @@ class WebViewResolver(
view: WebView?, view: WebView?,
request: WebResourceRequest? request: WebResourceRequest?
): WebResourceResponse? { ): WebResourceResponse? {
if (request?.url.toString().contains("assets/js/library")) { if (request?.url.toString().equals(embedUrl, true)) {
return patchScript(request!!.url.toString(), interfaceName) return patchBody(request!!.url.toString(), interfaceName)
?: super.shouldInterceptRequest(view, request) ?: super.shouldInterceptRequest(view, request)
} }
@ -92,12 +93,12 @@ class WebViewResolver(
return List(length) { charPool.random() }.joinToString("") return List(length) { charPool.random() }.joinToString("")
} }
private fun patchScript(scriptUrl: String, interfaceName: String): WebResourceResponse? { private fun patchBody(url: String, interfaceName: String): WebResourceResponse? {
val scriptBody = client.newCall(GET(scriptUrl)).execute().body.string() val html = client.newCall(GET(url, globalHeaders)).execute().asJsoup()
val oldFunc = randomString() val oldFunc = randomString()
val newBody = buildString { val script = html.createElement("script").apply {
append( appendText(
""" """
const $oldFunc = Function; const $oldFunc = Function;
window.Function = function (...args) { window.Function = function (...args) {
@ -108,17 +109,17 @@ class WebViewResolver(
}; };
""".trimIndent() """.trimIndent()
) )
append(scriptBody)
} }
html.body().insertChildren(0, script)
return WebResourceResponse( return WebResourceResponse(
"application/javascript", "text/html",
"utf-8", "utf-8",
200, 200,
"ok", "ok",
mapOf("server" to "cloudflare"), mapOf("server" to "cloudflare"),
ByteArrayInputStream(newBody.toByteArray()), ByteArrayInputStream(html.outerHtml().toByteArray()),
) )
} }
} }