feat(tiktok): tiktok-web-login patch (#593)

This commit is contained in:
d4rkk3y 2022-11-21 22:14:58 +07:00 committed by GitHub
parent e442c0c0a6
commit 7269014762
4 changed files with 98 additions and 0 deletions

View File

@ -0,0 +1,14 @@
package app.revanced.patches.tiktok.misc.loginfallback.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility(
[
Package("com.ss.android.ugc.trill"),
Package("com.zhiliaoapp.musically")
]
)
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class TikTokWebLoginCompatibility

View File

@ -0,0 +1,20 @@
package app.revanced.patches.tiktok.misc.loginfallback.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.impl.MethodFingerprint
import app.revanced.patches.tiktok.misc.loginfallback.annotations.TikTokWebLoginCompatibility
import org.jf.dexlib2.AccessFlags
@Name("google-one-tap-auth-available-fingerprint")
@TikTokWebLoginCompatibility
@Version("0.0.1")
object GoogleAuthAvailableFingerprint : MethodFingerprint(
returnType = "Z",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
customFingerprint = { methodDef ->
methodDef.definingClass == "Lcom/bytedance/lobby/google/GoogleAuth;"
}
)

View File

@ -0,0 +1,20 @@
package app.revanced.patches.tiktok.misc.loginfallback.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.impl.MethodFingerprint
import app.revanced.patches.tiktok.misc.loginfallback.annotations.TikTokWebLoginCompatibility
import org.jf.dexlib2.AccessFlags
@Name("google-one-tap-auth-available-fingerprint")
@TikTokWebLoginCompatibility
@Version("0.0.1")
object GoogleOneTapAuthAvailableFingerprint : MethodFingerprint(
returnType = "Z",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
customFingerprint = { methodDef ->
methodDef.definingClass == "Lcom/bytedance/lobby/google/GoogleOneTapAuth;"
}
)

View File

@ -0,0 +1,44 @@
package app.revanced.patches.tiktok.misc.loginfallback.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.tiktok.misc.loginfallback.annotations.TikTokWebLoginCompatibility
import app.revanced.patches.tiktok.misc.loginfallback.fingerprints.GoogleAuthAvailableFingerprint
import app.revanced.patches.tiktok.misc.loginfallback.fingerprints.GoogleOneTapAuthAvailableFingerprint
@Patch
@Name("tiktok-web-login")
@Description("Allows logging in with a Google account.")
@TikTokWebLoginCompatibility
@Version("0.0.1")
class TikTokLoginFallbackPatch : BytecodePatch(
listOf(
GoogleOneTapAuthAvailableFingerprint,
GoogleAuthAvailableFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
listOf(
GoogleOneTapAuthAvailableFingerprint,
GoogleAuthAvailableFingerprint
).forEach {
with(it.result!!.mutableMethod) {
addInstructions(
0,
"""
const/4 v0, 0x0
return v0
"""
)
}
}
return PatchResultSuccess()
}
}