diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/annotations/DownloadsCompatibility.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/annotations/DownloadsCompatibility.kt new file mode 100644 index 000000000..170239e7e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/annotations/DownloadsCompatibility.kt @@ -0,0 +1,14 @@ +package app.revanced.patches.tiktok.interaction.downloads.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility( + [ + Package("com.ss.android.ugc.trill", arrayOf()), + Package("com.zhiliaoapp.musically", arrayOf()) + ] +) +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +internal annotation class DownloadsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint.kt new file mode 100644 index 000000000..991702cd1 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint.kt @@ -0,0 +1,25 @@ +package app.revanced.patches.tiktok.interaction.downloads.fingerprints + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.tiktok.interaction.downloads.annotations.DownloadsCompatibility +import org.jf.dexlib2.AccessFlags + +@Name("acl-common-share-get-code") +@MatchingMethod("ACLCommonShare", "getCode") +@DownloadsCompatibility +@Version("0.0.1") +object ACLCommonShareFingerprint : MethodFingerprint( + "I", + AccessFlags.PUBLIC or AccessFlags.FINAL, + null, + null, + null, + { methodDef -> + methodDef.definingClass.endsWith("/ACLCommonShare;") && + methodDef.name == "getCode" + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint2.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint2.kt new file mode 100644 index 000000000..62284e395 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint2.kt @@ -0,0 +1,25 @@ +package app.revanced.patches.tiktok.interaction.downloads.fingerprints + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.tiktok.interaction.downloads.annotations.DownloadsCompatibility +import org.jf.dexlib2.AccessFlags + +@Name("acl-common-share-get-show-type") +@MatchingMethod("ACLCommonShare", "getShowType") +@DownloadsCompatibility +@Version("0.0.1") +object ACLCommonShareFingerprint2 : MethodFingerprint( + "I", + AccessFlags.PUBLIC or AccessFlags.FINAL, + null, + null, + null, + { methodDef -> + methodDef.definingClass.endsWith("/ACLCommonShare;") && + methodDef.name == "getShowType" + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint3.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint3.kt new file mode 100644 index 000000000..9e1c49635 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/fingerprints/ACLCommonShareFingerprint3.kt @@ -0,0 +1,25 @@ +package app.revanced.patches.tiktok.interaction.downloads.fingerprints + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.tiktok.interaction.downloads.annotations.DownloadsCompatibility +import org.jf.dexlib2.AccessFlags + +@Name("acl-common-share-get-transcode") +@MatchingMethod("ACLCommonShare", "getTranscode") +@DownloadsCompatibility +@Version("0.0.1") +object ACLCommonShareFingerprint3 : MethodFingerprint( + "I", + AccessFlags.PUBLIC or AccessFlags.FINAL, + null, + null, + null, + { methodDef -> + methodDef.definingClass.endsWith("/ACLCommonShare;") && + methodDef.name == "getTranscode" + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/patch/DownloadsPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/patch/DownloadsPatch.kt new file mode 100644 index 000000000..0360d2dbe --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/patch/DownloadsPatch.kt @@ -0,0 +1,56 @@ +package app.revanced.patches.tiktok.interaction.downloads.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.extensions.replaceInstructions +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patcher.patch.impl.BytecodePatch +import app.revanced.patches.tiktok.interaction.downloads.annotations.DownloadsCompatibility +import app.revanced.patches.tiktok.interaction.downloads.fingerprints.* + +@Patch +@Name("tiktok-download") +@Description("Remove restrictions on downloads video.") +@DownloadsCompatibility +@Version("0.0.1") +class DownloadsPatch : BytecodePatch( + listOf( + ACLCommonShareFingerprint, + ACLCommonShareFingerprint2, + ACLCommonShareFingerprint3 + ) +) { + override fun execute(data: BytecodeData): PatchResult { + val method1 = ACLCommonShareFingerprint.result!!.mutableMethod + method1.replaceInstructions( + 0, + """ + const/4 v0, 0x0 + return v0 + """ + ) + val method2 = ACLCommonShareFingerprint2.result!!.mutableMethod + method2.replaceInstructions( + 0, + """ + const/4 v0, 0x2 + return v0 + """ + ) + //Download videos without watermark. + val method3 = ACLCommonShareFingerprint3.result!!.mutableMethod + method3.replaceInstructions( + 0, + """ + const/4 v0, 0x1 + return v0 + """ + ) + return PatchResultSuccess() + } + +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/annotations/SeekbarCompatibility.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/annotations/SeekbarCompatibility.kt new file mode 100644 index 000000000..7c7983c46 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/annotations/SeekbarCompatibility.kt @@ -0,0 +1,14 @@ +package app.revanced.patches.tiktok.interaction.seekbar.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility( + [ + Package("com.ss.android.ugc.trill", arrayOf()), + Package("com.zhiliaoapp.musically", arrayOf()) + ] +) +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +internal annotation class SeekbarCompatibility diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/fingerprints/AwemeGetVideoControlFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/fingerprints/AwemeGetVideoControlFingerprint.kt new file mode 100644 index 000000000..0ac485d28 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/fingerprints/AwemeGetVideoControlFingerprint.kt @@ -0,0 +1,23 @@ +package app.revanced.patches.tiktok.interaction.seekbar.fingerprints + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.tiktok.interaction.seekbar.annotations.SeekbarCompatibility +import org.jf.dexlib2.AccessFlags + +@Name("aweme-get-video-control") +@MatchingMethod("Aweme", "getVideoControl") +@SeekbarCompatibility +@Version("0.0.1") +object AwemeGetVideoControlFingerprint : MethodFingerprint( + "L", + AccessFlags.PUBLIC.value, + null, + null, + null, + { methodDef -> + methodDef.definingClass.endsWith("/Aweme;") && methodDef.name == "getVideoControl" + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/TiktokSeekbarPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/TiktokSeekbarPatch.kt new file mode 100644 index 000000000..90ecf04e5 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/TiktokSeekbarPatch.kt @@ -0,0 +1,47 @@ +package app.revanced.patches.tiktok.interaction.seekbar.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patcher.patch.impl.BytecodePatch +import app.revanced.patches.tiktok.interaction.seekbar.annotations.SeekbarCompatibility +import app.revanced.patches.tiktok.interaction.seekbar.fingerprints.* +import org.jf.dexlib2.Opcode +import org.jf.dexlib2.builder.instruction.BuilderInstruction11n +import org.jf.dexlib2.builder.instruction.BuilderInstruction22c + +@Patch +@Name("tiktok-seekbar") +@Description("Show progress bar for all video.") +@SeekbarCompatibility +@Version("0.0.1") +class TiktokSeekbarPatch : BytecodePatch( + listOf( + AwemeGetVideoControlFingerprint + ) +) { + override fun execute(data: BytecodeData): PatchResult { + //Get VideoControl FieldReference + val videoControl = data.findClass { it.type.endsWith("/VideoControl;") } + ?: return PatchResultError("Can not find target class") + val fieldList = videoControl.immutableClass.fields.associateBy { field -> field.name } + + val method = AwemeGetVideoControlFingerprint.result!!.mutableMethod + val implementation = method.implementation!! + implementation.addInstructions( + 1, listOf( + BuilderInstruction11n(Opcode.CONST_4, 1, 1), + BuilderInstruction22c(Opcode.IPUT, 1, 0, fieldList["showProgressBar"]!!), + BuilderInstruction22c(Opcode.IPUT, 1, 0, fieldList["draftProgressBar"]!!) + ) + ) + return PatchResultSuccess() + } + +} \ No newline at end of file