mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 13:17:46 +02:00
refactor(enable-old-layout
): no longer changes the version shown in app settings
This commit is contained in:
@ -1,18 +0,0 @@
|
||||
package app.revanced.patches.youtube.misc.oldlayout.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object OldLayoutFingerprint : MethodFingerprint(
|
||||
returnType = "L",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||
parameters = listOf("L"),
|
||||
opcodes = listOf(
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.GOTO,
|
||||
Opcode.CONST_STRING,
|
||||
),
|
||||
strings = listOf("Unset")
|
||||
)
|
@ -0,0 +1,14 @@
|
||||
package app.revanced.patches.youtube.misc.oldlayout.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object VersionOverrideFingerprint : MethodFingerprint(
|
||||
opcodes = listOf(
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.CONST_STRING
|
||||
),
|
||||
customFingerprint = {
|
||||
it.definingClass.endsWith("VersionOverridePatch;") && it.name == "getVersionOverride"
|
||||
}
|
||||
)
|
@ -5,44 +5,48 @@ 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.extensions.replaceInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.misc.oldlayout.fingerprints.OldLayoutFingerprint
|
||||
import app.revanced.patches.shared.patch.options.PatchOptions
|
||||
import app.revanced.patches.shared.patch.versionspoof.GeneralVersionSpoofPatch
|
||||
import app.revanced.patches.youtube.misc.oldlayout.fingerprints.VersionOverrideFingerprint
|
||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.MISC_PATH
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@Name("enable-old-layout")
|
||||
@Description("Spoof the YouTube client version to use the old layout.")
|
||||
@DependsOn([SettingsPatch::class])
|
||||
@DependsOn(
|
||||
[
|
||||
GeneralVersionSpoofPatch::class,
|
||||
PatchOptions::class,
|
||||
SettingsPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class OldLayoutPatch : BytecodePatch(
|
||||
listOf(
|
||||
OldLayoutFingerprint
|
||||
VersionOverrideFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
OldLayoutFingerprint.result?.let {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
GeneralVersionSpoofPatch.injectSpoof("$MISC_PATH/VersionOverridePatch;->getVersionOverride(Ljava/lang/String;)Ljava/lang/String;")
|
||||
|
||||
with (it.mutableMethod) {
|
||||
val register = (this.implementation!!.instructions[insertIndex] as OneRegisterInstruction).registerA
|
||||
addInstructions(
|
||||
insertIndex + 1, """
|
||||
invoke-static {v$register}, $MISC_PATH/VersionOverridePatch;->getVersionOverride(Ljava/lang/String;)Ljava/lang/String;
|
||||
move-result-object v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: return OldLayoutFingerprint.toErrorResult()
|
||||
val clientSpoofVersion = PatchOptions.clientSpoofVersion!!
|
||||
|
||||
VersionOverrideFingerprint.result?.let {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
|
||||
it.mutableMethod.replaceInstruction(insertIndex, "const-string p0, \"$clientSpoofVersion\"")
|
||||
|
||||
} ?: return VersionOverrideFingerprint.toErrorResult()
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
|
Reference in New Issue
Block a user