From 2b5b28003f4eba42fb1ab3c9be2800eed08b25ce Mon Sep 17 00:00:00 2001 From: inotia00 Date: Fri, 12 May 2023 08:16:52 +0900 Subject: [PATCH] add support YouTube v18.17.43 --- .../shared/annotation/YouTubeCompatibility.kt | 3 ++- .../patch/SponsorBlockBytecodePatch.kt | 22 ++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/shared/annotation/YouTubeCompatibility.kt b/src/main/kotlin/app/revanced/patches/shared/annotation/YouTubeCompatibility.kt index 04d761730..19b742220 100644 --- a/src/main/kotlin/app/revanced/patches/shared/annotation/YouTubeCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/shared/annotation/YouTubeCompatibility.kt @@ -10,7 +10,8 @@ import app.revanced.patcher.annotation.Package "18.13.38", "18.14.41", "18.15.40", - "18.16.39" + "18.16.39", + "18.17.43" ) )] ) 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 d6a763f8c..bf14f3b07 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 @@ -10,7 +10,6 @@ import app.revanced.patcher.extensions.instruction import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult -import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod @@ -118,15 +117,18 @@ class SponsorBlockBytecodePatch : BytecodePatch( insertInstructions.indexOf(it) to (it as FiveRegisterInstruction).registerD } - if (drawRectangleInstructions.size < 4) - return PatchResultError("Couldn't find drawRect reference") - - mapOf( - "setSponsorBarAbsoluteLeft" to 3, - "setSponsorBarAbsoluteRight" to 0 - ).forEach { (string, int) -> - val (index, register) = drawRectangleInstructions[int] - injectCallRectangle(index, register, string) + /** + * Deprecated in YouTube v18.17.43+. + * TODO: remove code from integrations + */ + if (drawRectangleInstructions.size > 3) { + mapOf( + "setSponsorBarAbsoluteLeft" to 3, + "setSponsorBarAbsoluteRight" to 0 + ).forEach { (string, int) -> + val (index, register) = drawRectangleInstructions[int] + injectCallRectangle(index, register, string) + } } /**