add support YouTube v18.15.38

This commit is contained in:
inotia00
2023-04-21 13:34:36 +09:00
parent da812997fb
commit bc3c1ae6a5
2 changed files with 19 additions and 9 deletions

View File

@ -14,7 +14,8 @@ import app.revanced.patcher.annotation.Package
"18.11.36", "18.11.36",
"18.12.35", "18.12.35",
"18.13.38", "18.13.38",
"18.14.41" "18.14.41",
"18.15.38"
) )
)] )]
) )

View File

@ -23,6 +23,7 @@ import app.revanced.util.bytecode.BytecodeHelper.injectInit
import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode
import org.jf.dexlib2.builder.BuilderInstruction import org.jf.dexlib2.builder.BuilderInstruction
import org.jf.dexlib2.builder.instruction.BuilderInstruction3rc
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction
@ -122,19 +123,27 @@ class SponsorBlockBytecodePatch : BytecodePatch(
/* /*
* Draw segment * Draw segment
*/ */
val drawSegmentInstructionInsertIndex = (insertInstructions.size - 1 - 2) for ((index, instruction) in insertInstructions.withIndex()) {
val (canvasInstance, centerY) = (insertInstructions[drawSegmentInstructionInsertIndex] as FiveRegisterInstruction).let { if (instruction.opcode != Opcode.INVOKE_VIRTUAL_RANGE) continue
it.registerC to it.registerE
val invokeInstruction = instruction as BuilderInstruction3rc
if ((invokeInstruction.reference as MethodReference).name != "restore") continue
val drawSegmentInstructionInsertIndex = index - 1
val (canvasInstance, centerY) = (insertInstructions[drawSegmentInstructionInsertIndex] as FiveRegisterInstruction).let {
it.registerC to it.registerE
}
insertMethod.addInstruction(
drawSegmentInstructionInsertIndex,
"invoke-static {v$canvasInstance, v$centerY}, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->drawSponsorTimeBars(Landroid/graphics/Canvas;F)V"
)
break
} }
insertMethod.addInstruction(
drawSegmentInstructionInsertIndex,
"invoke-static {v$canvasInstance, v$centerY}, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->drawSponsorTimeBars(Landroid/graphics/Canvas;F)V"
)
/* /*
* Voting & Shield button * Voting & Shield button
*/ */
arrayOf("CreateSegmentButtonController", "VotingButtonController").forEach { arrayOf("CreateSegmentButtonController", "VotingButtonController").forEach {
PlayerControlsPatch.initializeSB("$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/ui/$it;") PlayerControlsPatch.initializeSB("$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/ui/$it;")
PlayerControlsPatch.injectVisibility("$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/ui/$it;") PlayerControlsPatch.injectVisibility("$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/ui/$it;")