[constellar] wow another one (#15164)
* at some point this gonna surpass asura * unused code * useless assignment
This commit is contained in:
parent
a0b7256c71
commit
1213241bb6
|
@ -6,7 +6,9 @@ import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.webkit.ConsoleMessage
|
||||||
import android.webkit.JavascriptInterface
|
import android.webkit.JavascriptInterface
|
||||||
|
import android.webkit.WebChromeClient
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesia
|
import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesia
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
|
@ -70,12 +72,11 @@ class ConstellarScans : MangaThemesia("Constellar Scans", "https://constellarsca
|
||||||
.cacheControl(CacheControl.FORCE_NETWORK)
|
.cacheControl(CacheControl.FORCE_NETWORK)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
internal class JsObject(private val latch: CountDownLatch, var tsData: String = "") {
|
internal class JsObject(val imageList: MutableList<String> = mutableListOf()) {
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
fun passData(tsData: String) {
|
fun passSingleImage(url: String) {
|
||||||
Log.d("constellarscans", "received ts_reader.run data: $tsData")
|
Log.d("constellarscans", "received image: $url")
|
||||||
this.tsData = tsData
|
imageList.add(url)
|
||||||
latch.countDown()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,18 +91,26 @@ class ConstellarScans : MangaThemesia("Constellar Scans", "https://constellarsca
|
||||||
|
|
||||||
document.body().prepend(
|
document.body().prepend(
|
||||||
"""
|
"""
|
||||||
|<script>
|
<script>
|
||||||
| window.ts_reader = new Proxy({}, {
|
const observer = new MutationObserver(mutations => {
|
||||||
| get(target, prop, receiver) {
|
mutations.forEach((mutation) => {
|
||||||
| return (param) => window.$interfaceName.passData(JSON.stringify(param))
|
[...mutation.addedNodes].filter(c => c instanceof HTMLImageElement &&
|
||||||
| }
|
(
|
||||||
| })
|
c.classList.contains("ts-main-image") ||
|
||||||
|</script>
|
c.dataset.index !== undefined ||
|
||||||
""".trimMargin()
|
c.dataset.server !== undefined
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.forEach(c => window.$interfaceName.passSingleImage(c.src))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
observer.observe(document.body, { childList: true, subtree: true })
|
||||||
|
</script>
|
||||||
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
val handler = Handler(Looper.getMainLooper())
|
val handler = Handler(Looper.getMainLooper())
|
||||||
val latch = CountDownLatch(1)
|
val latch = CountDownLatch(1)
|
||||||
val jsinterface = JsObject(latch)
|
val jsInterface = JsObject()
|
||||||
var webView: WebView? = null
|
var webView: WebView? = null
|
||||||
handler.post {
|
handler.post {
|
||||||
val webview = WebView(Injekt.get<Application>())
|
val webview = WebView(Injekt.get<Application>())
|
||||||
|
@ -112,17 +121,37 @@ class ConstellarScans : MangaThemesia("Constellar Scans", "https://constellarsca
|
||||||
webview.settings.useWideViewPort = false
|
webview.settings.useWideViewPort = false
|
||||||
webview.settings.loadWithOverviewMode = false
|
webview.settings.loadWithOverviewMode = false
|
||||||
webview.settings.userAgentString = mobileUserAgent
|
webview.settings.userAgentString = mobileUserAgent
|
||||||
webview.addJavascriptInterface(jsinterface, interfaceName)
|
webview.addJavascriptInterface(jsInterface, interfaceName)
|
||||||
|
|
||||||
|
webview.webChromeClient = object : WebChromeClient() {
|
||||||
|
override fun onProgressChanged(view: WebView?, newProgress: Int) {
|
||||||
|
if (newProgress >= 90) {
|
||||||
|
latch.countDown()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onConsoleMessage(consoleMessage: ConsoleMessage?): Boolean {
|
||||||
|
if (consoleMessage == null) { return false }
|
||||||
|
val logContent = "wv: ${consoleMessage.message()} ${consoleMessage.sourceId()}, line ${consoleMessage.lineNumber()}"
|
||||||
|
when (consoleMessage.messageLevel()) {
|
||||||
|
ConsoleMessage.MessageLevel.DEBUG -> Log.d("constellarscans", logContent)
|
||||||
|
ConsoleMessage.MessageLevel.ERROR -> Log.e("constellarscans", logContent)
|
||||||
|
ConsoleMessage.MessageLevel.LOG -> Log.i("constellarscans", logContent)
|
||||||
|
ConsoleMessage.MessageLevel.TIP -> Log.i("constellarscans", logContent)
|
||||||
|
ConsoleMessage.MessageLevel.WARNING -> Log.w("constellarscans", logContent)
|
||||||
|
else -> Log.d("constellarscans", logContent)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
Log.d("constellarscans", "starting webview shenanigans")
|
Log.d("constellarscans", "starting webview shenanigans")
|
||||||
webview.loadDataWithBaseURL(baseUrl, document.toString(), "text/html", "UTF-8", null)
|
webview.loadDataWithBaseURL(baseUrl, document.toString(), "text/html", "UTF-8", null)
|
||||||
}
|
}
|
||||||
|
|
||||||
latch.await()
|
latch.await()
|
||||||
handler.post { webView?.destroy() }
|
handler.post { webView?.destroy() }
|
||||||
val tsData = json.parseToJsonElement(jsinterface.tsData).jsonObject
|
return jsInterface.imageList.mapIndexed { idx, it -> Page(idx, imageUrl = it) }
|
||||||
return tsData["sources"]!!.jsonArray[0].jsonObject["images"]!!.jsonArray.mapIndexed { idx, it ->
|
|
||||||
Page(idx, imageUrl = it.jsonPrimitive.content)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun imageRequest(page: Page): Request = super.imageRequest(page).newBuilder()
|
override fun imageRequest(page: Page): Request = super.imageRequest(page).newBuilder()
|
||||||
|
|
|
@ -25,7 +25,7 @@ class MangaThemesiaGenerator : ThemeSourceGenerator {
|
||||||
SingleLang("Azure Scans", "https://azuremanga.com", "en", overrideVersionCode = 1),
|
SingleLang("Azure Scans", "https://azuremanga.com", "en", overrideVersionCode = 1),
|
||||||
SingleLang("Boosei", "https://boosei.net", "id", overrideVersionCode = 2),
|
SingleLang("Boosei", "https://boosei.net", "id", overrideVersionCode = 2),
|
||||||
SingleLang("Clayrer", "https://clayrer.net", "es"),
|
SingleLang("Clayrer", "https://clayrer.net", "es"),
|
||||||
SingleLang("Constellar Scans", "https://constellarscans.com", "en", isNsfw = true, overrideVersionCode = 10),
|
SingleLang("Constellar Scans", "https://constellarscans.com", "en", isNsfw = true, overrideVersionCode = 11),
|
||||||
SingleLang("Cosmic Scans", "https://cosmicscans.com", "en", overrideVersionCode = 1),
|
SingleLang("Cosmic Scans", "https://cosmicscans.com", "en", overrideVersionCode = 1),
|
||||||
SingleLang("Diskus Scan", "https://diskusscan.com", "pt-BR", overrideVersionCode = 7),
|
SingleLang("Diskus Scan", "https://diskusscan.com", "pt-BR", overrideVersionCode = 7),
|
||||||
SingleLang("Dojing.net", "https://dojing.net", "id", isNsfw = true, className = "DojingNet"),
|
SingleLang("Dojing.net", "https://dojing.net", "id", isNsfw = true, className = "DojingNet"),
|
||||||
|
|
Loading…
Reference in New Issue