Skip to content

Commit

Permalink
fix(YouTube/Hide feed components): Hide related videos setting hide…
Browse files Browse the repository at this point in the history
…s the player flyout component
  • Loading branch information
inotia00 committed Sep 28, 2024
1 parent 577f49b commit 4558869
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import app.revanced.patches.youtube.feed.components.fingerprints.LinearLayoutMan
import app.revanced.patches.youtube.feed.components.fingerprints.RelatedChipCloudFingerprint
import app.revanced.patches.youtube.feed.components.fingerprints.SearchResultsChipBarFingerprint
import app.revanced.patches.youtube.feed.components.fingerprints.ShowMoreButtonFingerprint
import app.revanced.patches.youtube.utils.bottomsheet.BottomSheetHookPatch
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.fingerprints.EngagementPanelBuilderFingerprint
import app.revanced.patches.youtube.utils.fingerprints.ScrollTopParentFingerprint
Expand Down Expand Up @@ -65,7 +66,8 @@ object FeedComponentsPatch : BaseBytecodePatch(
NavigationBarHookPatch::class,
PlayerTypeHookPatch::class,
SettingsPatch::class,
SharedResourceIdPatch::class
SharedResourceIdPatch::class,
BottomSheetHookPatch::class,
),
compatiblePackages = COMPATIBLE_PACKAGE,
fingerprints = setOf(
Expand Down Expand Up @@ -158,7 +160,10 @@ object FeedComponentsPatch : BaseBytecodePatch(
fun Method.indexOfEngagementPanelBuilderInstruction(targetMethod: MutableMethod) =
indexOfFirstInstruction {
opcode == Opcode.INVOKE_DIRECT &&
MethodUtil.methodSignaturesMatch(targetMethod, getReference<MethodReference>()!!)
MethodUtil.methodSignaturesMatch(
targetMethod,
getReference<MethodReference>()!!
)
}

EngagementPanelBuilderFingerprint.resultOrThrow().let {
Expand Down Expand Up @@ -189,7 +194,8 @@ object FeedComponentsPatch : BaseBytecodePatch(
// Otherwise, MethodWalker finds the wrong class in YouTube 18.29.38:
// https://github.com/ReVanced/revanced-patcher/issues/309
LinearLayoutManagerItemCountsFingerprint.resultOrThrow().let {
val methodWalker = it.getWalkerMethod(context, it.scanResult.patternScanResult!!.endIndex)
val methodWalker =
it.getWalkerMethod(context, it.scanResult.patternScanResult!!.endIndex)
methodWalker.apply {
val index = indexOfFirstInstructionOrThrow(Opcode.MOVE_RESULT)
val register = getInstruction<OneRegisterInstruction>(index).registerA
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package app.revanced.patches.youtube.utils.bottomsheet

import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.youtube.utils.bottomsheet.fingerprint.BottomSheetBehaviorFingerprint
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.util.findMethodOrThrow
import app.revanced.util.resultOrThrow

@Patch(dependencies = [SharedResourceIdPatch::class])
object BottomSheetHookPatch : BytecodePatch(
setOf(BottomSheetBehaviorFingerprint)
) {
private const val INTEGRATIONS_BOTTOM_SHEET_HOOK_CLASS_DESCRIPTOR =
"$UTILS_PATH/BottomSheetHookPatch;"

override fun execute(context: BytecodeContext) {

// region patch for set player type

val bottomSheetClass =
BottomSheetBehaviorFingerprint.resultOrThrow().mutableMethod.definingClass

arrayOf(
"onAttachedToWindow",
"onDetachedFromWindow"
).forEach { methodName ->
context.findMethodOrThrow(bottomSheetClass) {
name == methodName
}.addInstruction(
1,
"invoke-static {}, $INTEGRATIONS_BOTTOM_SHEET_HOOK_CLASS_DESCRIPTOR->$methodName()V"
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package app.revanced.patches.youtube.utils.bottomsheet.fingerprint

import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.DesignBottomSheet
import app.revanced.util.fingerprint.LiteralValueFingerprint

internal object BottomSheetBehaviorFingerprint : LiteralValueFingerprint(
returnType = "V",
literalSupplier = { DesignBottomSheet }
)
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ object SharedResourceIdPatch : ResourcePatch() {
var ControlsLayoutStub = -1L
var DarkBackground = -1L
var DarkSplashAnimation = -1L
var DesignBottomSheet = -1L
var DonationCompanion = -1L
var DrawerContentView = -1L
var DrawerResults = -1L
Expand Down Expand Up @@ -152,6 +153,7 @@ object SharedResourceIdPatch : ResourcePatch() {
ControlsLayoutStub = getId(ID, "controls_layout_stub")
DarkBackground = getId(ID, "dark_background")
DarkSplashAnimation = getId(ID, "dark_splash_animation")
DesignBottomSheet = getId(ID, "design_bottom_sheet")
DonationCompanion = getId(LAYOUT, "donation_companion")
DrawerContentView = getId(ID, "drawer_content_view")
DrawerResults = getId(ID, "drawer_results")
Expand Down

0 comments on commit 4558869

Please sign in to comment.