Hitomi is stupid enough to block user agent for chrome... holy shit
Added self-test and reload Reduced update ignoring time to 1d from 1w
This commit is contained in:
@@ -125,7 +125,7 @@ private var htmlVersion: String = ""
|
||||
fun reloadWhenFailedOrUpdate() = CoroutineScope(Dispatchers.Default).launch {
|
||||
while (true) {
|
||||
if (
|
||||
webViewFailed ||
|
||||
(webViewFailed && !oldWebView) ||
|
||||
runCatching {
|
||||
URL(
|
||||
if (BuildConfig.DEBUG)
|
||||
@@ -160,21 +160,12 @@ fun initWebView(context: Context) {
|
||||
|
||||
webViewClient = object: WebViewClient() {
|
||||
override fun onPageFinished(view: WebView?, url: String?) {
|
||||
webViewReady = true
|
||||
webView.evaluateJavascript("self_test()") {
|
||||
val result: String = Json.decodeFromString(it)
|
||||
|
||||
webView.evaluateJavascript(
|
||||
"""
|
||||
try {
|
||||
new Function('(x => x?.y ?? z)');
|
||||
true;
|
||||
} catch (err) {
|
||||
false;
|
||||
}
|
||||
""".trimIndent()
|
||||
) {
|
||||
val es2020: Boolean = Json.decodeFromString(it)
|
||||
|
||||
oldWebView = !es2020
|
||||
oldWebView = result == "es2020_unsupported";
|
||||
webViewReady = result == "OK";
|
||||
webViewFailed = result != "OK";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import xyz.quaver.pupil.hitomi.GalleryBlock
|
||||
import xyz.quaver.pupil.hitomi.GalleryInfo
|
||||
import xyz.quaver.pupil.hitomi.getReferer
|
||||
import xyz.quaver.pupil.hitomi.imageUrlFromImage
|
||||
import xyz.quaver.pupil.userAgent
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
@@ -114,7 +115,7 @@ suspend fun GalleryInfo.getRequestBuilders(): List<Request.Builder> {
|
||||
.getOrDefault("https://a/")
|
||||
)
|
||||
.header("Referer", "https://hitomi.la/")
|
||||
.header("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36")
|
||||
.header("User-Agent", userAgent)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ fun checkUpdate(context: Context, force: Boolean = false) {
|
||||
setNegativeButton(if (force) android.R.string.cancel else R.string.ignore) { _, _ ->
|
||||
if (!force)
|
||||
preferences.edit()
|
||||
.putLong("ignore_update_until", System.currentTimeMillis() + 604800000)
|
||||
.putLong("ignore_update_until", System.currentTimeMillis() + 86400000)
|
||||
.apply()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user