feat(spoof-app-version): rename patch (enable-old-layoutspoof-app-version)

This commit is contained in:
inotia00
2023-04-30 18:14:25 +09:00
parent e80997c246
commit ed32eddd71
5 changed files with 56 additions and 84 deletions

View File

@ -1,14 +0,0 @@
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"
}
)

View File

@ -1,64 +0,0 @@
package app.revanced.patches.youtube.misc.oldlayout.patch
import app.revanced.extensions.toErrorResult
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.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.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
@Patch
@Name("enable-old-layout")
@Description("Spoof the YouTube client version to use the old layout.")
@DependsOn(
[
GeneralVersionSpoofPatch::class,
PatchOptions::class,
SettingsPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class OldLayoutPatch : BytecodePatch(
listOf(
VersionOverrideFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
GeneralVersionSpoofPatch.injectSpoof("$MISC_PATH/VersionOverridePatch;->getVersionOverride(Ljava/lang/String;)Ljava/lang/String;")
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
*/
SettingsPatch.addPreference(
arrayOf(
"SETTINGS: ENABLE_OLD_LAYOUT"
)
)
SettingsPatch.updatePatchStatus("enable-old-layout")
return PatchResultSuccess()
}
}

View File

@ -0,0 +1,47 @@
package app.revanced.patches.youtube.misc.spoofappversion.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
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.shared.patch.versionspoof.GeneralVersionSpoofPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.MISC_PATH
import app.revanced.util.resources.ResourceUtils.copyXmlNode
@Patch
@Name("spoof-app-version")
@Description("Tricks YouTube into thinking, you are running an older version of the app. One of the side effects also includes restoring the old UI.")
@DependsOn(
[
GeneralVersionSpoofPatch::class,
SettingsPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class SpoofAppVersionPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
GeneralVersionSpoofPatch.injectSpoof("$MISC_PATH/VersionOverridePatch;->getVersionOverride(Ljava/lang/String;)Ljava/lang/String;")
/**
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"SETTINGS: SPOOF_APP_VERSION"
)
)
SettingsPatch.updatePatchStatus("spoof-app-version")
return PatchResultSuccess()
}
}