feat: disable sponsorblock on shorts (#439)

This commit is contained in:
OxrxL 2022-09-21 03:03:47 +02:00 committed by GitHub
parent d1fa2c3bc3
commit 47fbcba3f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 1 deletions

View file

@ -0,0 +1,38 @@
package app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
@Name("shorts-player-constructor-fingerprint")
@MatchingMethod("Lhgp;", "<init>")
@FuzzyPatternScanMethod(3)
@SponsorBlockCompatibility
@Version("0.0.1")
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
)
)

View file

@ -25,6 +25,7 @@ import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.mapping.patch.ResourceIdMappingProviderResourcePatch
import app.revanced.patches.youtube.misc.playercontrols.bytecode.patch.PlayerControlsBytecodePatch
import app.revanced.patches.youtube.misc.videoid.patch.VideoIdPatch
import app.revanced.patches.youtube.layout.autocaptions.fingerprints.StartVideoInformerFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.builder.MutableMethodImplementation
@ -53,7 +54,8 @@ class SponsorBlockBytecodePatch : BytecodePatch(
NextGenWatchLayoutFingerprint,
AppendTimeFingerprint,
PlayerInitFingerprint,
PlayerOverlaysLayoutInitFingerprint
PlayerOverlaysLayoutInitFingerprint,
ShortsPlayerConstructorFingerprint
)
) {
override fun execute(data: BytecodeData): PatchResult {/*
@ -324,6 +326,23 @@ class SponsorBlockBytecodePatch : BytecodePatch(
}
}
val startVideoInformerMethod = StartVideoInformerFingerprint.result!!.mutableMethod
startVideoInformerMethod.addInstructions(
0, """
const/4 v0, 0x1
sput-boolean v0, Lapp/revanced/integrations/settings/SettingsEnum;->shorts_playing:Z
"""
)
val shortsPlayerConstructorMethod = ShortsPlayerConstructorFingerprint.result!!.mutableMethod
shortsPlayerConstructorMethod.addInstructions(
0, """
const/4 v0, 0x0
sput-boolean v0, Lapp/revanced/integrations/settings/SettingsEnum;->shorts_playing:Z
"""
)
// TODO: isSBChannelWhitelisting implementation
return PatchResultSuccess()