From 9a6f8be28c3eddcfa866ecd4441e726c1f4b13a5 Mon Sep 17 00:00:00 2001 From: DitFranXX <45893338+DitFranXX@users.noreply.github.com> Date: Mon, 18 Mar 2019 22:58:50 +0900 Subject: [PATCH 1/5] Remove F-Droid on README.md (#1891) * Remove F-Droid on README.md Seems F-Droid is not updated anymore. * Remove unnecessary whitespace --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6b2fd3baaa..92b9e80b70 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ | Build | Stable | Dev | Contribute | Contact | |-------|----------|---------|------------|---------| -| [![Travis](https://img.shields.io/travis/inorichi/tachiyomi.svg)](https://travis-ci.org/inorichi/tachiyomi) | [![stable release](https://img.shields.io/github/release/inorichi/tachiyomi.svg?maxAge=3600&label=download%20(autoupdate%20included))](https://github.com/inorichi/tachiyomi/releases) | [![latest dev build](https://img.shields.io/badge/download-latest%20build-blue.svg)](http://tachiyomi.kanade.eu/latest) [![fdroid dev](https://img.shields.io/badge/autoupdate-wiki-blue.svg)](//github.com/inorichi/tachiyomi/wiki/F-Droid-for-dev-versions) | [![Translation status](https://hosted.weblate.org/widgets/tachiyomi/-/svg-badge.svg)](https://hosted.weblate.org/engage/tachiyomi/?utm_source=widget) | [![Discord](https://img.shields.io/discord/349436576037732353.svg)](https://discord.gg/tachiyomi) | +| [![Travis](https://img.shields.io/travis/inorichi/tachiyomi.svg)](https://travis-ci.org/inorichi/tachiyomi) | [![stable release](https://img.shields.io/github/release/inorichi/tachiyomi.svg?maxAge=3600&label=download%20(autoupdate%20included))](https://github.com/inorichi/tachiyomi/releases) | [![latest dev build](https://img.shields.io/badge/download-latest%20build-blue.svg)](http://tachiyomi.kanade.eu/latest) | [![Translation status](https://hosted.weblate.org/widgets/tachiyomi/-/svg-badge.svg)](https://hosted.weblate.org/engage/tachiyomi/?utm_source=widget) | [![Discord](https://img.shields.io/discord/349436576037732353.svg)](https://discord.gg/tachiyomi) | # ![app icon](./.github/readme-images/app-icon.png)Tachiyomi @@ -23,7 +23,7 @@ Features include: ## Download Get the app from our [releases page](https://github.com/inorichi/tachiyomi/releases). -If you want to try new features before they get to the stable release, you can download the dev version [here](http://tachiyomi.kanade.eu/latest) (auto-updates not included), or add our [F-Droid repo](https://github.com/inorichi/tachiyomi/wiki/F-Droid-for-dev-versions). +If you want to try new features before they get to the stable release, you can download the dev version [here](http://tachiyomi.kanade.eu/latest). (auto-updates not included) ## Issues, Feature Requests and Contributing From 9ca0307e1c4d0f39028154c55438548fb9d8b5fc Mon Sep 17 00:00:00 2001 From: DitFranXX <45893338+DitFranXX@users.noreply.github.com> Date: Thu, 21 Mar 2019 16:48:03 +0900 Subject: [PATCH 2/5] [Cloudflare] Fix 503 due to missing value in js challenge. (#1913) Related issues: inorichi/tachiyomi-extensions#951 --- .../eu/kanade/tachiyomi/network/CloudflareInterceptor.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt index 5bee37cabe..7c432f4294 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt @@ -12,6 +12,8 @@ class CloudflareInterceptor : Interceptor { private val challengePattern = Regex("""name="jschl_vc" value="(\w+)"""") + private val sPattern = Regex("""name="s" value="([^"]+)""") + private val serverCheck = arrayOf("cloudflare-nginx", "cloudflare") @Synchronized @@ -45,8 +47,9 @@ class CloudflareInterceptor : Interceptor { val operation = operationPattern.find(content)?.groups?.get(1)?.value val challenge = challengePattern.find(content)?.groups?.get(1)?.value val pass = passPattern.find(content)?.groups?.get(1)?.value + val s = sPattern.find(content)?.groups?.get(1)?.value - if (operation == null || challenge == null || pass == null) { + if (operation == null || challenge == null || pass == null || s == null) { throw Exception("Failed resolving Cloudflare challenge") } @@ -62,6 +65,7 @@ class CloudflareInterceptor : Interceptor { .newBuilder() .addQueryParameter("jschl_vc", challenge) .addQueryParameter("pass", pass) + .addQueryParameter("s", s) .addQueryParameter("jschl_answer", result) .toString() From 7551941ef22b6dda64f532e89ade19a8148cad13 Mon Sep 17 00:00:00 2001 From: DitFranXX <45893338+DitFranXX@users.noreply.github.com> Date: Sat, 23 Mar 2019 03:25:21 +0900 Subject: [PATCH 3/5] [Cloudflare] Fix recent CF JS Challenge error that calls DOM (#1919) * [Cloudflare] Fix recent CF JS Challenge error that calls DOM * Replace `atob` to pure js version. (was node.js API which invalid) * Use `atob` as native function `Base64.decode()`` * Use okio Base64 decoder instead of Android one. --- .../network/CloudflareInterceptor.kt | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt index 7c432f4294..641cdd9602 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt @@ -14,8 +14,20 @@ class CloudflareInterceptor : Interceptor { private val sPattern = Regex("""name="s" value="([^"]+)""") + private val kPattern = Regex("""k\s+=\s+'([^']+)';""") + private val serverCheck = arrayOf("cloudflare-nginx", "cloudflare") + private interface IBase64 { + fun decode(input: String): String + } + + private val b64: IBase64 = object : IBase64 { + override fun decode(input: String): String { + return okio.ByteString.decodeBase64(input)!!.utf8() + } + } + @Synchronized override fun intercept(chain: Interceptor.Chain): Response { val response = chain.proceed(chain.request()) @@ -49,17 +61,28 @@ class CloudflareInterceptor : Interceptor { val pass = passPattern.find(content)?.groups?.get(1)?.value val s = sPattern.find(content)?.groups?.get(1)?.value + // If `k` is null, it uses old methods. + val k = kPattern.find(content)?.groups?.get(1)?.value ?: "" + val innerHTMLValue = Regex("""(.*)""") + .find(content)?.groups?.get(3)?.value ?: "" + if (operation == null || challenge == null || pass == null || s == null) { throw Exception("Failed resolving Cloudflare challenge") } + // Export native Base64 decode function to js object. + duktape.set("b64", IBase64::class.java, b64) + + // Return simulated innerHTML when call DOM. + val simulatedDocumentJS = """var document = { getElementById: function (x) { return { innerHTML: "$innerHTMLValue" }; } }""" + val js = operation - .replace(Regex("""a\.value = (.+ \+ t\.length(\).toFixed\(10\))?).+"""), "$1") + .replace(Regex("""a\.value = (.+\.toFixed\(10\);).+"""), "$1") .replace(Regex("""\s{3,}[a-z](?: = |\.).+"""), "") .replace("t.length", "${domain.length}") .replace("\n", "") - val result = duktape.evaluate(js) as String + val result = duktape.evaluate("""$simulatedDocumentJS;$ATOB_JS;var t="$domain";$js""") as String val cloudflareUrl = HttpUrl.parse("${url.scheme()}://$domain/cdn-cgi/l/chk_jschl")!! .newBuilder() @@ -80,4 +103,8 @@ class CloudflareInterceptor : Interceptor { } } -} + companion object { + // atob() is browser API, Using Android's own function. (java.util.Base64 can't be used because of min API level) + private const val ATOB_JS = """var atob = function (input) { return b64.decode(input) }""" + } +} \ No newline at end of file From 0afd77d110a2392ed8d515b306544ddb1ffdb412 Mon Sep 17 00:00:00 2001 From: inorichi Date: Fri, 22 Mar 2019 19:26:04 +0100 Subject: [PATCH 4/5] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index ccf082421a..f6ea76ef53 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -4,6 +4,8 @@ **App version:** +**Android version:** + **Issue/Request:** **Steps to reproduce (if applicable)** From f12d5ba68984ff352ab9b0f3d15287525813dad1 Mon Sep 17 00:00:00 2001 From: inorichi Date: Fri, 22 Mar 2019 23:06:05 +0100 Subject: [PATCH 5/5] Storio imported from Jitpack. Also fix an issue with the progress bar animation on the reader --- app/build.gradle | 4 +++- .../ui/reader/viewer/ReaderProgressBar.kt | 22 +++++++------------ build.gradle | 1 - 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7ca90752be..d6385802fd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -161,7 +161,9 @@ dependencies { implementation 'com.github.gabrielemariotti.changeloglib:changelog:2.1.0' // Database - implementation 'eu.kanade.storio:storio:1.13.0' + implementation 'android.arch.persistence:db:1.0.0' + implementation 'com.github.inorichi.storio:storio-common:8be19de@aar' + implementation 'com.github.inorichi.storio:storio-sqlite:8be19de@aar' implementation 'io.requery:sqlite-android:3.25.2' // Model View Presenter diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderProgressBar.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderProgressBar.kt index e097c50638..a251b0c8ab 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderProgressBar.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderProgressBar.kt @@ -116,21 +116,15 @@ class ReaderProgressBar @JvmOverloads constructor( } /** - * Called when the aggregated visibility of this view changes. It also starts of stops the - * rotation animation according to [isVisible]. + * Called when the visibility of this view changes. */ - override fun onVisibilityAggregated(isVisible: Boolean) { - super.onVisibilityAggregated(isVisible) - - if (isVisible != aggregatedIsVisible) { - aggregatedIsVisible = isVisible - - // let's be nice with the UI thread - if (isVisible) { - startAnimation() - } else { - stopAnimation() - } + override fun setVisibility(visibility: Int) { + super.setVisibility(visibility) + val isVisible = visibility == View.VISIBLE + if (isVisible) { + startAnimation() + } else { + stopAnimation() } } diff --git a/build.gradle b/build.gradle index cef1ec0007..2885a88fc1 100644 --- a/build.gradle +++ b/build.gradle @@ -22,6 +22,5 @@ allprojects { maven { url "https://jitpack.io" } maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } jcenter() - maven { url "https://dl.bintray.com/inorichi/maven" } } }