fix(sponsorblock): broken fingerprint and invert setting shorts_playing (#579)

Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
OxrxL 2022-09-22 07:43:54 +02:00 committed by GitHub
parent 7656603d59
commit 59fb674437
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 6 deletions

View File

@ -7,8 +7,10 @@ import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility
import app.revanced.patches.youtube.layout.sponsorblock.resource.patch.SponsorBlockResourcePatch
import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
@Name("shorts-player-constructor-fingerprint") @Name("shorts-player-constructor-fingerprint")
@MatchingMethod("Lhgp;", "<init>") @MatchingMethod("Lhgp;", "<init>")
@ -33,6 +35,13 @@ object ShortsPlayerConstructorFingerprint : MethodFingerprint(
Opcode.IPUT_OBJECT, Opcode.IPUT_OBJECT,
Opcode.NEW_INSTANCE, Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT, Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT Opcode.IPUT_OBJECT,
) Opcode.IPUT_OBJECT,
Opcode.CONST_4
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any { instruction ->
(instruction as? WideLiteralInstruction)?.wideLiteral == SponsorBlockResourcePatch.reelButtonGroupResourceId
} == true
}
) )

View File

@ -40,7 +40,7 @@ import org.jf.dexlib2.util.MethodUtil
@Patch @Patch
@DependsOn( @DependsOn(
dependencies = [PlayerControlsBytecodePatch::class, IntegrationsPatch::class, ResourceIdMappingProviderResourcePatch::class, SponsorBlockResourcePatch::class, VideoIdPatch::class] dependencies = [PlayerControlsBytecodePatch::class, IntegrationsPatch::class, SponsorBlockResourcePatch::class, VideoIdPatch::class]
) )
@Name("sponsorblock") @Name("sponsorblock")
@Description("Integrate SponsorBlock.") @Description("Integrate SponsorBlock.")
@ -329,7 +329,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
val startVideoInformerMethod = StartVideoInformerFingerprint.result!!.mutableMethod val startVideoInformerMethod = StartVideoInformerFingerprint.result!!.mutableMethod
startVideoInformerMethod.addInstructions( startVideoInformerMethod.addInstructions(
0, """ 0, """
const/4 v0, 0x1 const/4 v0, 0x0
sput-boolean v0, Lapp/revanced/integrations/settings/SettingsEnum;->shorts_playing:Z sput-boolean v0, Lapp/revanced/integrations/settings/SettingsEnum;->shorts_playing:Z
""" """
) )
@ -338,7 +338,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
shortsPlayerConstructorMethod.addInstructions( shortsPlayerConstructorMethod.addInstructions(
0, """ 0, """
const/4 v0, 0x0 const/4 v0, 0x1
sput-boolean v0, Lapp/revanced/integrations/settings/SettingsEnum;->shorts_playing:Z sput-boolean v0, Lapp/revanced/integrations/settings/SettingsEnum;->shorts_playing:Z
""" """
) )

View File

@ -9,6 +9,7 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.impl.ResourcePatch import app.revanced.patcher.patch.impl.ResourcePatch
import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch
import app.revanced.patches.youtube.misc.mapping.patch.ResourceIdMappingProviderResourcePatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.youtube.misc.settings.framework.components.impl.Preference import app.revanced.patches.youtube.misc.settings.framework.components.impl.Preference
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
@ -19,9 +20,13 @@ import app.revanced.util.resources.ResourceUtils.copyXmlNode
@Name("sponsorblock-resource-patch") @Name("sponsorblock-resource-patch")
@SponsorBlockCompatibility @SponsorBlockCompatibility
@DependsOn([FixLocaleConfigErrorPatch::class, SettingsPatch::class]) @DependsOn([FixLocaleConfigErrorPatch::class, SettingsPatch::class, ResourceIdMappingProviderResourcePatch::class])
@Version("0.0.1") @Version("0.0.1")
class SponsorBlockResourcePatch : ResourcePatch() { class SponsorBlockResourcePatch : ResourcePatch() {
companion object {
internal var reelButtonGroupResourceId: Long = 0
}
override fun execute(data: ResourceData): PatchResult { override fun execute(data: ResourceData): PatchResult {
val youtubePackage = "com.google.android.youtube" val youtubePackage = "com.google.android.youtube"
SettingsPatch.addPreference( SettingsPatch.addPreference(
@ -102,6 +107,10 @@ class SponsorBlockResourcePatch : ResourcePatch() {
} }
}.close() // close afterwards }.close() // close afterwards
reelButtonGroupResourceId = ResourceIdMappingProviderResourcePatch.resourceMappings.single {
it.type == "id" && it.name == "reel_persistent_edu_button_group"
}.id
return PatchResultSuccess() return PatchResultSuccess()
} }
} }