Skip to content

Commit

Permalink
feat(YouTube): Support version 19.03.35
Browse files Browse the repository at this point in the history
  • Loading branch information
LisoUseInAIKyrios committed Jan 24, 2024
1 parent ba6d1dc commit aedf487
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ object HideShortsComponentsPatch : BytecodePatch(
override fun execute(context: BytecodeContext) {
// region Hide the Shorts shelf.

// This patch point is not present in 19.03.x and greater.
// If 19.02.x and lower is dropped, then this section of code and the fingerprint should be removed.
ReelConstructorFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex + 2
Expand All @@ -71,7 +73,7 @@ object HideShortsComponentsPatch : BytecodePatch(
"hideShortsShelf"
)
}
} ?: throw ReelConstructorFingerprint.exception
} // Do not throw an exception if not resolved.

// endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,15 @@ object HideShortsComponentsResourcePatch : ResourcePatch() {
)
)

fun String.getId() = ResourceMappingPatch.resourceMappings.single { it.name == this }.id
ResourceMappingPatch.resourceMappings.find {
it.type == "layout" && it.name == "reel_multiple_items_shelf"
}?.also {
reelMultipleItemShelfId = it.id
}

reelMultipleItemShelfId = "reel_multiple_items_shelf".getId()
reelPlayerRightCellButtonHeight = "reel_player_right_cell_button_height".getId()
reelPlayerRightCellButtonHeight =
ResourceMappingPatch.resourceMappings.single {
it.type == "dimen" && it.name == "reel_player_right_cell_button_height"
}.id
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package app.revanced.patches.youtube.layout.hide.shorts.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint
import app.revanced.patches.youtube.layout.hide.shorts.HideShortsComponentsResourcePatch
import app.revanced.util.patch.LiteralValueFingerprint
import app.revanced.util.containsWideLiteralInstructionValue
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode

internal object ReelConstructorFingerprint : LiteralValueFingerprint(
internal object ReelConstructorFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
opcodes = listOf(Opcode.INVOKE_VIRTUAL),
literalSupplier = { HideShortsComponentsResourcePatch.reelMultipleItemShelfId }
customFingerprint = { methodDef, _ ->
// Cannot use LiteralValueFingerprint, because the resource id may not be present.
val reelMultipleItemShelfId = HideShortsComponentsResourcePatch.reelMultipleItemShelfId;
reelMultipleItemShelfId != -1L
&& methodDef.containsWideLiteralInstructionValue(reelMultipleItemShelfId)
}
)

0 comments on commit aedf487

Please sign in to comment.