From b1a4b1c91e31d650fc15eaa097fab100335b23c8 Mon Sep 17 00:00:00 2001 From: inotia00 Date: Thu, 20 Apr 2023 07:46:37 +0900 Subject: [PATCH] fix(sponsorblock): wrong `video-id-hook` patch used https://github.com/inotia00/ReVanced_Extended/issues/777 --- .../bytecode/patch/OverlayButtonsBytecodePatch.kt | 4 ++-- .../bytecode/patch/SponsorBlockBytecodePatch.kt | 8 +++++++- .../misc/videoid/legacy/patch/LegacyVideoIdPatch.kt | 4 ++++ .../videoid/mainstream/patch/MainstreamVideoIdPatch.kt | 3 --- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/button/overlaybuttons/bytecode/patch/OverlayButtonsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/button/overlaybuttons/bytecode/patch/OverlayButtonsBytecodePatch.kt index dd4e267f9..2504f01d9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/button/overlaybuttons/bytecode/patch/OverlayButtonsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/button/overlaybuttons/bytecode/patch/OverlayButtonsBytecodePatch.kt @@ -9,14 +9,14 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.youtube.misc.playercontrols.patch.PlayerControlsPatch -import app.revanced.patches.youtube.misc.videoid.mainstream.patch.MainstreamVideoIdPatch +import app.revanced.patches.youtube.misc.videoid.legacy.patch.LegacyVideoIdPatch import app.revanced.util.integrations.Constants.BUTTON_PATH @Name("overlay-buttons-bytecode-patch") @DependsOn( dependencies = [ PlayerControlsPatch::class, - MainstreamVideoIdPatch::class + LegacyVideoIdPatch::class ] ) @YouTubeCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt index a84278b93..907dade63 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt @@ -17,6 +17,7 @@ import app.revanced.patches.youtube.misc.playercontrols.patch.PlayerControlsPatc import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.misc.sponsorblock.bytecode.fingerprints.* import app.revanced.patches.youtube.misc.timebar.patch.HookTimebarPatch +import app.revanced.patches.youtube.misc.videoid.legacy.patch.LegacyVideoIdPatch import app.revanced.patches.youtube.misc.videoid.mainstream.patch.MainstreamVideoIdPatch import app.revanced.util.bytecode.BytecodeHelper.injectInit import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus @@ -31,6 +32,7 @@ import org.jf.dexlib2.iface.reference.MethodReference @Name("sponsorblock-bytecode-patch") @DependsOn( [ + LegacyVideoIdPatch::class, MainstreamVideoIdPatch::class, OverrideSpeedHookPatch::class, PlayerControlsPatch::class, @@ -54,12 +56,16 @@ class SponsorBlockBytecodePatch : BytecodePatch( INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR, "setVideoTime" ) + onCreateHook( + INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR, + "initialize" + ) } /* * Inject VideoIdPatch */ - MainstreamVideoIdPatch.injectCall("$INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setCurrentVideoId(Ljava/lang/String;)V") + LegacyVideoIdPatch.injectCall("$INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setCurrentVideoId(Ljava/lang/String;)V") /* diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/legacy/patch/LegacyVideoIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/legacy/patch/LegacyVideoIdPatch.kt index 90d01a327..e6f99a500 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/legacy/patch/LegacyVideoIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/legacy/patch/LegacyVideoIdPatch.kt @@ -12,6 +12,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.youtube.misc.videoid.legacy.fingerprint.LegacyVideoIdFingerprint +import app.revanced.util.integrations.Constants.VIDEO_PATH import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Name("video-id-hook-legacy") @@ -35,10 +36,13 @@ class LegacyVideoIdPatch : BytecodePatch( offset++ // offset so setCurrentVideoId is called before any injected call } ?: return LegacyVideoIdFingerprint.toErrorResult() + injectCall("$INTEGRATIONS_CLASS_DESCRIPTOR->setVideoId(Ljava/lang/String;)V") + return PatchResultSuccess() } companion object { + const val INTEGRATIONS_CLASS_DESCRIPTOR = "$VIDEO_PATH/VideoInformation;" private var offset = 2 private var insertIndex: Int = 0 diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/patch/MainstreamVideoIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/patch/MainstreamVideoIdPatch.kt index 883b5ad27..1d22d07ea 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/patch/MainstreamVideoIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/patch/MainstreamVideoIdPatch.kt @@ -164,9 +164,6 @@ class MainstreamVideoIdPatch : BytecodePatch( offset++ // offset so setVideoId is called before any injected call } ?: return MainstreamVideoIdFingerprint.toErrorResult() - - injectCall("$INTEGRATIONS_CLASS_DESCRIPTOR->setVideoId(Ljava/lang/String;)V") - return PatchResultSuccess() }