From f46fcadd855a13d9f8916f21980abcf5564e97d7 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 28 Jan 2023 11:28:48 +0400 Subject: [PATCH] fix(youtube/return-youtube-dislike): do not fetch voting stats when watching shorts (#1532) Signed-off-by: oSumAtrIX Co-authored-by: oSumAtrIX --- .../patch/ReturnYouTubeDislikePatch.kt | 15 ++++++- .../ShortsPlayerConstructorFingerprint.kt | 41 ------------------- .../patch/SponsorBlockBytecodePatch.kt | 20 +-------- .../patch/SponsorBlockResourcePatch.kt | 7 ---- 4 files changed, 15 insertions(+), 68 deletions(-) delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/ShortsPlayerConstructorFingerprint.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt index 78b8a4fa..65d62746 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt @@ -19,17 +19,28 @@ import app.revanced.patches.youtube.layout.returnyoutubedislike.annotations.Retu import app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints.* import app.revanced.patches.youtube.layout.returnyoutubedislike.resource.patch.ReturnYouTubeDislikeResourcePatch import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch +import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch @Patch -@DependsOn([IntegrationsPatch::class, VideoIdPatch::class, ReturnYouTubeDislikeResourcePatch::class]) +@DependsOn( + [ + IntegrationsPatch::class, + VideoIdPatch::class, + ReturnYouTubeDislikeResourcePatch::class, + PlayerTypeHookPatch::class, + ] +) @Name("return-youtube-dislike") @Description("Shows the dislike count of videos using the Return YouTube Dislike API.") @ReturnYouTubeDislikeCompatibility @Version("0.0.1") class ReturnYouTubeDislikePatch : BytecodePatch( listOf( - TextComponentSpecParentFingerprint, LikeFingerprint, DislikeFingerprint, RemoveLikeFingerprint + TextComponentSpecParentFingerprint, + LikeFingerprint, + DislikeFingerprint, + RemoveLikeFingerprint, ) ) { override fun execute(context: BytecodeContext): PatchResult { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/ShortsPlayerConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/ShortsPlayerConstructorFingerprint.kt deleted file mode 100644 index 86205596..00000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/fingerprints/ShortsPlayerConstructorFingerprint.kt +++ /dev/null @@ -1,41 +0,0 @@ -package app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.layout.sponsorblock.resource.patch.SponsorBlockResourcePatch -import org.jf.dexlib2.AccessFlags -import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.WideLiteralInstruction - - -@FuzzyPatternScanMethod(3) -object ShortsPlayerConstructorFingerprint : MethodFingerprint( - "V", AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, - opcodes = listOf( - Opcode.MOVE_OBJECT_FROM16, - Opcode.MOVE_OBJECT_FROM16, - Opcode.MOVE_OBJECT_FROM16, - Opcode.INVOKE_DIRECT_RANGE, - Opcode.NEW_INSTANCE, - Opcode.INVOKE_DIRECT, - Opcode.IPUT_OBJECT, - Opcode.NEW_INSTANCE, - Opcode.INVOKE_DIRECT, - Opcode.IPUT_OBJECT, - Opcode.NEW_INSTANCE, - Opcode.INVOKE_DIRECT, - Opcode.IPUT_OBJECT, - Opcode.NEW_INSTANCE, - Opcode.INVOKE_DIRECT, - Opcode.IPUT_OBJECT, - Opcode.IPUT_OBJECT, - Opcode.CONST_4 - ), - customFingerprint = { methodDef -> - methodDef.implementation?.instructions?.any { instruction -> - instruction.opcode.ordinal == Opcode.CONST.ordinal && - (instruction as? WideLiteralInstruction)?.wideLiteral == SponsorBlockResourcePatch.reelButtonGroupResourceId - } == true - } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt index 013cc584..f070aa8a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt @@ -23,6 +23,7 @@ import app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints.* import app.revanced.patches.youtube.layout.sponsorblock.resource.patch.SponsorBlockResourcePatch import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.playercontrols.bytecode.patch.PlayerControlsBytecodePatch +import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch import app.revanced.patches.youtube.misc.video.information.patch.VideoInformationPatch import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch import org.jf.dexlib2.Opcode @@ -35,6 +36,7 @@ import org.jf.dexlib2.iface.reference.MethodReference dependencies = [ VideoInformationPatch::class, // updates video information and adds method to seek in video PlayerControlsBytecodePatch::class, + PlayerTypeHookPatch::class, IntegrationsPatch::class, SponsorBlockResourcePatch::class, VideoIdPatch::class @@ -50,7 +52,6 @@ class SponsorBlockBytecodePatch : BytecodePatch( NextGenWatchLayoutFingerprint, AppendTimeFingerprint, PlayerOverlaysLayoutInitFingerprint, - ShortsPlayerConstructorFingerprint, StartVideoInformerFingerprint ) ) { @@ -232,23 +233,6 @@ class SponsorBlockBytecodePatch : BytecodePatch( "invoke-static {p0}, Lapp/revanced/integrations/sponsorblock/player/ui/SponsorBlockView;->initialize(Ljava/lang/Object;)V" ) - val startVideoInformerMethod = StartVideoInformerFingerprint.result!!.mutableMethod - startVideoInformerMethod.addInstructions( - 0, """ - const/4 v0, 0x0 - sput-boolean v0, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->shorts_playing:Z - """ - ) - - val shortsPlayerConstructorMethod = ShortsPlayerConstructorFingerprint.result!!.mutableMethod - - shortsPlayerConstructorMethod.addInstructions( - 0, """ - const/4 v0, 0x1 - sput-boolean v0, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->shorts_playing:Z - """ - ) - // TODO: isSBChannelWhitelisting implementation return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt index 7b0d58f6..4f85e378 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt @@ -23,9 +23,6 @@ import app.revanced.util.resources.ResourceUtils.mergeStrings @DependsOn([FixLocaleConfigErrorPatch::class, SettingsPatch::class, ResourceMappingPatch::class]) @Version("0.0.1") class SponsorBlockResourcePatch : ResourcePatch { - companion object { - internal var reelButtonGroupResourceId: Long = 0 - } override fun execute(context: ResourceContext): PatchResult { val youtubePackage = "com.google.android.youtube" @@ -107,10 +104,6 @@ class SponsorBlockResourcePatch : ResourcePatch { } }.close() // close afterwards - reelButtonGroupResourceId = ResourceMappingPatch.resourceMappings.single { - it.type == "id" && it.name == "reel_persistent_edu_button_group" - }.id - return PatchResultSuccess() } } \ No newline at end of file