Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcd72bb8bd |
@@ -126,7 +126,7 @@ dependencies {
|
|||||||
implementation "ru.noties.markwon:core:3.1.0"
|
implementation "ru.noties.markwon:core:3.1.0"
|
||||||
|
|
||||||
implementation "org.jsoup:jsoup:1.14.3"
|
implementation "org.jsoup:jsoup:1.14.3"
|
||||||
implementation "app.cash.zipline:zipline:1.0.0-SNAPSHOT"
|
implementation "com.github.seven332:quickjs-android:0.1.0"
|
||||||
|
|
||||||
implementation "com.google.guava:guava:31.0.1-android"
|
implementation "com.google.guava:guava:31.0.1-android"
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,12 @@
|
|||||||
package xyz.quaver.pupil.hitomi
|
package xyz.quaver.pupil.hitomi
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import app.cash.zipline.QuickJs
|
import com.hippo.quickjs.android.QuickJS
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.sync.Mutex
|
||||||
|
import kotlinx.coroutines.sync.withLock
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import xyz.quaver.json
|
import xyz.quaver.json
|
||||||
import xyz.quaver.readText
|
import xyz.quaver.readText
|
||||||
@@ -50,18 +55,33 @@ interface gg {
|
|||||||
fun getInstance(): gg =
|
fun getInstance(): gg =
|
||||||
instance ?: synchronized(this) {
|
instance ?: synchronized(this) {
|
||||||
instance ?: object: gg {
|
instance ?: object: gg {
|
||||||
private val engine = QuickJs.create().also {
|
private val ggjs by lazy { URL("https://ltn.hitomi.la/gg.js").readText(Charset.defaultCharset()) }
|
||||||
it.evaluate(URL("https://ltn.hitomi.la/gg.js").readText(Charset.defaultCharset()).also {
|
private val quickJS = QuickJS.Builder().build()
|
||||||
Log.d("PUPILD", it)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun m(g: Int): Int = engine.evaluate("gg.m($g)") as Int
|
override fun m(g: Int): Int =
|
||||||
|
quickJS.createJSRuntime().use { runtime ->
|
||||||
|
runtime.createJSContext().use { context ->
|
||||||
|
context.evaluate(ggjs, "gg.js")
|
||||||
|
context.evaluate("gg.m($g)", "gg.js", Int::class.java)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override val b: String
|
override val b: String
|
||||||
get() = engine.evaluate("gg.b") as String
|
get() =
|
||||||
|
quickJS.createJSRuntime().use { runtime ->
|
||||||
|
runtime.createJSContext().use { context ->
|
||||||
|
context.evaluate(ggjs, "gg.js")
|
||||||
|
context.evaluate("gg.b", "gg.js", String::class.java)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun s(h: String): String = engine.evaluate("gg.s('$h')") as String
|
override fun s(h: String): String =
|
||||||
|
quickJS.createJSRuntime().use { runtime ->
|
||||||
|
runtime.createJSContext().use { context ->
|
||||||
|
context.evaluate(ggjs, "gg.js")
|
||||||
|
context.evaluate("gg.s('$h')", "gg.js", String::class.java)
|
||||||
|
}
|
||||||
|
}
|
||||||
}.also { instance = it }
|
}.also { instance = it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class DownloadService : Service() {
|
|||||||
|
|
||||||
override fun source(): BufferedSource {
|
override fun source(): BufferedSource {
|
||||||
if (bufferedSource == null)
|
if (bufferedSource == null)
|
||||||
bufferedSource = source(responseBody.source()).buffer()
|
bufferedSource = Okio.buffer(source(responseBody.source()))
|
||||||
|
|
||||||
return bufferedSource!!
|
return bufferedSource!!
|
||||||
}
|
}
|
||||||
@@ -174,13 +174,9 @@ class DownloadService : Service() {
|
|||||||
private val interceptor: PupilInterceptor = { chain ->
|
private val interceptor: PupilInterceptor = { chain ->
|
||||||
val request = chain.request()
|
val request = chain.request()
|
||||||
|
|
||||||
Log.d("PUPILD", "REQ")
|
|
||||||
|
|
||||||
if (rateLimitHost.matches(request.url().host()))
|
if (rateLimitHost.matches(request.url().host()))
|
||||||
rateLimiter.acquire()
|
rateLimiter.acquire()
|
||||||
|
|
||||||
Log.d("PUPILD", "ACQ ${request.url()}")
|
|
||||||
|
|
||||||
var response = chain.proceed(request)
|
var response = chain.proceed(request)
|
||||||
var limit = 5
|
var limit = 5
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ allprojects {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
jcenter()
|
jcenter()
|
||||||
maven { url "https://jitpack.io" }
|
maven { url "https://jitpack.io" }
|
||||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
|
|
||||||
maven { url "https://guardian.github.io/maven/repo-releases/" }
|
maven { url "https://guardian.github.io/maven/repo-releases/" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user