2023-09-20 05:33:02 +02:00
|
|
|
package app.revanced.patches.youtube.layout.spoofappversion
|
2023-01-10 19:27:53 +01:00
|
|
|
|
2023-08-27 21:40:49 +02:00
|
|
|
import app.revanced.extensions.exception
|
2023-01-10 19:27:53 +01:00
|
|
|
import app.revanced.patcher.data.BytecodeContext
|
2023-06-07 03:46:13 +02:00
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
2023-01-10 19:27:53 +01:00
|
|
|
import app.revanced.patcher.patch.BytecodePatch
|
2023-09-20 05:33:02 +02:00
|
|
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
|
|
|
import app.revanced.patcher.patch.annotation.Patch
|
2023-04-28 19:52:22 +02:00
|
|
|
import app.revanced.patches.shared.settings.preference.impl.ArrayResource
|
|
|
|
import app.revanced.patches.shared.settings.preference.impl.ListPreference
|
2023-01-10 19:27:53 +01:00
|
|
|
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
|
|
|
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
2023-09-20 05:33:02 +02:00
|
|
|
import app.revanced.patches.youtube.layout.spoofappversion.fingerprints.SpoofAppVersionFingerprint
|
|
|
|
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
|
|
|
|
import app.revanced.patches.youtube.misc.settings.SettingsPatch
|
2023-08-27 21:40:49 +02:00
|
|
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
2023-01-10 19:27:53 +01:00
|
|
|
|
2023-09-20 05:33:02 +02:00
|
|
|
@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.",
|
|
|
|
dependencies = [IntegrationsPatch::class, SettingsPatch::class],
|
|
|
|
compatiblePackages = [
|
|
|
|
CompatiblePackage(
|
|
|
|
"com.google.android.youtube", [
|
|
|
|
"18.16.37",
|
|
|
|
"18.19.35",
|
|
|
|
"18.20.39",
|
|
|
|
"18.23.35",
|
|
|
|
"18.29.38",
|
2023-09-28 01:28:25 +02:00
|
|
|
"18.32.39",
|
|
|
|
"18.37.36"
|
2023-09-20 05:33:02 +02:00
|
|
|
]
|
|
|
|
)
|
|
|
|
]
|
|
|
|
)
|
|
|
|
@Suppress("unused")
|
|
|
|
object SpoofAppVersionPatch : BytecodePatch(
|
|
|
|
setOf(SpoofAppVersionFingerprint)
|
2023-01-10 19:27:53 +01:00
|
|
|
) {
|
2023-09-20 05:33:02 +02:00
|
|
|
private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/SpoofAppVersionPatch"
|
|
|
|
|
2023-08-27 21:40:49 +02:00
|
|
|
override fun execute(context: BytecodeContext) {
|
2023-01-10 19:27:53 +01:00
|
|
|
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
|
|
|
SwitchPreference(
|
|
|
|
"revanced_spoof_app_version",
|
|
|
|
StringResource("revanced_spoof_app_version_title", "Spoof app version"),
|
2023-04-28 19:52:22 +02:00
|
|
|
StringResource("revanced_spoof_app_version_summary_on", "Version spoofed"),
|
2023-04-05 10:25:12 +02:00
|
|
|
StringResource("revanced_spoof_app_version_summary_off", "Version not spoofed"),
|
|
|
|
StringResource("revanced_spoof_app_version_user_dialog_message",
|
2023-05-15 09:51:43 +02:00
|
|
|
"App version will be spoofed to an older version of YouTube."
|
|
|
|
+ "\\n\\nThis will change the appearance and features of the app, but unknown side effects may occur."
|
2023-07-20 22:34:17 +02:00
|
|
|
+ "\\n\\nIf later turned off, the old UI may remain until the app data is cleared.")
|
2023-04-28 19:52:22 +02:00
|
|
|
),
|
|
|
|
ListPreference(
|
|
|
|
"revanced_spoof_app_version_target",
|
|
|
|
StringResource(
|
|
|
|
"revanced_spoof_app_version_target_title",
|
|
|
|
"Spoof app version target"
|
|
|
|
),
|
|
|
|
ArrayResource(
|
|
|
|
"revanced_spoof_app_version_target_entries",
|
|
|
|
listOf(
|
2023-09-20 21:36:35 +02:00
|
|
|
StringResource("revanced_spoof_app_version_target_entry_1", "18.20.39 - Restore wide video speed & quality menu"),
|
|
|
|
StringResource("revanced_spoof_app_version_target_entry_2", "17.08.35 - Restore old UI layout"),
|
|
|
|
StringResource("revanced_spoof_app_version_target_entry_3", "16.08.35 - Restore explore tab"),
|
|
|
|
StringResource("revanced_spoof_app_version_target_entry_4", "16.01.35 - Restore old Shorts player"),
|
2023-04-28 19:52:22 +02:00
|
|
|
)
|
|
|
|
),
|
|
|
|
ArrayResource(
|
|
|
|
"revanced_spoof_app_version_target_entry_values",
|
|
|
|
listOf(
|
2023-09-20 21:36:35 +02:00
|
|
|
StringResource("revanced_spoof_app_version_target_entry_value_1", "18.20.39"),
|
|
|
|
StringResource("revanced_spoof_app_version_target_entry_value_2", "17.08.35"),
|
|
|
|
StringResource("revanced_spoof_app_version_target_entry_value_3", "16.08.35"),
|
|
|
|
StringResource("revanced_spoof_app_version_target_entry_value_4", "16.01.35"),
|
2023-04-28 19:52:22 +02:00
|
|
|
)
|
|
|
|
)
|
2023-01-10 19:27:53 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
SpoofAppVersionFingerprint.result?.apply {
|
|
|
|
val insertIndex = scanResult.patternScanResult!!.startIndex + 1
|
|
|
|
val buildOverrideNameRegister =
|
|
|
|
(mutableMethod.implementation!!.instructions[insertIndex - 1] as OneRegisterInstruction).registerA
|
|
|
|
|
|
|
|
mutableMethod.addInstructions(
|
|
|
|
insertIndex,
|
|
|
|
"""
|
2023-06-07 03:46:13 +02:00
|
|
|
invoke-static {v$buildOverrideNameRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR;->getYouTubeVersionOverride(Ljava/lang/String;)Ljava/lang/String;
|
|
|
|
move-result-object v$buildOverrideNameRegister
|
|
|
|
"""
|
2023-01-10 19:27:53 +01:00
|
|
|
)
|
2023-08-27 21:40:49 +02:00
|
|
|
} ?: throw SpoofAppVersionFingerprint.exception
|
2023-01-10 19:27:53 +01:00
|
|
|
}
|
2023-07-28 23:14:22 +02:00
|
|
|
}
|