forked from inotia00/revanced-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(youtube/sponsorblock): fix toast shown when scrubbing thru a paus…
…ed video (ReVanced#2152) Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
- Loading branch information
1 parent
99916ae
commit c6c23ff
Showing
4 changed files
with
69 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
.../kotlin/app/revanced/patches/youtube/misc/playertype/fingerprint/VideoStateFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package app.revanced.patches.youtube.misc.playertype.fingerprint | ||
|
||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import org.jf.dexlib2.AccessFlags | ||
import org.jf.dexlib2.Opcode | ||
|
||
object VideoStateFingerprint : MethodFingerprint( | ||
access = AccessFlags.PUBLIC or AccessFlags.FINAL, | ||
returnType = "V", | ||
parameters = listOf("L"), | ||
opcodes = listOf( | ||
Opcode.IGET_OBJECT, | ||
Opcode.INVOKE_VIRTUAL, | ||
Opcode.IGET_OBJECT, | ||
Opcode.CONST_4, | ||
Opcode.IF_EQZ, | ||
Opcode.IF_EQZ, | ||
Opcode.IGET_OBJECT, // obfuscated parameter field name | ||
), | ||
customFingerprint = { methodDef, _ -> | ||
methodDef.definingClass.endsWith("YouTubeControlsOverlay;") | ||
} | ||
) |
47 changes: 37 additions & 10 deletions
47
src/main/kotlin/app/revanced/patches/youtube/misc/playertype/patch/PlayerTypeHookPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,61 @@ | ||
package app.revanced.patches.youtube.misc.playertype.patch | ||
|
||
import app.revanced.extensions.toErrorResult | ||
import app.revanced.patcher.annotation.Description | ||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.addInstruction | ||
import app.revanced.patcher.extensions.addInstructions | ||
import app.revanced.patcher.extensions.instruction | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.PatchResult | ||
import app.revanced.patcher.patch.PatchResultSuccess | ||
import app.revanced.patcher.patch.annotations.DependsOn | ||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch | ||
import app.revanced.patches.youtube.misc.playertype.annotation.PlayerTypeHookCompatibility | ||
import app.revanced.patches.youtube.misc.playertype.fingerprint.UpdatePlayerTypeFingerprint | ||
import app.revanced.patches.youtube.misc.playertype.fingerprint.PlayerTypeFingerprint | ||
import app.revanced.patches.youtube.misc.playertype.fingerprint.VideoStateFingerprint | ||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction | ||
|
||
@Name("player-type-hook") | ||
@Description("Hook to get the current player type of WatchWhileActivity") | ||
@Description("Hook to get the current player type and video playback state.") | ||
@PlayerTypeHookCompatibility | ||
@Version("0.0.1") | ||
@DependsOn([IntegrationsPatch::class]) | ||
class PlayerTypeHookPatch : BytecodePatch( | ||
listOf( | ||
UpdatePlayerTypeFingerprint | ||
) | ||
listOf(PlayerTypeFingerprint, VideoStateFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext): PatchResult { | ||
// hook YouTubePlayerOverlaysLayout.updatePlayerLayout() | ||
UpdatePlayerTypeFingerprint.result!!.mutableMethod.addInstruction( | ||
0, | ||
"invoke-static { p1 }, Lapp/revanced/integrations/patches/PlayerTypeHookPatch;->YouTubePlayerOverlaysLayout_updatePlayerTypeHookEX(Ljava/lang/Object;)V" | ||
) | ||
|
||
PlayerTypeFingerprint.result?.let { | ||
it.mutableMethod.apply { | ||
addInstruction( | ||
0, | ||
"invoke-static {p1}, $INTEGRATIONS_CLASS_DESCRIPTOR->setPlayerType(Ljava/lang/Enum;)V" | ||
) | ||
} | ||
} ?: return PlayerTypeFingerprint.toErrorResult() | ||
|
||
VideoStateFingerprint.result?.let { | ||
it.mutableMethod.apply { | ||
val endIndex = it.scanResult.patternScanResult!!.endIndex | ||
val videoStateFieldName = instruction<ReferenceInstruction>(endIndex).reference | ||
addInstructions( | ||
0, """ | ||
iget-object v0, p1, $videoStateFieldName # copy VideoState parameter field | ||
invoke-static {v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->setVideoState(Ljava/lang/Enum;)V | ||
""" | ||
) | ||
} | ||
} ?: return VideoStateFingerprint.toErrorResult() | ||
|
||
return PatchResultSuccess() | ||
} | ||
|
||
companion object { | ||
private const val INTEGRATIONS_CLASS_DESCRIPTOR = | ||
"Lapp/revanced/integrations/patches/PlayerTypeHookPatch;" | ||
} | ||
|
||
} |