mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-04-29 22:24:31 +02:00
feat(tiktok): bump compatibility to 29.3.4
This commit is contained in:
parent
43d22014c7
commit
7f3f75dc44
@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Package
|
|||||||
|
|
||||||
@Compatibility(
|
@Compatibility(
|
||||||
[
|
[
|
||||||
Package("com.ss.android.ugc.trill", arrayOf("27.8.3")),
|
Package("com.ss.android.ugc.trill", arrayOf("27.8.3", "29.3.4")),
|
||||||
Package("com.zhiliaoapp.musically", arrayOf("27.8.3"))
|
Package("com.zhiliaoapp.musically", arrayOf("27.8.3", "29.3.4"))
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package app.revanced.patches.tiktok.feedfilter.fingerprints
|
package app.revanced.patches.tiktok.feedfilter.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
object FeedApiServiceLIZFingerprint : MethodFingerprint(
|
object FeedApiServiceLIZFingerprint : MethodFingerprint(
|
||||||
access = AccessFlags.PUBLIC or AccessFlags.STATIC or AccessFlags.SYNTHETIC,
|
opcodes = listOf(
|
||||||
customFingerprint = { methodDef ->
|
Opcode.RETURN_OBJECT,
|
||||||
methodDef.definingClass.endsWith("/FeedApiService;") && methodDef.name == "LIZ"
|
Opcode.MOVE_EXCEPTION
|
||||||
}
|
),
|
||||||
|
customFingerprint = { it.definingClass.endsWith("/FeedApiService;") }
|
||||||
)
|
)
|
@ -1,5 +1,6 @@
|
|||||||
package app.revanced.patches.tiktok.feedfilter.patch
|
package app.revanced.patches.tiktok.feedfilter.patch
|
||||||
|
|
||||||
|
import app.revanced.extensions.toErrorResult
|
||||||
import app.revanced.patcher.annotation.Description
|
import app.revanced.patcher.annotation.Description
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
@ -15,7 +16,6 @@ import app.revanced.patches.tiktok.feedfilter.fingerprints.FeedApiServiceLIZFing
|
|||||||
import app.revanced.patches.tiktok.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.tiktok.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsStatusLoadFingerprint
|
import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsStatusLoadFingerprint
|
||||||
import app.revanced.patches.tiktok.misc.settings.patch.SettingsPatch
|
import app.revanced.patches.tiktok.misc.settings.patch.SettingsPatch
|
||||||
import org.jf.dexlib2.Opcode
|
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@ -31,21 +31,24 @@ class FeedFilterPatch : BytecodePatch(
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
val method = FeedApiServiceLIZFingerprint.result!!.mutableMethod
|
|
||||||
for ((index, instruction) in method.implementation!!.instructions.withIndex()) {
|
FeedApiServiceLIZFingerprint.result?.let {
|
||||||
if (instruction.opcode != Opcode.RETURN_OBJECT) continue
|
val index = it.scanResult.patternScanResult!!.startIndex
|
||||||
val feedItemsRegister = (instruction as OneRegisterInstruction).registerA
|
|
||||||
method.addInstruction(
|
with (it.mutableMethod) {
|
||||||
index,
|
val register = (this.implementation!!.instructions[index] as OneRegisterInstruction).registerA
|
||||||
"invoke-static {v$feedItemsRegister}, Lapp/revanced/tiktok/feedfilter/FeedItemsFilter;->filter(Lcom/ss/android/ugc/aweme/feed/model/FeedItemList;)V"
|
addInstruction(
|
||||||
)
|
index,
|
||||||
break
|
"invoke-static {v$register}, Lapp/revanced/tiktok/feedfilter/FeedItemsFilter;->filter(Lcom/ss/android/ugc/aweme/feed/model/FeedItemList;)V"
|
||||||
}
|
)
|
||||||
val method2 = SettingsStatusLoadFingerprint.result!!.mutableMethod
|
}
|
||||||
method2.addInstruction(
|
} ?: return FeedApiServiceLIZFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
SettingsStatusLoadFingerprint.result?.mutableMethod?.addInstruction(
|
||||||
0,
|
0,
|
||||||
"invoke-static {}, Lapp/revanced/tiktok/settingsmenu/SettingsStatus;->enableFeedFilter()V"
|
"invoke-static {}, Lapp/revanced/tiktok/settingsmenu/SettingsStatus;->enableFeedFilter()V"
|
||||||
)
|
) ?: return SettingsStatusLoadFingerprint.toErrorResult()
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Package
|
|||||||
|
|
||||||
@Compatibility(
|
@Compatibility(
|
||||||
[
|
[
|
||||||
Package("com.ss.android.ugc.trill", arrayOf("27.8.3")),
|
Package("com.ss.android.ugc.trill", arrayOf("27.8.3", "29.3.4")),
|
||||||
Package("com.zhiliaoapp.musically", arrayOf("27.8.3"))
|
Package("com.zhiliaoapp.musically", arrayOf("27.8.3", "29.3.4"))
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Package
|
|||||||
|
|
||||||
@Compatibility(
|
@Compatibility(
|
||||||
[
|
[
|
||||||
Package("com.ss.android.ugc.trill", arrayOf("27.8.3")),
|
Package("com.ss.android.ugc.trill", arrayOf("27.8.3", "29.3.4")),
|
||||||
Package("com.zhiliaoapp.musically", arrayOf("27.8.3"))
|
Package("com.zhiliaoapp.musically", arrayOf("27.8.3", "29.3.4"))
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package app.revanced.patches.tiktok.misc.settings.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
object AboutPageFingerprint : MethodFingerprint(
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.CONST,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.CONST_STRING
|
||||||
|
),
|
||||||
|
customFingerprint = {
|
||||||
|
it.definingClass == "Lcom/ss/android/ugc/aweme/setting/page/AboutPage;" &&
|
||||||
|
it.name == "onViewCreated"
|
||||||
|
}
|
||||||
|
)
|
@ -1,37 +0,0 @@
|
|||||||
package app.revanced.patches.tiktok.misc.settings.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
import org.jf.dexlib2.Opcode
|
|
||||||
|
|
||||||
@FuzzyPatternScanMethod(4)
|
|
||||||
object AboutViewFingerprint : MethodFingerprint(
|
|
||||||
opcodes = listOf(
|
|
||||||
Opcode.NEW_INSTANCE,
|
|
||||||
Opcode.INVOKE_DIRECT,
|
|
||||||
Opcode.INVOKE_DIRECT_RANGE,
|
|
||||||
Opcode.INVOKE_DIRECT,
|
|
||||||
Opcode.IPUT_OBJECT,
|
|
||||||
Opcode.NEW_INSTANCE,
|
|
||||||
Opcode.NEW_INSTANCE,
|
|
||||||
Opcode.CONST,
|
|
||||||
Opcode.INVOKE_VIRTUAL,
|
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
|
||||||
Opcode.SGET_OBJECT,
|
|
||||||
Opcode.INVOKE_STATIC,
|
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
|
||||||
Opcode.NEW_INSTANCE,
|
|
||||||
Opcode.INVOKE_DIRECT,
|
|
||||||
Opcode.CONST_4,
|
|
||||||
Opcode.CONST_STRING,
|
|
||||||
Opcode.INVOKE_DIRECT_RANGE,
|
|
||||||
Opcode.INVOKE_DIRECT,
|
|
||||||
Opcode.IPUT_OBJECT,
|
|
||||||
Opcode.CONST,
|
|
||||||
Opcode.SGET_OBJECT,
|
|
||||||
Opcode.INVOKE_VIRTUAL,
|
|
||||||
Opcode.MOVE_RESULT,
|
|
||||||
Opcode.IF_EQZ,
|
|
||||||
Opcode.CONST
|
|
||||||
)
|
|
||||||
)
|
|
@ -8,23 +8,24 @@ import app.revanced.patcher.data.BytecodeContext
|
|||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.instruction
|
import app.revanced.patcher.extensions.instruction
|
||||||
import app.revanced.patcher.extensions.replaceInstruction
|
import app.revanced.patcher.extensions.replaceInstruction
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultError
|
import app.revanced.patcher.patch.PatchResultError
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import app.revanced.patches.tiktok.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.tiktok.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.tiktok.misc.settings.annotations.SettingsCompatibility
|
import app.revanced.patches.tiktok.misc.settings.annotations.SettingsCompatibility
|
||||||
import app.revanced.patches.tiktok.misc.settings.fingerprints.AboutViewFingerprint
|
import app.revanced.patches.tiktok.misc.settings.fingerprints.AboutPageFingerprint
|
||||||
import app.revanced.patches.tiktok.misc.settings.fingerprints.AdPersonalizationActivityOnCreateFingerprint
|
import app.revanced.patches.tiktok.misc.settings.fingerprints.AdPersonalizationActivityOnCreateFingerprint
|
||||||
import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsOnViewCreatedFingerprint
|
import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsOnViewCreatedFingerprint
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
|
import org.jf.dexlib2.builder.instruction.BuilderInstruction21c
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
||||||
import org.jf.dexlib2.iface.reference.StringReference
|
|
||||||
import org.jf.dexlib2.iface.reference.TypeReference
|
import org.jf.dexlib2.iface.reference.TypeReference
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@ -35,77 +36,82 @@ import org.jf.dexlib2.iface.reference.TypeReference
|
|||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class SettingsPatch : BytecodePatch(
|
class SettingsPatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
|
AboutPageFingerprint,
|
||||||
AdPersonalizationActivityOnCreateFingerprint,
|
AdPersonalizationActivityOnCreateFingerprint,
|
||||||
SettingsOnViewCreatedFingerprint,
|
SettingsOnViewCreatedFingerprint,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
SettingsOnViewCreatedFingerprint.result?.let {
|
|
||||||
AboutViewFingerprint.resolve(context, it.method, it.classDef)
|
AboutPageFingerprint.result?.let {
|
||||||
}
|
val startIndex = it.scanResult.patternScanResult!!.startIndex
|
||||||
// Patch Settings UI to add 'Revanced Settings'.
|
|
||||||
val targetIndexes = findOptionsOnClickIndex()
|
with(it.mutableMethod.implementation!!.instructions) {
|
||||||
with(SettingsOnViewCreatedFingerprint.result!!.mutableMethod) {
|
copyrightPolicyLabelId = (this[startIndex] as WideLiteralInstruction).wideLiteral
|
||||||
for (index in targetIndexes) {
|
|
||||||
if (
|
|
||||||
instruction(index).opcode != Opcode.NEW_INSTANCE ||
|
|
||||||
instruction(index - 4).opcode != Opcode.MOVE_RESULT_OBJECT
|
|
||||||
)
|
|
||||||
return PatchResultError("Hardcode offset changed.")
|
|
||||||
patchOptionNameAndOnClickEvent(index, context)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Implement settings screen in `AdPersonalizationActivity`
|
} ?: return AboutPageFingerprint.toErrorResult()
|
||||||
with(AdPersonalizationActivityOnCreateFingerprint.result!!.mutableMethod) {
|
|
||||||
for ((index, instruction) in implementation!!.instructions.withIndex()) {
|
SettingsOnViewCreatedFingerprint.result?.mutableMethod?.let { method ->
|
||||||
|
val copyrightInstructions = method.implementation!!.instructions
|
||||||
|
|
||||||
|
val copyrightIndex = copyrightInstructions.indexOfFirst {
|
||||||
|
it.opcode == Opcode.CONST_STRING &&
|
||||||
|
(it as BuilderInstruction21c).reference.toString() == "copyright_policy"
|
||||||
|
} - 6
|
||||||
|
|
||||||
|
val copyrightPolicyIndex = copyrightInstructions.indexOfFirst {
|
||||||
|
it.opcode == Opcode.CONST &&
|
||||||
|
(it as WideLiteralInstruction).wideLiteral == copyrightPolicyLabelId
|
||||||
|
} + 2
|
||||||
|
|
||||||
|
arrayOf(
|
||||||
|
copyrightIndex,
|
||||||
|
copyrightPolicyIndex
|
||||||
|
).forEach {
|
||||||
|
if (method.instruction(it).opcode != Opcode.MOVE_RESULT_OBJECT)
|
||||||
|
return PatchResultError("Hardcode offset changed.")
|
||||||
|
val register = (method.instruction(it) as OneRegisterInstruction).registerA
|
||||||
|
|
||||||
|
method.insertSettings(context, it, register)
|
||||||
|
}
|
||||||
|
|
||||||
|
} ?: return SettingsOnViewCreatedFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
AdPersonalizationActivityOnCreateFingerprint.result?.mutableMethod?.let {
|
||||||
|
for ((index, instruction) in it.implementation!!.instructions.withIndex()) {
|
||||||
if (instruction.opcode != Opcode.INVOKE_SUPER) continue
|
if (instruction.opcode != Opcode.INVOKE_SUPER) continue
|
||||||
val thisRegister = (instruction as Instruction35c).registerC
|
val thisRegister = (instruction as Instruction35c).registerC
|
||||||
addInstructions(
|
it.addInstructions(
|
||||||
index + 1,
|
index + 1,
|
||||||
"""
|
"""
|
||||||
invoke-static {v$thisRegister}, Lapp/revanced/tiktok/settingsmenu/SettingsMenu;->initializeSettings(Lcom/bytedance/ies/ugc/aweme/commercialize/compliance/personalization/AdPersonalizationActivity;)V
|
invoke-static {v$thisRegister}, Lapp/revanced/tiktok/settingsmenu/SettingsMenu;->initializeSettings(Lcom/bytedance/ies/ugc/aweme/commercialize/compliance/personalization/AdPersonalizationActivity;)V
|
||||||
return-void
|
return-void
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
break
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
}
|
} ?: return AdPersonalizationActivityOnCreateFingerprint.toErrorResult()
|
||||||
return PatchResultSuccess()
|
|
||||||
|
return PatchResultError("Could not find the method to hook.")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findOptionsOnClickIndex(): IntArray {
|
private companion object {
|
||||||
val results = IntArray(2)
|
var copyrightPolicyLabelId: Long = -1
|
||||||
SettingsOnViewCreatedFingerprint.result?.apply {
|
|
||||||
for ((index, instruction) in mutableMethod.implementation!!.instructions.withIndex()) {
|
|
||||||
// Old UI settings option to replace to 'Revanced Settings'
|
|
||||||
if (instruction.opcode == Opcode.CONST_STRING) {
|
|
||||||
val string = ((instruction as ReferenceInstruction).reference as StringReference).string
|
|
||||||
if (string == "copyright_policy") {
|
|
||||||
results[0] = index - 2
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// New UI settings option to replace to 'Revanced Settings'
|
fun MutableMethod.insertSettings(
|
||||||
results[1] = AboutViewFingerprint.result!!.scanResult.patternScanResult!!.startIndex
|
context: BytecodeContext,
|
||||||
} ?: throw SettingsOnViewCreatedFingerprint.toErrorResult()
|
index: Int,
|
||||||
return results
|
overrideRegister: Int
|
||||||
}
|
) {
|
||||||
|
|
||||||
private fun patchOptionNameAndOnClickEvent(index: Int, context: BytecodeContext) {
|
|
||||||
with(SettingsOnViewCreatedFingerprint.result!!.mutableMethod) {
|
|
||||||
// Patch option name
|
|
||||||
val overrideRegister = (instruction(index - 4) as OneRegisterInstruction).registerA
|
|
||||||
replaceInstruction(
|
replaceInstruction(
|
||||||
index - 4,
|
index,
|
||||||
"""
|
"""
|
||||||
const-string v$overrideRegister, "Revanced Settings"
|
const-string v$overrideRegister, "Revanced Settings"
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
// Patch option OnClick Event
|
with(((instruction(index + 4) as ReferenceInstruction).reference as TypeReference).type) {
|
||||||
with(((instruction(index) as ReferenceInstruction).reference as TypeReference).type) {
|
|
||||||
context.findClass(this)!!.mutableClass.methods.first { it.name == "onClick" }
|
context.findClass(this)!!.mutableClass.methods.first { it.name == "onClick" }
|
||||||
.addInstructions(
|
.addInstructions(
|
||||||
0,
|
0,
|
||||||
|
@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Package
|
|||||||
|
|
||||||
@Compatibility(
|
@Compatibility(
|
||||||
[
|
[
|
||||||
Package("com.ss.android.ugc.trill", arrayOf("27.8.3")),
|
Package("com.ss.android.ugc.trill", arrayOf("27.8.3", "29.3.4")),
|
||||||
Package("com.zhiliaoapp.musically", arrayOf("27.8.3"))
|
Package("com.zhiliaoapp.musically", arrayOf("27.8.3", "29.3.4"))
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user