feat(YouTube - Hide layout components): Add option to hide Yoodles (YouTube Doodles) (#3743)

Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
LisoUseInAIKyrios 2024-10-05 20:09:06 -04:00 committed by GitHub
parent 5a08620356
commit 0679a47b22
6 changed files with 74 additions and 4 deletions

View file

@ -224,18 +224,25 @@ fun Method.indexOfFirstInstructionOrThrow(startIndex: Int = 0, predicate: Instru
/**
* @return The list of indices of the opcode in reverse order.
*/
fun Method.findOpcodeIndicesReversed(opcode: Opcode): List<Int> {
fun Method.findOpcodeIndicesReversed(opcode: Opcode): List<Int> =
findOpcodeIndicesReversed { this.opcode == opcode }
/**
* @return The list of indices of the opcode in reverse order.
*/
fun Method.findOpcodeIndicesReversed(filter: Instruction.() -> Boolean): List<Int> {
val indexes = implementation!!.instructions
.withIndex()
.filter { (_, instruction) -> instruction.opcode == opcode }
.filter { (_, instruction) -> filter(instruction) }
.map { (index, _) -> index }
.reversed()
if (indexes.isEmpty()) throw PatchException("No ${opcode.name} instructions found in: $this")
if (indexes.isEmpty()) throw PatchException("No matching instructions found in: $this")
return indexes
}
/**
* Return the resolved method early.
*/