fix(youtube/sponsorblock): vote button and new segment button do not disappear when end screen overlay appears

This commit is contained in:
inotia00
2023-05-08 04:30:32 +09:00
parent 77b73cff80
commit 3c6c7d3965
6 changed files with 28 additions and 26 deletions

View File

@ -0,0 +1,12 @@
package app.revanced.patches.youtube.button.autorepeat.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
object VideoEndFingerprint : MethodFingerprint(
returnType = "V",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
customFingerprint = { methodDef -> methodDef.implementation!!.instructions.count() == 3 && methodDef.annotations.isEmpty()}
)

View File

@ -0,0 +1,14 @@
package app.revanced.patches.youtube.button.autorepeat.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
object VideoEndParentFingerprint : MethodFingerprint(
returnType = "V",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
strings = listOf(
"play() called when the player wasn't loaded.",
"play() blocked because Background Playability failed"
)
)

View File

@ -11,8 +11,6 @@ import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.fingerprints.VideoEndFingerprint
import app.revanced.patches.shared.fingerprints.VideoEndParentFingerprint
import app.revanced.patches.youtube.button.autorepeat.fingerprints.*
import app.revanced.util.integrations.Constants.UTILS_PATH
import app.revanced.util.integrations.Constants.VIDEO_PATH

View File

@ -0,0 +1,10 @@
package app.revanced.patches.youtube.misc.sponsorblock.bytecode.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object EndScreenEngagementPanelsFingerprint : MethodFingerprint(
returnType = "V",
opcodes = listOf(Opcode.CONST_WIDE_16),
strings = listOf("ITEM_COUNT")
)

View File

@ -46,12 +46,13 @@ import org.jf.dexlib2.iface.reference.MethodReference
@Version("0.0.1")
class SponsorBlockBytecodePatch : BytecodePatch(
listOf(
EndScreenEngagementPanelsFingerprint,
PlayerControllerFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
/*
/**
* Hook the video time methods
*/
with(MainstreamVideoIdPatch) {
@ -66,14 +67,14 @@ class SponsorBlockBytecodePatch : BytecodePatch(
}
/*
/**
* Seekbar drawing
*/
insertMethod = HookTimeBarPatch.setTimeBarMethod
insertInstructions = insertMethod.implementation!!.instructions
/*
/**
* Get the instance of the seekbar rectangle
*/
for ((index, instruction) in insertInstructions.withIndex()) {
@ -100,7 +101,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
break
}
/*
/**
* Set rectangle absolute left and right positions
*/
val drawRectangleInstructions = insertInstructions.filter {
@ -120,7 +121,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
injectCallRectangle(index, register, string)
}
/*
/**
* Draw segment
*/
for ((index, instruction) in insertInstructions.withIndex()) {
@ -141,7 +142,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
break
}
/*
/**
* Voting & Shield button
*/
arrayOf("CreateSegmentButtonController", "VotingButtonController").forEach {
@ -149,8 +150,15 @@ class SponsorBlockBytecodePatch : BytecodePatch(
PlayerControlsPatch.injectVisibility("$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/ui/$it;")
}
EndScreenEngagementPanelsFingerprint.result?.mutableMethod?.let {
it.addInstruction(
it.implementation!!.instructions.size - 1,
"invoke-static {}, $INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/ui/SponsorBlockViewController;->endOfVideoReached()V"
)
}
/*
/**
* Replace strings
*/
PlayerControllerFingerprint.result?.mutableMethod?.let {
@ -167,7 +175,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
}
} ?: return PlayerControllerFingerprint.toErrorResult()
/*
/**
* Inject VideoIdPatch
*/
LegacyVideoIdPatch.injectCall("$INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setCurrentVideoId(Ljava/lang/String;)V")

View File

@ -15,8 +15,6 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.fingerprints.VideoEndFingerprint
import app.revanced.patches.shared.fingerprints.VideoEndParentFingerprint
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
import app.revanced.patches.youtube.misc.timebar.patch.HookTimeBarPatch
import app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint.*
@ -49,24 +47,12 @@ class MainstreamVideoIdPatch : BytecodePatch(
PlayerInitFingerprint,
SeekFingerprint,
TimebarFingerprint,
VideoEndParentFingerprint,
VideoTimeHighPrecisionFingerprint,
VideoTimeHighPrecisionParentFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
VideoEndParentFingerprint.result?.classDef?.let { classDef ->
VideoEndFingerprint.also {
it.resolve(context, classDef)
}.result?.mutableMethod?.let { method ->
method.addInstruction(
method.implementation!!.instructions.size - 1,
"invoke-static {}, $VIDEO_PATH/VideoInformation;->videoEnd()V"
)
} ?: return VideoEndFingerprint.toErrorResult()
} ?: return VideoEndParentFingerprint.toErrorResult()
PlayerInitFingerprint.result?.let { parentResult ->
playerInitMethod = parentResult.mutableClass.methods.first { MethodUtil.isConstructor(it) }