Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf672462

Browse files
committed
Use WebView version for UA to bypass Cloudflare
1 parent9a0b0d2 commitf672462

File tree

5 files changed

+9
-23
lines changed

5 files changed

+9
-23
lines changed

‎app/build.gradle.kts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ android {
5252
}.standardOutput.asText.get().trim().removePrefix("https://github.com/").removePrefix("git@github.com:")
5353
.removeSuffix(".git")
5454

55-
val chromeVersion= rootProject.layout.projectDirectory.file("chrome.version").asFile.readText().trim()
56-
5755
defaultConfig {
5856
applicationId="moe.tarsin.ehviewer"
5957
versionCode=180063
@@ -63,7 +61,6 @@ android {
6361
buildConfigField("String","COMMIT_SHA","\"$commitSha\"")
6462
buildConfigField("long","COMMIT_TIME", commitTime)
6563
buildConfigField("String","REPO_NAME","\"$repoName\"")
66-
buildConfigField("String","CHROME_VERSION","\"$chromeVersion\"")
6764
ndk {
6865
if (isRelease) {
6966
abiFilters.addAll(supportedAbis)
@@ -179,6 +176,7 @@ dependencies {
179176
implementation(libs.androidx.appcompat)
180177
implementation(libs.androidx.biometric)
181178
implementation(libs.androidx.browser)
179+
implementation(libs.androidx.webkit)
182180

183181
implementation(libs.compose.destinations.core)
184182
ksp(libs.compose.destinations.compiler)

‎app/src/main/kotlin/com/hippo/ehviewer/ktor/Common.kt‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
packagecom.hippo.ehviewer.ktor
22

3+
importandroidx.webkit.WebViewCompat
34
importcom.ehviewer.core.network.EhCookieStore
4-
importcom.hippo.ehviewer.BuildConfig
55
importcom.hippo.ehviewer.Settings
66
importio.ktor.client.HttpClientConfig
77
importio.ktor.client.engine.HttpClientEngineConfig
@@ -14,9 +14,12 @@ import io.ktor.client.request.header
1414
importio.ktor.http.HttpHeaders
1515
importio.ktor.http.userAgent
1616
importio.ktor.util.appendIfNameAbsent
17+
importsplitties.init.appCtx
1718

18-
constvalCHROME_MOBILE_USER_AGENT="Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${BuildConfig.CHROME_VERSION}.0.0.0 Mobile Safari/537.36"
19-
privateconstvalCHROME_USER_AGENT="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${BuildConfig.CHROME_VERSION}.0.0.0 Safari/537.36"
19+
// It's safe to assume the WebView package will always be present as we require CookieManager anyway
20+
privatevalWebViewVersion=WebViewCompat.getCurrentWebViewPackage(appCtx)!!.versionName!!.substringBefore('.')
21+
valCHROME_MOBILE_USER_AGENT="Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/$WebViewVersion.0.0.0 Mobile Safari/537.36"
22+
privatevalCHROME_USER_AGENT="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/$WebViewVersion.0.0.0 Safari/537.36"
2023
privateconstvalCHROME_ACCEPT="text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"
2124
privateconstvalCHROME_ACCEPT_LANGUAGE="en-US,en;q=0.9"
2225

‎chrome.version‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎gradle/libs.versions.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ androidx-datastore = "1.2.0"
1212
androidx-lifecycle ="2.10.0"
1313
androidx-paging ="3.3.6"
1414
androidx-room ="2.8.4"
15+
androidx-webkit ="1.14.0"
1516
androidx-work ="2.11.0"
1617
arrow ="2.2.0"
1718
coil ="3.3.0"
@@ -59,6 +60,7 @@ androidx-paging-compose = { module = "androidx.paging:paging-compose", version.r
5960
androidx-room-compiler = {module ="androidx.room:room-compiler",version.ref ="androidx-room" }
6061
androidx-room-paging = {module ="androidx.room:room-paging",version.ref ="androidx-room" }
6162

63+
androidx-webkit = {module ="androidx.webkit:webkit",version.ref ="androidx-webkit" }
6264
androidx-work-runtime = {module ="androidx.work:work-runtime",version.ref ="androidx-work" }
6365

6466
arrow-fx-coroutines = {module ="io.arrow-kt:arrow-fx-coroutines" }

‎renovate.json‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,6 @@
2828
"datasourceTemplate":"custom.gnu",
2929
"extractVersionTemplate":"{{depName}}-(?<version>.+)\\.tar\\.gz$"
3030
},
31-
{
32-
"customType":"regex",
33-
"managerFilePatterns": [
34-
"chrome.version"
35-
],
36-
"matchStrings": [
37-
"(?<currentValue>\\S+)"
38-
],
39-
"depNameTemplate":"chrome",
40-
"datasourceTemplate":"custom.chrome",
41-
"extractVersionTemplate":"^(?<version>\\d+)"
42-
},
4331
{
4432
"customType":"regex",
4533
"managerFilePatterns": [
@@ -65,10 +53,6 @@
6553
}
6654
],
6755
"customDatasources": {
68-
"chrome": {
69-
"defaultRegistryUrlTemplate":"https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_STABLE",
70-
"format":"plain"
71-
},
7256
"rust-nightly": {
7357
"defaultRegistryUrlTemplate":"https://rust-lang.github.io/rustup-components-history/aarch64-linux-android/rust-std",
7458
"format":"plain"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp