From 730f3e3a7e058b60f9a8130980ecb0a747fa0a8a Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 21 Apr 2024 03:15:31 +0400 Subject: [PATCH] feat(YouTube): Support version `19.09.38`, `19.10.39` and `19.11.43` (#2971) Co-authored-by: oSumAtrIX --- api/revanced-patches.api | 4 +- .../misc/mapping/ResourceMappingPatch.kt | 22 +++--- .../navbar/PremiumNavbarTabResourcePatch.kt | 11 ++- .../youtube/ad/general/HideAdsPatch.kt | 4 +- .../ad/general/HideAdsResourcePatch.kt | 8 +-- .../ad/getpremium/HideGetPremiumPatch.kt | 4 +- .../patches/youtube/ad/video/VideoAdsPatch.kt | 4 +- .../copyvideourl/CopyVideoUrlBytecodePatch.kt | 4 +- .../RemoveViewerDiscretionDialogPatch.kt | 4 +- .../interaction/downloads/DownloadsPatch.kt | 4 +- .../DisablePreciseSeekingGesturePatch.kt | 4 +- .../seekbar/EnableSeekbarTappingPatch.kt | 4 +- .../seekbar/EnableSlideToSeekPatch.kt | 4 +- .../SwipeControlsBytecodePatch.kt | 23 ++++--- .../layout/autocaptions/AutoCaptionsPatch.kt | 4 +- .../layout/buttons/action/HideButtonsPatch.kt | 4 +- .../autoplay/HideAutoplayButtonPatch.kt | 24 ++++--- .../captions/HideCaptionsButtonPatch.kt | 4 +- .../navigation/NavigationButtonsPatch.kt | 4 +- .../player/hide/HidePlayerButtonsPatch.kt | 4 +- .../layout/hide/albumcards/AlbumCardsPatch.kt | 4 +- .../albumcards/AlbumCardsResourcePatch.kt | 10 ++- .../layout/hide/comments/CommentsPatch.kt | 4 +- .../crowdfundingbox/CrowdfundingBoxPatch.kt | 4 +- .../CrowdfundingBoxResourcePatch.kt | 13 ++-- .../endscreencards/HideEndscreenCardsPatch.kt | 4 +- .../HideEndscreenCardsResourcePatch.kt | 16 ++--- .../hide/filterbar/HideFilterBarPatch.kt | 4 +- .../filterbar/HideFilterBarResourcePatch.kt | 15 ++-- .../HideFloatingMicrophoneButtonPatch.kt | 4 +- ...deFloatingMicrophoneButtonResourcePatch.kt | 10 ++- .../DisableFullscreenAmbientModePatch.kt | 4 +- .../hide/general/HideLayoutComponentsPatch.kt | 4 +- .../HideLayoutComponentsResourcePatch.kt | 14 ++-- .../hide/infocards/HideInfoCardsPatch.kt | 4 +- .../infocards/HideInfocardsResourcePatch.kt | 13 ++-- .../HidePlayerFlyoutMenuPatch.kt | 4 +- .../DisableRollingNumberAnimationPatch.kt | 4 +- .../layout/hide/seekbar/HideSeekbarPatch.kt | 4 +- .../hide/shorts/HideShortsComponentsPatch.kt | 44 ++++++------ .../HideShortsComponentsResourcePatch.kt | 22 +++--- .../CreateShortsButtonsFingerprint.kt | 5 +- .../DisableSuggestedVideoEndScreenPatch.kt | 4 +- ...bleSuggestedVideoEndScreenResourcePatch.kt | 13 ++-- .../layout/hide/time/HideTimestampPatch.kt | 4 +- .../panels/popup/PlayerPopupPanelsPatch.kt | 4 +- .../PlayerControlsBackgroundPatch.kt | 4 +- ...CustomPlayerOverlayOpacityResourcePatch.kt | 11 +-- .../ReturnYouTubeDislikePatch.kt | 4 +- .../ReturnYouTubeDislikeResourcePatch.kt | 15 ++-- .../layout/searchbar/WideSearchbarPatch.kt | 4 +- .../RestoreOldSeekbarThumbnailsPatch.kt | 4 +- .../seekbar/SeekbarColorResourcePatch.kt | 31 ++++----- .../sponsorblock/SponsorBlockBytecodePatch.kt | 54 ++++++++------- .../spoofappversion/SpoofAppVersionPatch.kt | 4 +- .../DisableResumingShortsOnStartupPatch.kt | 4 +- .../tabletminiplayer/TabletMiniPlayerPatch.kt | 4 +- ...erDimensionsCalculatorParentFingerprint.kt | 2 +- .../layout/theme/ThemeBytecodePatch.kt | 4 +- .../thumbnails/AlternativeThumbnailsPatch.kt | 4 +- .../misc/autorepeat/AutoRepeatPatch.kt | 4 +- .../spoof/SpoofDeviceDimensionsPatch.kt | 4 +- .../playback/SpoofSignatureResourcePatch.kt | 7 +- .../youtube/misc/gms/GmsCoreSupportPatch.kt | 4 +- .../misc/links/BypassURLRedirectsPatch.kt | 4 +- .../misc/links/OpenLinksExternallyPatch.kt | 4 +- .../MinimizedPlaybackPatch.kt | 4 +- .../NavigationBarHookResourcePatch.kt | 13 ++-- .../BottomControlsResourcePatch.kt | 3 +- .../RemoveTrackingQueryParameterPatch.kt | 4 +- .../misc/settings/SettingsResourcePatch.kt | 5 +- .../quality/RememberVideoQualityPatch.kt | 4 +- .../youtube/video/speed/PlaybackSpeedPatch.kt | 4 +- .../CustomPlaybackSpeedResourcePatch.kt | 9 +-- .../RestoreOldVideoQualityMenuPatch.kt | 4 +- ...RestoreOldVideoQualityMenuResourcePatch.kt | 13 ++-- .../kotlin/app/revanced/util/BytecodeUtils.kt | 68 ++++++++++++------- 77 files changed, 402 insertions(+), 288 deletions(-) diff --git a/api/revanced-patches.api b/api/revanced-patches.api index d61454ba1..6ee21cc71 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -724,6 +724,7 @@ public final class app/revanced/patches/shared/misc/mapping/ResourceMappingPatch public static final field INSTANCE Lapp/revanced/patches/shared/misc/mapping/ResourceMappingPatch; public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V + public final fun get (Ljava/lang/String;Ljava/lang/String;)J } public final class app/revanced/patches/shared/misc/mapping/ResourceMappingPatch$ResourceElement { @@ -1846,11 +1847,12 @@ public final class app/revanced/patches/yuka/misc/unlockpremium/UnlockPremiumPat public final class app/revanced/util/BytecodeUtilsKt { public static final fun containsWideLiteralInstructionValue (Lcom/android/tools/smali/dexlib2/iface/Method;J)Z - public static final fun findIndexForIdResource (Lcom/android/tools/smali/dexlib2/iface/Method;Ljava/lang/String;)I public static final fun findMutableMethodOf (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;Lcom/android/tools/smali/dexlib2/iface/Method;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod; public static final fun getException (Lapp/revanced/patcher/fingerprint/MethodFingerprint;)Lapp/revanced/patcher/patch/PatchException; public static final fun indexOfFirstInstruction (Lcom/android/tools/smali/dexlib2/iface/Method;Lkotlin/jvm/functions/Function1;)I public static final fun indexOfFirstWideLiteralInstructionValue (Lcom/android/tools/smali/dexlib2/iface/Method;J)I + public static final fun indexOfIdResource (Lcom/android/tools/smali/dexlib2/iface/Method;Ljava/lang/String;)I + public static final fun indexOfIdResourceOrThrow (Lcom/android/tools/smali/dexlib2/iface/Method;Ljava/lang/String;)I public static final fun injectHideViewCall (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;IILjava/lang/String;Ljava/lang/String;)V public static final fun resultOrThrow (Lapp/revanced/patcher/fingerprint/MethodFingerprint;)Lapp/revanced/patcher/fingerprint/MethodFingerprintResult; public static final fun returnEarly (Ljava/util/List;Z)V diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/mapping/ResourceMappingPatch.kt b/src/main/kotlin/app/revanced/patches/shared/misc/mapping/ResourceMappingPatch.kt index 23831eb41..388c4ef61 100644 --- a/src/main/kotlin/app/revanced/patches/shared/misc/mapping/ResourceMappingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/mapping/ResourceMappingPatch.kt @@ -8,19 +8,15 @@ import java.util.concurrent.Executors import java.util.concurrent.TimeUnit object ResourceMappingPatch : ResourcePatch() { - internal lateinit var resourceMappings: List - private set + private val resourceMappings = Collections.synchronizedList(mutableListOf()) private val THREAD_COUNT = Runtime.getRuntime().availableProcessors() private val threadPoolExecutor = Executors.newFixedThreadPool(THREAD_COUNT) override fun execute(context: ResourceContext) { - // save the file in memory to concurrently read from + // sSve the file in memory to concurrently read from it. val resourceXmlFile = context.get("res/values/public.xml").readBytes() - // create a synchronized list to store the resource mappings - val mappings = Collections.synchronizedList(mutableListOf()) - for (threadIndex in 0 until THREAD_COUNT) { threadPoolExecutor.execute thread@{ context.xmlEditor[resourceXmlFile.inputStream()].use { editor -> @@ -33,7 +29,7 @@ object ResourceMappingPatch : ResourcePatch() { val batchStart = jobSize * threadIndex val batchEnd = jobSize * (threadIndex + 1) element@ for (i in batchStart until batchEnd) { - // make sure to not go out of bounds when rounding errors occur at calculating the jobSize + // Prevent out of bounds. if (i >= resourcesLength) return@thread val node = resources.item(i) @@ -46,18 +42,18 @@ object ResourceMappingPatch : ResourcePatch() { val id = node.getAttribute("id").substring(2).toLong(16) - mappings.add(ResourceElement(typeAttribute, nameAttribute, id)) + resourceMappings.add(ResourceElement(typeAttribute, nameAttribute, id)) } } } } - threadPoolExecutor - .also { it.shutdown() } - .awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS) - - resourceMappings = mappings + threadPoolExecutor.also { it.shutdown() }.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS) } + operator fun get(type: String, name: String) = resourceMappings.first { + it.type == type && it.name == name + }.id + data class ResourceElement(val type: String, val name: String, val id: Long) } diff --git a/src/main/kotlin/app/revanced/patches/spotify/navbar/PremiumNavbarTabResourcePatch.kt b/src/main/kotlin/app/revanced/patches/spotify/navbar/PremiumNavbarTabResourcePatch.kt index 5f2ac4b22..40018925d 100644 --- a/src/main/kotlin/app/revanced/patches/spotify/navbar/PremiumNavbarTabResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/spotify/navbar/PremiumNavbarTabResourcePatch.kt @@ -11,12 +11,11 @@ object PremiumNavbarTabResourcePatch : ResourcePatch() { internal var premiumTabId = -1L override fun execute(context: ResourceContext) { - premiumTabId = ResourceMappingPatch.resourceMappings.single { - it.type == "id" && it.name == "premium_tab" - }.id + premiumTabId = ResourceMappingPatch["id", "premium_tab"] - showBottomNavigationItemsTextId = ResourceMappingPatch.resourceMappings.single { - it.type == "bool" && it.name == "show_bottom_navigation_items_text" - }.id + showBottomNavigationItemsTextId = ResourceMappingPatch[ + "bool", + "show_bottom_navigation_items_text", + ] } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt index 063f033ec..99d73e4cd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt @@ -42,7 +42,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ], ), ], diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsResourcePatch.kt index ebf47807e..8cc3ed113 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsResourcePatch.kt @@ -14,8 +14,8 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch LithoFilterPatch::class, SettingsPatch::class, ResourceMappingPatch::class, - AddResourcesPatch::class - ] + AddResourcesPatch::class, + ], ) object HideAdsResourcePatch : ResourcePatch() { private const val FILTER_CLASS_DESCRIPTOR = @@ -35,11 +35,11 @@ object HideAdsResourcePatch : ResourcePatch() { SwitchPreference("revanced_hide_products_banner"), SwitchPreference("revanced_hide_shopping_links"), SwitchPreference("revanced_hide_web_search_results"), - SwitchPreference("revanced_hide_merchandise_banners") + SwitchPreference("revanced_hide_merchandise_banners"), ) LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR) - adAttributionId = ResourceMappingPatch.resourceMappings.single { it.name == "ad_attribution" }.id + adAttributionId = ResourceMappingPatch["id", "ad_attribution"] } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt index a90956e0f..b3094ea2c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt @@ -36,7 +36,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt index 06e496e0e..c000e0898 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt @@ -41,7 +41,9 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlBytecodePatch.kt index 89398b8d2..87d91821c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlBytecodePatch.kt @@ -29,7 +29,9 @@ import app.revanced.patches.youtube.video.information.VideoInformationPatch "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ], ), ], diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt index 7fdacaeff..a5de50f0b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt @@ -38,7 +38,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt index 6147a3d54..10e1de2de 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt @@ -35,7 +35,9 @@ import app.revanced.util.resultOrThrow "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ], ), ], diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt index e18a8f076..d3df068c2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt @@ -38,7 +38,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt index 3c4be5ad0..c428b2497 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt @@ -40,7 +40,9 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt index eb5ef93cd..a4c7de09e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt @@ -36,7 +36,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ], diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsBytecodePatch.kt index 5e21c6074..c49b74f59 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsBytecodePatch.kt @@ -20,7 +20,7 @@ import com.android.tools.smali.dexlib2.immutable.ImmutableMethod dependencies = [ IntegrationsPatch::class, PlayerTypeHookPatch::class, - SwipeControlsResourcePatch::class + SwipeControlsResourcePatch::class, ], compatiblePackages = [ CompatiblePackage( @@ -42,17 +42,22 @@ import com.android.tools.smali.dexlib2.immutable.ImmutableMethod "19.06.39", "19.07.40", "19.08.36", - "19.09.37" - ] - ) - ] + "19.09.38", + "19.10.39", + "19.11.43", // 19.12.x has an issue with opening YT using external links, + // and the app then crashes if double tap to skip forward/back is immediately used. + // The stack trace shows a call coming from integrations SwipeController, + // but it may be a bug in YT itself as other target versions do not have this issue. + ], + ), + ], ) @Suppress("unused") object SwipeControlsBytecodePatch : BytecodePatch( setOf( MainActivityFingerprint, - SwipeControlsHostActivityFingerprint - ) + SwipeControlsHostActivityFingerprint, + ), ) { override fun execute(context: BytecodeContext) { val wrapperClass = SwipeControlsHostActivityFingerprint.result!!.mutableClass @@ -74,9 +79,9 @@ object SwipeControlsBytecodePatch : BytecodePatch( accessFlags and AccessFlags.FINAL.value.inv(), annotations, hiddenApiRestrictions, - implementation + implementation, ).toMutable() } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt index 00f15cab3..188fa14b0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt @@ -40,7 +40,9 @@ import app.revanced.util.exception "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ], diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt index 2a6284827..deaebe49c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt @@ -39,7 +39,9 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt index d96caab79..6eba4ff47 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt @@ -14,7 +14,7 @@ import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.youtube.shared.fingerprints.LayoutConstructorFingerprint import app.revanced.util.exception -import app.revanced.util.findIndexForIdResource +import app.revanced.util.indexOfIdResourceOrThrow import com.android.tools.smali.dexlib2.iface.instruction.Instruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction @@ -27,7 +27,7 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference IntegrationsPatch::class, SettingsPatch::class, ResourceMappingPatch::class, - AddResourcesPatch::class + AddResourcesPatch::class, ], compatiblePackages = [ CompatiblePackage( @@ -49,27 +49,29 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference "19.06.39", "19.07.40", "19.08.36", - "19.09.37" - ] - ) - ] + "19.09.38", + "19.10.39", + "19.11.43", + ], + ), + ], ) @Suppress("unused") object HideAutoplayButtonPatch : BytecodePatch( - setOf(LayoutConstructorFingerprint) + setOf(LayoutConstructorFingerprint), ) { override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) SettingsPatch.PreferenceScreen.PLAYER.addPreferences( - SwitchPreference("revanced_hide_autoplay_button") + SwitchPreference("revanced_hide_autoplay_button"), ) LayoutConstructorFingerprint.result?.mutableMethod?.apply { val layoutGenMethodInstructions = implementation!!.instructions // resolve the offsets of where to insert the branch instructions and ... - val insertIndex = findIndexForIdResource("autonav_preview_stub") + val insertIndex = indexOfIdResourceOrThrow("autonav_preview_stub") // where to branch away val branchIndex = @@ -90,8 +92,8 @@ object HideAutoplayButtonPatch : BytecodePatch( move-result v$clobberRegister if-eqz v$clobberRegister, :hidden """, - ExternalLabel("hidden", jumpInstruction) + ExternalLabel("hidden", jumpInstruction), ) } ?: throw LayoutConstructorFingerprint.exception } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt index 88e856686..7ee8e1f3c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt @@ -40,7 +40,9 @@ import com.android.tools.smali.dexlib2.Opcode "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt index c660344de..1cdbe20d1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt @@ -47,7 +47,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37", + "19.09.38", + "19.10.39", + "19.11.43" ], ), ], diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt index b51f3270e..441709113 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt @@ -44,7 +44,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction3rc "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsPatch.kt index b11b24435..3877397a4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsPatch.kt @@ -38,7 +38,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsResourcePatch.kt index 08b54204f..e8265b68d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsResourcePatch.kt @@ -12,7 +12,7 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch dependencies = [ SettingsPatch::class, ResourceMappingPatch::class, - AddResourcesPatch::class + AddResourcesPatch::class, ], ) internal object AlbumCardsResourcePatch : ResourcePatch() { @@ -22,11 +22,9 @@ internal object AlbumCardsResourcePatch : ResourcePatch() { AddResourcesPatch(this::class) SettingsPatch.PreferenceScreen.FEED.addPreferences( - SwitchPreference("revanced_hide_album_cards") + SwitchPreference("revanced_hide_album_cards"), ) - albumCardId = ResourceMappingPatch.resourceMappings.single { - it.type == "layout" && it.name == "album_card" - }.id + albumCardId = ResourceMappingPatch["layout", "album_card"] } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt index fdc90bf69..9a6ee70e6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt @@ -38,7 +38,9 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxPatch.kt index b429d69a6..fa0f45934 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxPatch.kt @@ -38,7 +38,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxResourcePatch.kt index 4e61c0953..f1763704c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxResourcePatch.kt @@ -12,7 +12,7 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch dependencies = [ SettingsPatch::class, ResourceMappingPatch::class, - AddResourcesPatch::class + AddResourcesPatch::class, ], ) internal object CrowdfundingBoxResourcePatch : ResourcePatch() { @@ -22,11 +22,12 @@ internal object CrowdfundingBoxResourcePatch : ResourcePatch() { AddResourcesPatch(this::class) SettingsPatch.PreferenceScreen.FEED.addPreferences( - SwitchPreference("revanced_hide_crowdfunding_box") + SwitchPreference("revanced_hide_crowdfunding_box"), ) - crowdfundingBoxId = ResourceMappingPatch.resourceMappings.single { - it.type == "layout" && it.name == "donation_companion" - }.id + crowdfundingBoxId = ResourceMappingPatch[ + "layout", + "donation_companion", + ] } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt index aecd7cf12..02145fa5f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt @@ -41,7 +41,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction21c "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsResourcePatch.kt index 13231b7bd..40878824a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsResourcePatch.kt @@ -12,7 +12,7 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch dependencies = [ SettingsPatch::class, ResourceMappingPatch::class, - AddResourcesPatch::class + AddResourcesPatch::class, ], ) internal object HideEndscreenCardsResourcePatch : ResourcePatch() { @@ -24,15 +24,13 @@ internal object HideEndscreenCardsResourcePatch : ResourcePatch() { AddResourcesPatch(this::class) SettingsPatch.PreferenceScreen.PLAYER.addPreferences( - SwitchPreference("revanced_hide_endscreen_cards") + SwitchPreference("revanced_hide_endscreen_cards"), ) - fun findEndscreenResourceId(name: String) = ResourceMappingPatch.resourceMappings.single { - it.type == "layout" && it.name == "endscreen_element_layout_$name" - }.id + fun idOf(name: String) = ResourceMappingPatch["layout", "endscreen_element_layout_$name"] - layoutCircle = findEndscreenResourceId("circle") - layoutIcon = findEndscreenResourceId("icon") - layoutVideo = findEndscreenResourceId("video") + layoutCircle = idOf("circle") + layoutIcon = idOf("icon") + layoutVideo = idOf("video") } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarPatch.kt index 0a836aa5a..f63a78bf0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarPatch.kt @@ -38,7 +38,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarResourcePatch.kt index a10d22a09..d49df7a5b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarResourcePatch.kt @@ -25,15 +25,12 @@ internal object HideFilterBarResourcePatch : ResourcePatch() { SwitchPreference("revanced_hide_filter_bar_feed_in_feed"), SwitchPreference("revanced_hide_filter_bar_feed_in_search"), SwitchPreference("revanced_hide_filter_bar_feed_in_related_videos"), - ) - ) + ), + ), ) - relatedChipCloudMarginId = "related_chip_cloud_reduced_margins".layoutResourceId("layout") - filterBarHeightId = "filter_bar_height".layoutResourceId() - barContainerHeightId = "bar_container_height".layoutResourceId() + relatedChipCloudMarginId = ResourceMappingPatch["layout", "related_chip_cloud_reduced_margins"] + filterBarHeightId = ResourceMappingPatch["dimen", "filter_bar_height"] + barContainerHeightId = ResourceMappingPatch["dimen", "bar_container_height"] } - - private fun String.layoutResourceId(type: String = "dimen") = - ResourceMappingPatch.resourceMappings.single { it.type == type && it.name == this }.id -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonPatch.kt index 1b4606c4e..2ddda6f79 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonPatch.kt @@ -34,7 +34,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonResourcePatch.kt index 7dbd6a154..30dd8e84d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonResourcePatch.kt @@ -1,7 +1,6 @@ package app.revanced.patches.youtube.layout.hide.floatingmicrophone import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.all.misc.resources.AddResourcesPatch @@ -13,8 +12,8 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch dependencies = [ SettingsPatch::class, ResourceMappingPatch::class, - AddResourcesPatch::class - ] + AddResourcesPatch::class, + ], ) internal object HideFloatingMicrophoneButtonResourcePatch : ResourcePatch() { internal var fabButtonId: Long = -1 @@ -23,10 +22,9 @@ internal object HideFloatingMicrophoneButtonResourcePatch : ResourcePatch() { AddResourcesPatch(this::class) SettingsPatch.PreferenceScreen.GENERAL_LAYOUT.addPreferences( - SwitchPreference("revanced_hide_floating_microphone_button") + SwitchPreference("revanced_hide_floating_microphone_button"), ) - fabButtonId = ResourceMappingPatch.resourceMappings.find { it.type == "id" && it.name == "fab" }?.id - ?: throw PatchException("Can not find required fab button resource id") + fabButtonId = ResourceMappingPatch["id", "fab"] } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt index 0a4ea85b0..dcefb0d1a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt @@ -34,7 +34,9 @@ import app.revanced.util.exception "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt index 4025d8b51..8944dbbf9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt @@ -57,7 +57,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37", + "19.09.38", + "19.10.39", + "19.11.43" ], ), ], diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsResourcePatch.kt index 7b9dce7c5..c7b60d544 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsResourcePatch.kt @@ -5,22 +5,22 @@ import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch -import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch( dependencies = [ SettingsPatch::class, ResourceMappingPatch::class, - AddResourcesPatch::class - ] + AddResourcesPatch::class, + ], ) internal object HideLayoutComponentsResourcePatch : ResourcePatch() { internal var expandButtonDownId: Long = -1 override fun execute(context: ResourceContext) { - expandButtonDownId = ResourceMappingPatch.resourceMappings.single { - it.type == "layout" && it.name == "expand_button_down" - }.id + expandButtonDownId = ResourceMappingPatch[ + "layout", + "expand_button_down", + ] } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt index 7cb8d8658..cc8e17933 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt @@ -45,7 +45,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfocardsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfocardsResourcePatch.kt index 6ac2377fa..228cc1505 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfocardsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfocardsResourcePatch.kt @@ -12,7 +12,7 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch dependencies = [ SettingsPatch::class, ResourceMappingPatch::class, - AddResourcesPatch::class + AddResourcesPatch::class, ], ) object HideInfocardsResourcePatch : ResourcePatch() { @@ -22,11 +22,12 @@ object HideInfocardsResourcePatch : ResourcePatch() { AddResourcesPatch(this::class) SettingsPatch.PreferenceScreen.PLAYER.addPreferences( - SwitchPreference("revanced_hide_info_cards") + SwitchPreference("revanced_hide_info_cards"), ) - drawerResourceId = ResourceMappingPatch.resourceMappings.single { - it.type == "id" && it.name == "info_cards_drawer_header" - }.id + drawerResourceId = ResourceMappingPatch[ + "id", + "info_cards_drawer_header", + ] } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt index e81d050e4..9d1d48a90 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt @@ -39,7 +39,9 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt index 5758d813f..8ee810b97 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt @@ -36,7 +36,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt index 8e8434af9..485ec1044 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt @@ -41,7 +41,9 @@ import app.revanced.patches.youtube.shared.fingerprints.SeekbarOnDrawFingerprint "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt index d9db24b9d..3471c5dff 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt @@ -1,8 +1,5 @@ package app.revanced.patches.youtube.layout.hide.shorts -import app.revanced.util.exception -import app.revanced.util.findIndexForIdResource -import app.revanced.util.injectHideViewCall import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction @@ -15,6 +12,9 @@ import app.revanced.patches.youtube.layout.hide.shorts.fingerprints.* import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch import app.revanced.patches.youtube.misc.navigation.NavigationBarHookPatch +import app.revanced.util.exception +import app.revanced.util.indexOfIdResourceOrThrow +import app.revanced.util.injectHideViewCall import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction @@ -27,11 +27,12 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction LithoFilterPatch::class, HideShortsComponentsResourcePatch::class, ResourceMappingPatch::class, - NavigationBarHookPatch::class + NavigationBarHookPatch::class, ], compatiblePackages = [ CompatiblePackage( - "com.google.android.youtube", [ + "com.google.android.youtube", + [ "18.32.39", "18.37.36", "18.38.44", @@ -48,10 +49,12 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" - ] - ) - ] + "19.09.38", + "19.10.39", + "19.11.43", + ], + ), + ], ) @Suppress("unused") object HideShortsComponentsPatch : BytecodePatch( @@ -60,8 +63,8 @@ object HideShortsComponentsPatch : BytecodePatch( ReelConstructorFingerprint, BottomNavigationBarFingerprint, RenderBottomNavigationBarParentFingerprint, - SetPivotBarVisibilityParentFingerprint - ) + SetPivotBarVisibilityParentFingerprint, + ), ) { private const val FILTER_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/youtube/patches/components/ShortsFilter;" @@ -79,7 +82,7 @@ object HideShortsComponentsPatch : BytecodePatch( insertIndex, viewRegister, FILTER_CLASS_DESCRIPTOR, - "hideShortsShelf" + "hideShortsShelf", ) } } // Do not throw an exception if not resolved. @@ -93,7 +96,6 @@ object HideShortsComponentsPatch : BytecodePatch( ShortsButtons.entries.forEach { button -> button.injectHideCall(it.mutableMethod) } } ?: throw CreateShortsButtonsFingerprint.exception - // endregion // region Hide the Shorts buttons in newer versions of YouTube. @@ -106,8 +108,9 @@ object HideShortsComponentsPatch : BytecodePatch( // Hook to get the pivotBar view. SetPivotBarVisibilityParentFingerprint.result?.let { - if (!SetPivotBarVisibilityFingerprint.resolve(context, it.classDef)) + if (!SetPivotBarVisibilityFingerprint.resolve(context, it.classDef)) { throw SetPivotBarVisibilityFingerprint.exception + } SetPivotBarVisibilityFingerprint.result!!.let { result -> result.mutableMethod.apply { @@ -116,7 +119,7 @@ object HideShortsComponentsPatch : BytecodePatch( addInstruction( insertIndex, "sput-object v$viewRegister, $FILTER_CLASS_DESCRIPTOR->pivotBar:" + - "Lcom/google/android/libraries/youtube/rendering/ui/pivotbar/PivotBar;" + "Lcom/google/android/libraries/youtube/rendering/ui/pivotbar/PivotBar;", ) } } @@ -124,8 +127,9 @@ object HideShortsComponentsPatch : BytecodePatch( // Hook to hide the navigation bar when Shorts are being played. RenderBottomNavigationBarParentFingerprint.result?.let { - if (!RenderBottomNavigationBarFingerprint.resolve(context, it.classDef)) + if (!RenderBottomNavigationBarFingerprint.resolve(context, it.classDef)) { throw RenderBottomNavigationBarFingerprint.exception + } RenderBottomNavigationBarFingerprint.result!!.mutableMethod.apply { addInstruction(0, "invoke-static { }, $FILTER_CLASS_DESCRIPTOR->hideNavigationBar()V") @@ -142,7 +146,7 @@ object HideShortsComponentsPatch : BytecodePatch( addInstruction( insertIndex, "invoke-static { v$viewRegister }, $FILTER_CLASS_DESCRIPTOR->" + - "hideNavigationBar(Landroid/view/View;)Landroid/view/View;" + "hideNavigationBar(Landroid/view/View;)Landroid/view/View;", ) } } ?: throw BottomNavigationBarFingerprint.exception @@ -150,14 +154,14 @@ object HideShortsComponentsPatch : BytecodePatch( // endregion } - private enum class ShortsButtons(private val resourceName: String, private val methodName: String) { COMMENTS("reel_dyn_comment", "hideShortsCommentsButton"), REMIX("reel_dyn_remix", "hideShortsRemixButton"), - SHARE("reel_dyn_share", "hideShortsShareButton"); + SHARE("reel_dyn_share", "hideShortsShareButton"), + ; fun injectHideCall(method: MutableMethod) { - val referencedIndex = method.findIndexForIdResource(resourceName) + val referencedIndex = method.indexOfIdResourceOrThrow(resourceName) val setIdIndex = referencedIndex + 1 val viewRegister = method.getInstruction(setIdIndex).registerC diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt index 6d8a07026..47381c2d5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt @@ -50,15 +50,19 @@ object HideShortsComponentsResourcePatch : ResourcePatch() { SwitchPreference("revanced_hide_shorts_navigation_bar"), ) - ResourceMappingPatch.resourceMappings.find { - it.type == "layout" && it.name == "reel_multiple_items_shelf" - }?.also { - reelMultipleItemShelfId = it.id - } + reelPlayerRightCellButtonHeight = ResourceMappingPatch[ + "dimen", + "reel_player_right_cell_button_height", + ] - reelPlayerRightCellButtonHeight = - ResourceMappingPatch.resourceMappings.single { - it.type == "dimen" && it.name == "reel_player_right_cell_button_height" - }.id + // Resource not present in new versions of the app. + try { + ResourceMappingPatch[ + "dimen", + "reel_player_right_cell_button_height", + ] + } catch (e: NoSuchElementException) { + return + }.also { reelPlayerRightCellButtonHeight = it } } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/fingerprints/CreateShortsButtonsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/fingerprints/CreateShortsButtonsFingerprint.kt index 97ac69121..da5cdc634 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/fingerprints/CreateShortsButtonsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/fingerprints/CreateShortsButtonsFingerprint.kt @@ -1,13 +1,10 @@ package app.revanced.patches.youtube.layout.hide.shorts.fingerprints -import app.revanced.patcher.extensions.or import app.revanced.patches.youtube.layout.hide.shorts.HideShortsComponentsResourcePatch import app.revanced.util.patch.LiteralValueFingerprint -import com.android.tools.smali.dexlib2.AccessFlags internal object CreateShortsButtonsFingerprint : LiteralValueFingerprint( - accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL, + // YT 19.12.x moved this code inside another method, and each method has different parameters. returnType = "V", - parameters = listOf("Z", "Z", "L"), literalSupplier = { HideShortsComponentsResourcePatch.reelPlayerRightCellButtonHeight } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenPatch.kt index c939e786d..68407dc68 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenPatch.kt @@ -33,7 +33,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenResourcePatch.kt index 28122d1a2..7d9c1ad61 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenResourcePatch.kt @@ -12,7 +12,7 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch dependencies = [ SettingsPatch::class, ResourceMappingPatch::class, - AddResourcesPatch::class + AddResourcesPatch::class, ], ) internal object DisableSuggestedVideoEndScreenResourcePatch : ResourcePatch() { @@ -22,11 +22,12 @@ internal object DisableSuggestedVideoEndScreenResourcePatch : ResourcePatch() { AddResourcesPatch(this::class) SettingsPatch.PreferenceScreen.PLAYER.addPreferences( - SwitchPreference("revanced_disable_suggested_video_end_screen") + SwitchPreference("revanced_disable_suggested_video_end_screen"), ) - sizeAdjustableLiteAutoNavOverlay = ResourceMappingPatch.resourceMappings.single { - it.type == "layout" && it.name == "size_adjustable_lite_autonav_overlay" - }.id + sizeAdjustableLiteAutoNavOverlay = ResourceMappingPatch[ + "layout", + "size_adjustable_lite_autonav_overlay", + ] } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt index a3c731ef1..cb741ddf1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt @@ -34,7 +34,9 @@ import app.revanced.util.exception "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt index 58fade4e0..a50d781a3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt @@ -35,7 +35,9 @@ import app.revanced.util.exception "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/background/PlayerControlsBackgroundPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/background/PlayerControlsBackgroundPatch.kt index d5e1893a2..aa9f4b9f1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/background/PlayerControlsBackgroundPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/background/PlayerControlsBackgroundPatch.kt @@ -30,7 +30,9 @@ import org.w3c.dom.Element "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ], ), ], diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityResourcePatch.kt index 147ccaccf..4037fe20a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityResourcePatch.kt @@ -10,7 +10,7 @@ import app.revanced.patches.shared.misc.settings.preference.TextPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch( - dependencies = [SettingsPatch::class, ResourceMappingPatch::class, AddResourcesPatch::class] + dependencies = [SettingsPatch::class, ResourceMappingPatch::class, AddResourcesPatch::class], ) internal object CustomPlayerOverlayOpacityResourcePatch : ResourcePatch() { internal var scrimOverlayId = -1L @@ -19,11 +19,12 @@ internal object CustomPlayerOverlayOpacityResourcePatch : ResourcePatch() { AddResourcesPatch(this::class) SettingsPatch.PreferenceScreen.PLAYER.addPreferences( - TextPreference("revanced_player_overlay_opacity", inputType = InputType.NUMBER) + TextPreference("revanced_player_overlay_opacity", inputType = InputType.NUMBER), ) - scrimOverlayId = ResourceMappingPatch.resourceMappings.single { - it.type == "id" && it.name == "scrim_overlay" - }.id + scrimOverlayId = ResourceMappingPatch[ + "id", + "scrim_overlay", + ] } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt index 783474eb3..6a2a03522 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt @@ -64,7 +64,9 @@ import com.android.tools.smali.dexlib2.iface.reference.TypeReference "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt index 06226fc0c..d39a8fa3e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt @@ -12,8 +12,8 @@ import app.revanced.patches.youtube.misc.settings.SettingsResourcePatch @Patch( dependencies = [ SettingsPatch::class, - AddResourcesPatch::class - ] + AddResourcesPatch::class, + ], ) internal object ReturnYouTubeDislikeResourcePatch : ResourcePatch() { internal var oldUIDislikeId: Long = -1 @@ -25,11 +25,12 @@ internal object ReturnYouTubeDislikeResourcePatch : ResourcePatch() { key = "revanced_settings_screen_09", titleKey = "revanced_ryd_settings_title", summaryKey = null, - intent = SettingsPatch.newIntent("revanced_ryd_settings_intent") + intent = SettingsPatch.newIntent("revanced_ryd_settings_intent"), ) - oldUIDislikeId = ResourceMappingPatch.resourceMappings.single { - it.type == "id" && it.name == "dislike_button" - }.id + oldUIDislikeId = ResourceMappingPatch[ + "id", + "dislike_button", + ] } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt index 3cd258b78..0e72bddaf 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt @@ -39,7 +39,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatch.kt index 77de2e752..c621a95dd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatch.kt @@ -35,7 +35,9 @@ import app.revanced.util.exception "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorResourcePatch.kt index 09a686be3..84ea503a4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorResourcePatch.kt @@ -15,18 +15,18 @@ internal object SeekbarColorResourcePatch : ResourcePatch() { internal var inlineTimeBarPlayedNotHighlightedColorId = -1L override fun execute(context: ResourceContext) { - fun findColorResource(resourceName: String): Long { - return ResourceMappingPatch.resourceMappings - .find { it.type == "color" && it.name == resourceName }?.id - ?: throw PatchException("Could not find color resource: $resourceName") - } - - reelTimeBarPlayedColorId = - findColorResource("reel_time_bar_played_color") - inlineTimeBarColorizedBarPlayedColorDarkId = - findColorResource("inline_time_bar_colorized_bar_played_color_dark") - inlineTimeBarPlayedNotHighlightedColorId = - findColorResource("inline_time_bar_played_not_highlighted_color") + reelTimeBarPlayedColorId = ResourceMappingPatch[ + "color", + "reel_time_bar_played_color", + ] + inlineTimeBarColorizedBarPlayedColorDarkId = ResourceMappingPatch[ + "color", + "inline_time_bar_colorized_bar_played_color_dark", + ] + inlineTimeBarPlayedNotHighlightedColorId = ResourceMappingPatch[ + "color", + "inline_time_bar_played_not_highlighted_color", + ] // Edit the resume playback drawable and replace the progress bar with a custom drawable context.xmlEditor["res/drawable/resume_playback_progressbar_drawable.xml"].use { editor -> @@ -39,10 +39,9 @@ internal object SeekbarColorResourcePatch : ResourcePatch() { } val scaleNode = progressNode.getElementsByTagName("scale").item(0) as Element val shapeNode = scaleNode.getElementsByTagName("shape").item(0) as Element - val replacementNode = - document.createElement( - "app.revanced.integrations.youtube.patches.theme.ProgressBarDrawable", - ) + val replacementNode = document.createElement( + "app.revanced.integrations.youtube.patches.theme.ProgressBarDrawable", + ) scaleNode.replaceChild(replacementNode, shapeNode) } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockBytecodePatch.kt index 52ab535e8..8ba36ef11 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockBytecodePatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.youtube.layout.sponsorblock -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions @@ -25,6 +24,7 @@ import app.revanced.patches.youtube.shared.fingerprints.SeekbarFingerprint import app.revanced.patches.youtube.shared.fingerprints.SeekbarOnDrawFingerprint import app.revanced.patches.youtube.video.information.VideoInformationPatch import app.revanced.patches.youtube.video.videoid.VideoIdPatch +import app.revanced.util.exception import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.* import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c @@ -37,7 +37,8 @@ import com.android.tools.smali.dexlib2.iface.reference.StringReference description = "Adds options to enable and configure SponsorBlock, which can skip undesired video segments such as sponsored content.", compatiblePackages = [ CompatiblePackage( - "com.google.android.youtube", [ + "com.google.android.youtube", + [ "18.48.39", "18.49.37", "19.01.34", @@ -48,9 +49,11 @@ import com.android.tools.smali.dexlib2.iface.reference.StringReference "19.06.39", "19.07.40", "19.08.36", - "19.09.37" - ] - ) + "19.09.38", + "19.10.39", + "19.11.43", + ], + ), ], dependencies = [ IntegrationsPatch::class, @@ -60,8 +63,8 @@ import com.android.tools.smali.dexlib2.iface.reference.StringReference // Used to prevent SponsorBlock from running on Shorts because SponsorBlock does not yet support Shorts. PlayerTypeHookPatch::class, PlayerControlsBytecodePatch::class, - SponsorBlockResourcePatch::class - ] + SponsorBlockResourcePatch::class, + ], ) @Suppress("unused") object SponsorBlockBytecodePatch : BytecodePatch( @@ -69,8 +72,8 @@ object SponsorBlockBytecodePatch : BytecodePatch( SeekbarFingerprint, AppendTimeFingerprint, LayoutConstructorFingerprint, - AutoRepeatParentFingerprint - ) + AutoRepeatParentFingerprint, + ), ) { private const val INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/youtube/sponsorblock/SegmentPlaybackController;" @@ -83,8 +86,9 @@ object SponsorBlockBytecodePatch : BytecodePatch( override fun execute(context: BytecodeContext) { LayoutConstructorFingerprint.result?.let { - if (!ControlsOverlayFingerprint.resolve(context, it.classDef)) + if (!ControlsOverlayFingerprint.resolve(context, it.classDef)) { throw ControlsOverlayFingerprint.exception + } } ?: throw LayoutConstructorFingerprint.exception /* @@ -93,7 +97,7 @@ object SponsorBlockBytecodePatch : BytecodePatch( with(VideoInformationPatch) { videoTimeHook( INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR, - "setVideoTime" + "setVideoTime", ) } @@ -121,7 +125,7 @@ object SponsorBlockBytecodePatch : BytecodePatch( seekbarMethod.addInstruction( moveRectangleToRegisterIndex + 1, "invoke-static/range {p0 .. p0}, " + - "$INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarRect(Ljava/lang/Object;)V" + "$INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarRect(Ljava/lang/Object;)V", ) for ((index, instruction) in seekbarMethodInstructions.withIndex()) { @@ -136,7 +140,7 @@ object SponsorBlockBytecodePatch : BytecodePatch( seekbarMethod.addInstruction( insertIndex, "invoke-static {v${invokeInstruction.registerC}}, " + - "$INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarThickness(I)V" + "$INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarThickness(I)V", ) break } @@ -154,7 +158,7 @@ object SponsorBlockBytecodePatch : BytecodePatch( } seekbarMethod.addInstruction( i, - "invoke-static {v$canvasInstance, v$centerY}, $INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->drawSponsorTimeBars(Landroid/graphics/Canvas;F)V" + "invoke-static {v$canvasInstance, v$centerY}, $INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->drawSponsorTimeBars(Landroid/graphics/Canvas;F)V", ) break @@ -166,9 +170,9 @@ object SponsorBlockBytecodePatch : BytecodePatch( val controlsMethodResult = PlayerControlsBytecodePatch.showPlayerControlsFingerprintResult val controlsLayoutStubResourceId = - ResourceMappingPatch.resourceMappings.single { it.type == "id" && it.name == "controls_layout_stub" }.id + ResourceMappingPatch["id", "controls_layout_stub"] val zoomOverlayResourceId = - ResourceMappingPatch.resourceMappings.single { it.type == "id" && it.name == "video_zoom_overlay_stub" }.id + ResourceMappingPatch["id", "video_zoom_overlay_stub"] methods@ for (method in controlsMethodResult.mutableClass.methods) { val instructions = method.implementation?.instructions!! @@ -188,7 +192,7 @@ object SponsorBlockBytecodePatch : BytecodePatch( """ invoke-static {v$inflatedViewRegister}, $INTEGRATIONS_CREATE_SEGMENT_BUTTON_CONTROLLER_CLASS_DESCRIPTOR->initialize(Landroid/view/View;)V invoke-static {v$inflatedViewRegister}, $INTEGRATIONS_VOTING_BUTTON_CONTROLLER_CLASS_DESCRIPTOR->initialize(Landroid/view/View;)V - """ + """, ) } @@ -201,7 +205,7 @@ object SponsorBlockBytecodePatch : BytecodePatch( """ invoke-static {p1}, $INTEGRATIONS_CREATE_SEGMENT_BUTTON_CONTROLLER_CLASS_DESCRIPTOR->changeVisibilityNegatedImmediate(Z)V invoke-static {p1}, $INTEGRATIONS_VOTING_BUTTON_CONTROLLER_CLASS_DESCRIPTOR->changeVisibilityNegatedImmediate(Z)V - """.trimIndent() + """.trimIndent(), ) } } @@ -223,7 +227,7 @@ object SponsorBlockBytecodePatch : BytecodePatch( """ invoke-static {v$targetRegister}, $INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->appendTimeWithoutSegments(Ljava/lang/String;)Ljava/lang/String; move-result-object v$targetRegister - """ + """, ) // initialize the player controller @@ -236,10 +240,10 @@ object SponsorBlockBytecodePatch : BytecodePatch( val frameLayoutRegister = (getInstruction(startIndex + 2) as OneRegisterInstruction).registerA addInstruction( startIndex + 3, - "invoke-static {v$frameLayoutRegister}, $INTEGRATIONS_SPONSORBLOCK_VIEW_CONTROLLER_CLASS_DESCRIPTOR->initialize(Landroid/view/ViewGroup;)V" + "invoke-static {v$frameLayoutRegister}, $INTEGRATIONS_SPONSORBLOCK_VIEW_CONTROLLER_CLASS_DESCRIPTOR->initialize(Landroid/view/ViewGroup;)V", ) } - } ?: throw ControlsOverlayFingerprint.exception + } ?: throw ControlsOverlayFingerprint.exception // get rectangle field name RectangleFieldInvalidatorFingerprint.resolve(context, seekbarSignatureResult.classDef) @@ -258,7 +262,8 @@ object SponsorBlockBytecodePatch : BytecodePatch( fun MutableMethod.replaceStringInstruction(index: Int, instruction: Instruction, with: String) { val register = (instruction as OneRegisterInstruction).registerA this.replaceInstruction( - index, "const-string v$register, \"$with\"" + index, + "const-string v$register, \"$with\"", ) } for ((index, it) in method.implementation!!.instructions.withIndex()) { @@ -268,13 +273,12 @@ object SponsorBlockBytecodePatch : BytecodePatch( "replaceMeWithsetSponsorBarRect" -> method.replaceStringInstruction( index, it, - rectangleFieldName + rectangleFieldName, ) } } } ?: throw PatchException("Could not find the method which contains the replaceMeWith* strings") - // The vote and create segment buttons automatically change their visibility when appropriate, // but if buttons are showing when the end of the video is reached then they will not automatically hide. // Add a hook to forcefully hide when the end of the video is reached. @@ -283,7 +287,7 @@ object SponsorBlockBytecodePatch : BytecodePatch( it.resolve(context, AutoRepeatParentFingerprint.result!!.classDef) }.result?.mutableMethod?.addInstruction( 0, - "invoke-static {}, $INTEGRATIONS_SPONSORBLOCK_VIEW_CONTROLLER_CLASS_DESCRIPTOR->endOfVideoReached()V" + "invoke-static {}, $INTEGRATIONS_SPONSORBLOCK_VIEW_CONTROLLER_CLASS_DESCRIPTOR->endOfVideoReached()V", ) ?: throw AutoRepeatFingerprint.exception // TODO: isSBChannelWhitelisting implementation diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt index b4a64d790..82557e6a0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt @@ -38,7 +38,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt index 7ed287816..57a4d1632 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt @@ -44,7 +44,9 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch.kt index b770c7743..80297fe36 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch.kt @@ -43,7 +43,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ) ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorParentFingerprint.kt index 244bf33d0..2e1612373 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorParentFingerprint.kt @@ -12,7 +12,7 @@ internal object MiniPlayerDimensionsCalculatorParentFingerprint : MethodFingerpr opcodes = listOf( Opcode.CONST_HIGH16, Opcode.ADD_FLOAT_2ADDR, - Opcode.MUL_FLOAT, + null, // Opcode.MUL_FLOAT or Opcode.MUL_FLOAT_2ADDR Opcode.CONST_4, Opcode.INVOKE_STATIC, Opcode.MOVE_RESULT, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt index 9859dac0b..04b3dc0bb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt @@ -50,7 +50,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt index c7bd24ec8..b028dad8b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt @@ -61,7 +61,9 @@ import com.android.tools.smali.dexlib2.immutable.ImmutableMethod "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ], ), ], diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt index 55c110966..b8c0157f9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt @@ -39,7 +39,9 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt index 4ed76e24a..86b2967fd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt @@ -34,7 +34,9 @@ import app.revanced.util.exception "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureResourcePatch.kt index 54bfa7540..d65e23ee3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureResourcePatch.kt @@ -11,8 +11,9 @@ object SpoofSignatureResourcePatch : ResourcePatch() { internal var scrubbedPreviewThumbnailResourceId: Long = -1 override fun execute(context: ResourceContext) { - scrubbedPreviewThumbnailResourceId = ResourceMappingPatch.resourceMappings.single { - it.type == "id" && it.name == "thumbnail" - }.id + scrubbedPreviewThumbnailResourceId = ResourceMappingPatch[ + "id", + "thumbnail", + ] } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt index 6547f0ec3..4c9e526ec 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt @@ -44,7 +44,9 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch( "19.06.39", "19.07.40", "19.08.36", - "19.09.37", + "19.09.38", + "19.10.39", + "19.11.43" ), ), ), diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt index 3228a7c68..cafaa942b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt @@ -36,7 +36,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt index 682868644..a9cf1bf8c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt @@ -40,7 +40,9 @@ import com.android.tools.smali.dexlib2.iface.reference.StringReference "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/MinimizedPlaybackPatch.kt index 4374262a3..b54cc4f40 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/MinimizedPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/MinimizedPlaybackPatch.kt @@ -45,7 +45,9 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookResourcePatch.kt index 3841f2bfa..614fbd65c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookResourcePatch.kt @@ -6,19 +6,14 @@ import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch @Patch( - dependencies = [ResourceMappingPatch::class] + dependencies = [ResourceMappingPatch::class], ) internal object NavigationBarHookResourcePatch : ResourcePatch() { internal var imageOnlyTabResourceId: Long = -1 internal var actionBarSearchResultsViewMicId: Long = -1 override fun execute(context: ResourceContext) { - imageOnlyTabResourceId = ResourceMappingPatch.resourceMappings.first { - it.type == "layout" && it.name == "image_only_tab" - }.id - - actionBarSearchResultsViewMicId = ResourceMappingPatch.resourceMappings.first { - it.type == "layout" && it.name == "action_bar_search_results_view_mic" - }.id + imageOnlyTabResourceId = ResourceMappingPatch["layout", "image_only_tab"] + actionBarSearchResultsViewMicId = ResourceMappingPatch["layout", "action_bar_search_results_view_mic"] } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/BottomControlsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/BottomControlsResourcePatch.kt index d2b1c195d..474ccf479 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/BottomControlsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/BottomControlsResourcePatch.kt @@ -24,8 +24,7 @@ object BottomControlsResourcePatch : ResourcePatch(), Closeable { resourceContext = context targetDocumentEditor = context.xmlEditor[TARGET_RESOURCE] - bottomUiContainerResourceId = ResourceMappingPatch.resourceMappings - .single { it.type == "id" && it.name == "bottom_ui_container_stub" }.id + bottomUiContainerResourceId = ResourceMappingPatch["id", "bottom_ui_container_stub"] } /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt index 28404a8f4..f1af3d569 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt @@ -41,7 +41,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt index 3f8b1d16d..2783a0266 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt @@ -31,10 +31,7 @@ object SettingsResourcePatch : BaseSettingsResourcePatch( AddResourcesPatch(this::class) // Used for a fingerprint from SettingsPatch. - appearanceStringId = - ResourceMappingPatch.resourceMappings.find { - it.type == "string" && it.name == "app_theme_appearance_dark" - }!!.id + appearanceStringId = ResourceMappingPatch["string", "app_theme_appearance_dark"] arrayOf( ResourceGroup("layout", "revanced_settings_with_toolbar.xml"), diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt index 858d30b14..62249f848 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt @@ -45,7 +45,9 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt index f8e9330a5..671dff006 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt @@ -25,7 +25,9 @@ import app.revanced.patches.youtube.video.speed.remember.RememberPlaybackSpeedPa "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ], ), ], diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedResourcePatch.kt index 2fc51faaa..0981e7f55 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedResourcePatch.kt @@ -8,8 +8,9 @@ internal object CustomPlaybackSpeedResourcePatch : ResourcePatch() { var speedUnavailableId: Long = -1 override fun execute(context: ResourceContext) { - speedUnavailableId = ResourceMappingPatch.resourceMappings.single { - it.type == "string" && it.name == "varispeed_unavailable_message" - }.id + speedUnavailableId = ResourceMappingPatch[ + "string", + "varispeed_unavailable_message", + ] } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuPatch.kt index 25b01b1ab..a2ccd3e94 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuPatch.kt @@ -41,7 +41,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction "19.06.39", "19.07.40", "19.08.36", - "19.09.37" + "19.09.38", + "19.10.39", + "19.11.43" ] ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuResourcePatch.kt index 7221e80b1..8de2a9b0e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuResourcePatch.kt @@ -1,7 +1,6 @@ package app.revanced.patches.youtube.video.videoqualitymenu import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.all.misc.resources.AddResourcesPatch @@ -10,7 +9,7 @@ import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch( - dependencies = [SettingsPatch::class, ResourceMappingPatch::class, AddResourcesPatch::class] + dependencies = [SettingsPatch::class, ResourceMappingPatch::class, AddResourcesPatch::class], ) object RestoreOldVideoQualityMenuResourcePatch : ResourcePatch() { internal var videoQualityBottomSheetListFragmentTitle = -1L @@ -19,13 +18,13 @@ object RestoreOldVideoQualityMenuResourcePatch : ResourcePatch() { AddResourcesPatch(this::class) SettingsPatch.PreferenceScreen.VIDEO.addPreferences( - SwitchPreference("revanced_restore_old_video_quality_menu") + SwitchPreference("revanced_restore_old_video_quality_menu"), ) - fun findResource(name: String) = ResourceMappingPatch.resourceMappings.find { it.name == name }?.id - ?: throw PatchException("Could not find resource") - // Used for the old type of the video quality menu. - videoQualityBottomSheetListFragmentTitle = findResource("video_quality_bottom_sheet_list_fragment_title") + videoQualityBottomSheetListFragmentTitle = ResourceMappingPatch[ + "layout", + "video_quality_bottom_sheet_list_fragment_title", + ] } } diff --git a/src/main/kotlin/app/revanced/util/BytecodeUtils.kt b/src/main/kotlin/app/revanced/util/BytecodeUtils.kt index 8daf77702..ccd9c1b08 100644 --- a/src/main/kotlin/app/revanced/util/BytecodeUtils.kt +++ b/src/main/kotlin/app/revanced/util/BytecodeUtils.kt @@ -15,7 +15,6 @@ import com.android.tools.smali.dexlib2.iface.instruction.WideLiteralInstruction import com.android.tools.smali.dexlib2.iface.reference.Reference import com.android.tools.smali.dexlib2.util.MethodUtil - fun MethodFingerprint.resultOrThrow() = result ?: throw exception /** @@ -59,24 +58,41 @@ fun MutableMethod.injectHideViewCall( insertIndex: Int, viewRegister: Int, classDescriptor: String, - targetMethod: String + targetMethod: String, ) = addInstruction( insertIndex, - "invoke-static { v$viewRegister }, $classDescriptor->$targetMethod(Landroid/view/View;)V" + "invoke-static { v$viewRegister }, $classDescriptor->$targetMethod(Landroid/view/View;)V", ) /** - * Find the index of the first instruction with the id of the given resource name. + * Get the index of the first instruction with the id of the given resource name. + * + * Requires [ResourceMappingPatch] as a dependency. * * @param resourceName the name of the resource to find the id for. * @return the index of the first instruction with the id of the given resource name, or -1 if not found. + * @throws PatchException if the resource cannot be found. + * @see [indexOfIdResourceOrThrow] */ -fun Method.findIndexForIdResource(resourceName: String): Int { - fun getIdResourceId(resourceName: String) = ResourceMappingPatch.resourceMappings.single { - it.type == "id" && it.name == resourceName - }.id +fun Method.indexOfIdResource(resourceName: String): Int { + val resourceId = ResourceMappingPatch["id", resourceName] + return indexOfFirstWideLiteralInstructionValue(resourceId) +} - return indexOfFirstWideLiteralInstructionValue(getIdResourceId(resourceName)) +/** + * Get the index of the first instruction with the id of the given resource name or throw a [PatchException]. + * + * Requires [ResourceMappingPatch] as a dependency. + * + * @throws [PatchException] if the resource is not found, or the method does not contain the resource id literal value. + */ +fun Method.indexOfIdResourceOrThrow(resourceName: String): Int { + val index = indexOfIdResource(resourceName) + if (index < 0) { + throw PatchException("Found resource id for: '$resourceName' but method does not contain the id: $this") + } + + return index } /** @@ -130,27 +146,29 @@ inline fun Instruction.getReference() = (this as? Refere fun Method.indexOfFirstInstruction(predicate: Instruction.() -> Boolean) = this.implementation!!.instructions.indexOfFirst(predicate) - /** - * Return the resolved methods of [MethodFingerprint]s early. - */ - fun List.returnEarly(bool: Boolean = false) { - val const = if (bool) "0x1" else "0x0" - this.forEach { fingerprint -> - fingerprint.result?.let { result -> - val stringInstructions = when (result.method.returnType.first()) { - 'L' -> """ +/** + * Return the resolved methods of [MethodFingerprint]s early. + */ +fun List.returnEarly(bool: Boolean = false) { + val const = if (bool) "0x1" else "0x0" + this.forEach { fingerprint -> + fingerprint.result?.let { result -> + val stringInstructions = when (result.method.returnType.first()) { + 'L' -> + """ const/4 v0, $const return-object v0 """ - 'V' -> "return-void" - 'I', 'Z' -> """ + 'V' -> "return-void" + 'I', 'Z' -> + """ const/4 v0, $const return v0 """ - else -> throw Exception("This case should never happen.") - } + else -> throw Exception("This case should never happen.") + } - result.mutableMethod.addInstructions(0, stringInstructions) - } ?: throw fingerprint.exception - } + result.mutableMethod.addInstructions(0, stringInstructions) + } ?: throw fingerprint.exception } +}