Compare commits

..

7 Commits

Author SHA1 Message Date
tom5079
9b821dd7cb Update README.md 2022-01-02 23:49:58 +09:00
tom5079
213902c854 Update README.md 2022-01-02 16:46:54 +09:00
tom5079
2054922586 Update README.md 2022-01-02 16:46:43 +09:00
tom5079
a17b7355f5 Merge remote-tracking branch 'origin/master' 2022-01-02 15:30:20 +09:00
tom5079
066a1e1f3a use WebView(!) as a js engine 2022-01-02 15:30:03 +09:00
tom5079
b10cbfbd63 Update README.md 2022-01-02 15:18:11 +09:00
tom5079
fcd72bb8bd Revert back to quickjs-android (quickjs stackoverflows) 2022-01-02 09:16:28 +09:00
9 changed files with 89 additions and 36 deletions

View File

@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="$USER_HOME$/.android/avd/Pixel_2_API_30.avd" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-01-01T07:38:11.679673Z" />
</component>
</project>

View File

@@ -2,7 +2,7 @@
*Pupil, Hitomi.la viewer for Android*
![](https://img.shields.io/github/downloads/tom5079/Pupil/total)
[![](https://img.shields.io/github/downloads/tom5079/Pupil/5.1.30/Pupil-v5.1.30.apk?color=%234fc3f7&label=DOWNLOAD%20APP&style=for-the-badge)](https://github.com/tom5079/Pupil/releases/download/5.1.30/Pupil-v5.1.30.apk)
[![](https://img.shields.io/github/downloads/tom5079/Pupil/5.1.34/Pupil-v5.1.34.apk?color=%234fc3f7&label=DOWNLOAD%20APP&style=for-the-badge)](https://github.com/tom5079/Pupil/releases/download/5.1.34/Pupil-v5.1.34.apk)
[![](https://discordapp.com/api/guilds/610452916612104194/embed.png?style=banner2)](https://discord.gg/Stj4b5v)
# Features

View File

@@ -38,7 +38,7 @@ android {
minSdkVersion 16
targetSdkVersion 30
versionCode 69
versionName "5.1.30"
versionName "5.1.32"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
@@ -126,7 +126,6 @@ dependencies {
implementation "ru.noties.markwon:core:3.1.0"
implementation "org.jsoup:jsoup:1.14.3"
implementation "app.cash.zipline:zipline:1.0.0-SNAPSHOT"
implementation "com.google.guava:guava:31.0.1-android"

View File

@@ -11,7 +11,7 @@
"type": "SINGLE",
"filters": [],
"versionCode": 69,
"versionName": "5.1.30",
"versionName": "5.1.32",
"outputFile": "app-release.apk"
}
]

View File

@@ -20,8 +20,14 @@
package xyz.quaver.pupil
import android.util.Log
import android.webkit.WebView
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import org.junit.Test
import org.junit.runner.RunWith
@@ -37,5 +43,17 @@ class ExampleInstrumentedTest {
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
runBlocking {
MainScope().launch {
val webView = WebView(appContext).apply {
settings.javaScriptEnabled = true
}
webView.evaluateJavascript("3") {
Log.d("PUPILD", it)
}
Log.d("PUPILD", "SYNC?")
}.join()
}
}
}

View File

@@ -18,6 +18,7 @@
package xyz.quaver.pupil
import android.annotation.SuppressLint
import android.app.Application
import android.app.Notification
import android.app.NotificationChannel
@@ -26,6 +27,7 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.webkit.WebView
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.ContextCompat
import androidx.preference.PreferenceManager
@@ -69,9 +71,26 @@ val client: OkHttpClient
clientHolder = it
}
@SuppressLint("StaticFieldLeak")
lateinit var webView: WebView
class Pupil : Application() {
companion object {
lateinit var instance: Pupil
private set
}
@SuppressLint("SetJavaScriptEnabled")
override fun onCreate() {
instance = this
webView = WebView(this).apply {
settings.javaScriptEnabled = true
loadData("""<script src="https://ltn.hitomi.la/gg.js"></script>""", "text/html", null)
}
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
preferences = PreferenceManager.getDefaultSharedPreferences(this)

View File

@@ -16,10 +16,15 @@
package xyz.quaver.pupil.hitomi
import android.annotation.SuppressLint
import android.util.Log
import app.cash.zipline.QuickJs
import android.webkit.WebView
import android.webkit.WebViewClient
import kotlinx.coroutines.*
import kotlinx.serialization.decodeFromString
import xyz.quaver.json
import xyz.quaver.pupil.Pupil
import xyz.quaver.pupil.webView
import xyz.quaver.readText
import java.net.URL
import java.nio.charset.Charset
@@ -39,6 +44,7 @@ const val galleryblockextension = ".html"
const val galleryblockdir = "galleryblock"
const val nozomiextension = ".nozomi"
@SuppressLint("SetJavaScriptEnabled")
interface gg {
fun m(g: Int): Int
val b: String
@@ -50,18 +56,51 @@ interface gg {
fun getInstance(): gg =
instance ?: synchronized(this) {
instance ?: object: gg {
private val engine = QuickJs.create().also {
it.evaluate(URL("https://ltn.hitomi.la/gg.js").readText(Charset.defaultCharset()).also {
Log.d("PUPILD", it)
})
override fun m(g: Int): Int {
var result: Int? = null
MainScope().launch {
while (webView.progress != 100) delay(100)
webView.evaluateJavascript("gg.m($g)") {
result = it.toInt()
}
}
while (result == null) Thread.sleep(100)
return result!!
}
override fun m(g: Int): Int = engine.evaluate("gg.m($g)") as Int
override val b: String
get() = engine.evaluate("gg.b") as String
get() {
var result: String? = null
override fun s(h: String): String = engine.evaluate("gg.s('$h')") as String
MainScope().launch {
while (webView.progress != 100) delay(100)
webView.evaluateJavascript("gg.b") {
result = it.replace("\"", "")
}
}
while (result == null) Thread.sleep(100)
return result!!
}
override fun s(h: String): String {
var result: String? = null
MainScope().launch {
while (webView.progress != 100) delay(100)
webView.evaluateJavascript("gg.s('$h')") {
result = it.replace("\"", "")
}
}
while (result == null) Thread.sleep(100)
return result!!
}
}.also { instance = it }
}
}

View File

@@ -149,7 +149,7 @@ class DownloadService : Service() {
override fun source(): BufferedSource {
if (bufferedSource == null)
bufferedSource = source(responseBody.source()).buffer()
bufferedSource = Okio.buffer(source(responseBody.source()))
return bufferedSource!!
}
@@ -174,13 +174,9 @@ class DownloadService : Service() {
private val interceptor: PupilInterceptor = { chain ->
val request = chain.request()
Log.d("PUPILD", "REQ")
if (rateLimitHost.matches(request.url().host()))
rateLimiter.acquire()
Log.d("PUPILD", "ACQ ${request.url()}")
var response = chain.proceed(request)
var limit = 5

View File

@@ -25,7 +25,6 @@ allprojects {
mavenCentral()
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://guardian.github.io/maven/repo-releases/" }
}
}