fix(youtube): separate hide-general-ads to hide-layout-components patch

This commit is contained in:
inotia00
2023-06-23 19:38:17 +09:00
parent 5080ae5452
commit 00fb748025
237 changed files with 655 additions and 471 deletions

View File

@ -1,8 +1,12 @@
package app.revanced.patches.youtube.utils.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
object LayoutConstructorFingerprint : MethodFingerprint(
strings = listOf("1.0x"),
customFingerprint = { it, _ -> it.definingClass.endsWith("YouTubeControlsOverlay;") }
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = emptyList(),
strings = listOf("1.0x")
)

View File

@ -5,5 +5,5 @@ import org.jf.dexlib2.Opcode
object OnBackPressedFingerprint : MethodFingerprint(
opcodes = listOf(Opcode.RETURN_VOID),
customFingerprint = { it, _ -> it.definingClass.endsWith("WatchWhileActivity;") && it.name == "onBackPressed" }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("WatchWhileActivity;") && methodDef.name == "onBackPressed" }
)

View File

@ -14,5 +14,5 @@ object PivotBarCreateButtonViewFingerprint : MethodFingerprint(
Opcode.MOVE_OBJECT,
Opcode.INVOKE_DIRECT_RANGE, // unique instruction anchor
),
customFingerprint = { it, _ -> it.isWideLiteralExists(ImageOnlyTab) }
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(ImageOnlyTab) }
)

View File

@ -2,13 +2,15 @@ package app.revanced.patches.youtube.utils.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.AccessibilityCaptionsButtonName
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object SubtitleButtonControllerFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("Lcom/google/android/libraries/youtube/player/subtitles/model/SubtitleTrack;"),
parameters = listOf("L"),
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.IF_NEZ,
@ -20,5 +22,9 @@ object SubtitleButtonControllerFingerprint : MethodFingerprint(
Opcode.INVOKE_VIRTUAL,
Opcode.IGET_OBJECT
),
customFingerprint = { it, _ -> it.definingClass.endsWith("SubtitleButtonController;") }
customFingerprint = { methodDef, _ ->
methodDef.isWideLiteralExists(
AccessibilityCaptionsButtonName
)
}
)

View File

@ -6,5 +6,5 @@ import app.revanced.util.bytecode.isWideLiteralExists
object TotalTimeFingerprint : MethodFingerprint(
returnType = "V",
customFingerprint = { it, _ -> it.isWideLiteralExists(TotalTime) }
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(TotalTime) }
)

View File

@ -0,0 +1,24 @@
package app.revanced.patches.youtube.utils.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.YoutubeControlsOverlay
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object YouTubeControlsOverlayFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
parameters = emptyList(),
opcodes = listOf(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT,
Opcode.IF_EQZ
),
customFingerprint = { methodDef, _ ->
methodDef.isWideLiteralExists(
YoutubeControlsOverlay
)
}
)

View File

@ -20,6 +20,6 @@ object ScrollTopParentFingerprint : MethodFingerprint(
Opcode.IPUT_OBJECT,
Opcode.RETURN_VOID
),
customFingerprint = { it, _ -> it.name == "<init>" }
customFingerprint = { methodDef, _ -> methodDef.name == "<init>" }
)

View File

@ -11,8 +11,8 @@ import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.utils.fingerprints.OnBackPressedFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.fingerprints.OnBackPressedFingerprint
import app.revanced.patches.youtube.utils.fix.doublebacktoclose.fingerprint.ScrollPositionFingerprint
import app.revanced.patches.youtube.utils.fix.doublebacktoclose.fingerprint.ScrollTopFingerprint
import app.revanced.patches.youtube.utils.fix.doublebacktoclose.fingerprint.ScrollTopParentFingerprint

View File

@ -4,5 +4,5 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object SubtitleWindowFingerprint : MethodFingerprint(
parameters = listOf("I", "I", "I", "Z", "Z"),
customFingerprint = { it, _ -> it.definingClass.endsWith("SubtitleWindowSettings;") && it.name == "<init>" }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("SubtitleWindowSettings;") && methodDef.name == "<init>" }
)

View File

@ -15,5 +15,5 @@ object SwipeRefreshLayoutFingerprint : MethodFingerprint(
Opcode.MOVE_RESULT,
Opcode.RETURN
),
customFingerprint = { it, _ -> it.definingClass.endsWith("SwipeRefreshLayout;") }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("SwipeRefreshLayout;") }
)

View File

@ -0,0 +1,11 @@
package app.revanced.patches.youtube.utils.litho.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object LithoFilterFingerprint : MethodFingerprint(
customFingerprint = custom@{ method, classDef ->
if (method.name != "<clinit>") return@custom false
classDef.type.endsWith("LithoFilterPatch;")
}
)

View File

@ -15,5 +15,5 @@ object LithoThemeFingerprint : MethodFingerprint(
Opcode.INVOKE_VIRTUAL, // Paint.setColor: inject point
Opcode.RETURN_VOID
),
customFingerprint = { it, _ -> it.name == "onBoundsChange" }
customFingerprint = { methodDef, _ -> methodDef.name == "onBoundsChange" }
)

View File

@ -4,6 +4,9 @@ import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
@ -11,25 +14,26 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.patch.litho.ComponentParserPatch
import app.revanced.patches.shared.patch.litho.ComponentParserPatch.Companion.generalHook
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.fix.doublebacktoclose.patch.DoubleBackToClosePatch
import app.revanced.patches.youtube.utils.fix.swiperefresh.patch.SwipeRefreshPatch
import app.revanced.patches.youtube.utils.litho.fingerprints.ByteBufferFingerprint
import app.revanced.patches.youtube.utils.litho.fingerprints.LithoFilterFingerprint
import app.revanced.patches.youtube.utils.playertype.patch.PlayerTypeHookPatch
import app.revanced.util.integrations.Constants.ADS_PATH
import java.io.Closeable
@DependsOn(
[
ComponentParserPatch::class,
DoubleBackToClosePatch::class,
PlayerTypeHookPatch::class,
SwipeRefreshPatch::class
PlayerTypeHookPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class LithoFilterPatch : BytecodePatch(
listOf(ByteBufferFingerprint)
) {
listOf(
ByteBufferFingerprint,
LithoFilterFingerprint
)
), Closeable {
override fun execute(context: BytecodeContext): PatchResult {
@ -38,9 +42,34 @@ class LithoFilterPatch : BytecodePatch(
"sput-object p0, $ADS_PATH/ByteBufferFilterPatch;->bytebuffer:Ljava/nio/ByteBuffer;"
) ?: return ByteBufferFingerprint.toErrorResult()
generalHook("$ADS_PATH/LithoFilterPatch;->filters")
LithoFilterFingerprint.result?.mutableMethod?.apply {
removeInstructions(2, 4) // Remove dummy filter.
addFilter = { classDescriptor ->
addInstructions(
2,
"""
new-instance v1, $classDescriptor
invoke-direct {v1}, $classDescriptor-><init>()V
const/4 v2, ${filterCount++}
aput-object v1, v0, v2
"""
)
}
} ?: return LithoFilterFingerprint.toErrorResult()
return PatchResultSuccess()
}
override fun close() = LithoFilterFingerprint.result!!
.mutableMethod.replaceInstruction(0, "const/4 v0, $filterCount")
companion object {
internal lateinit var addFilter: (String) -> Unit
private set
private var filterCount = 0
}
}

View File

@ -15,5 +15,5 @@ object TopBarButtonFingerprint : MethodFingerprint(
Opcode.IF_EQZ
),
strings = listOf("parent_csn", "parent_ve_type"),
customFingerprint = { it, _ -> it.name == "onClick" }
customFingerprint = { methodDef, _ -> methodDef.name == "onClick" }
)

View File

@ -11,8 +11,8 @@ 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.utils.fingerprints.OnBackPressedFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.fingerprints.OnBackPressedFingerprint
import app.revanced.patches.youtube.utils.navbarindex.fingerprints.NavBarBuilderFingerprint
import app.revanced.patches.youtube.utils.navbarindex.fingerprints.TopBarButtonFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch

View File

@ -12,5 +12,5 @@ object VideoSpeedChangedFingerprint : MethodFingerprint(
Opcode.IGET_OBJECT,
Opcode.INVOKE_VIRTUAL
),
customFingerprint = { it, _ -> it.name == "onItemClick" }
customFingerprint = { methodDef, _ -> methodDef.name == "onItemClick" }
)

View File

@ -8,5 +8,5 @@ object VideoSpeedPatchFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
parameters = listOf("F"),
customFingerprint = { it, _ -> it.definingClass.endsWith("/VideoSpeedPatch;") && it.name == "overrideSpeed" }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/VideoSpeedPatch;") && methodDef.name == "overrideSpeed" }
)

View File

@ -7,5 +7,5 @@ import org.jf.dexlib2.Opcode
object LiveChatFingerprint : MethodFingerprint(
opcodes = listOf(Opcode.NEW_INSTANCE),
customFingerprint = { it, _ -> it.isWideLiteralExists(LiveChatButton) }
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(LiveChatButton) }
)

View File

@ -11,5 +11,5 @@ object BottomControlsInflateFingerprint : MethodFingerprint(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT
),
customFingerprint = { it, _ -> it.isWideLiteralExists(BottomUiContainerStub) }
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(BottomUiContainerStub) }
)

View File

@ -13,5 +13,5 @@ object ControlsLayoutInflateFingerprint : MethodFingerprint(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT
),
customFingerprint = { it, _ -> it.isWideLiteralExists(ControlsLayoutStub) }
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(ControlsLayoutStub) }
)

View File

@ -4,6 +4,5 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object PlayerControlsVisibilityFingerprint : MethodFingerprint(
returnType = "V",
parameters = listOf("Z", "Z"),
customFingerprint = { it, _ -> it.definingClass.endsWith("YouTubeControlsOverlay;") }
parameters = listOf("Z", "Z")
)

View File

@ -6,5 +6,5 @@ import org.jf.dexlib2.Opcode
object SpeedEduVisibleFingerprint : MethodFingerprint(
returnType = "V",
opcodes = listOf(Opcode.IPUT_BOOLEAN),
customFingerprint = { it, _ -> it.name == "<init>" }
customFingerprint = { methodDef, _ -> methodDef.name == "<init>" }
)

View File

@ -16,6 +16,7 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.fingerprints.YouTubeControlsOverlayFingerprint
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.BottomControlsInflateFingerprint
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.ControlsLayoutInflateFingerprint
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.PlayerControlsVisibilityFingerprint
@ -33,7 +34,7 @@ import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
import org.jf.dexlib2.iface.reference.Reference
@Name("player-controls-bytecode-patch")
@Name("player-controls-patch")
@DependsOn([SharedResourceIdPatch::class])
@Description("Manages the code for the player controls of the YouTube player.")
@YouTubeCompatibility
@ -42,9 +43,9 @@ class PlayerControlsPatch : BytecodePatch(
listOf(
BottomControlsInflateFingerprint,
ControlsLayoutInflateFingerprint,
PlayerControlsVisibilityFingerprint,
PlayerControlsVisibilityModelFingerprint,
SpeedEduVisibleParentFingerprint
SpeedEduVisibleParentFingerprint,
YouTubeControlsOverlayFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
@ -61,8 +62,14 @@ class PlayerControlsPatch : BytecodePatch(
userScrubbingResult =
UserScrubbingFingerprint.result ?: return UserScrubbingFingerprint.toErrorResult()
val controlsOverlayClassDef =
YouTubeControlsOverlayFingerprint.result?.classDef
?: return YouTubeControlsOverlayFingerprint.toErrorResult()
PlayerControlsVisibilityFingerprint.resolve(context, controlsOverlayClassDef)
playerControlsVisibilityResult = PlayerControlsVisibilityFingerprint.result
?: return PlayerControlsVisibilityFingerprint.toErrorResult()
controlsLayoutInflateResult = ControlsLayoutInflateFingerprint.result
?: return ControlsLayoutInflateFingerprint.toErrorResult()
inflateResult = BottomControlsInflateFingerprint.result

View File

@ -3,5 +3,5 @@ package app.revanced.patches.youtube.utils.playeroverlay.fingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object PlayerOverlaysOnFinishInflateFingerprint : MethodFingerprint(
customFingerprint = { it, _ -> it.definingClass.endsWith("YouTubePlayerOverlaysLayout;") && it.name == "onFinishInflate" }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("YouTubePlayerOverlaysLayout;") && methodDef.name == "onFinishInflate" }
)

View File

@ -13,5 +13,5 @@ object PlayerTypeFingerprint : MethodFingerprint(
Opcode.IF_NE,
Opcode.RETURN_VOID
),
customFingerprint = { it, _ -> it.definingClass.endsWith("YouTubePlayerOverlaysLayout;") }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("YouTubePlayerOverlaysLayout;") }
)

View File

@ -17,6 +17,5 @@ object VideoStateFingerprint : MethodFingerprint(
Opcode.IF_EQZ,
Opcode.IF_EQZ,
Opcode.IGET_OBJECT, // obfuscated parameter field name
),
customFingerprint = { it, _ -> it.definingClass.endsWith("YouTubeControlsOverlay;") }
)
)

View File

@ -8,10 +8,12 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.fingerprints.YouTubeControlsOverlayFingerprint
import app.revanced.patches.youtube.utils.playertype.fingerprint.PlayerTypeFingerprint
import app.revanced.patches.youtube.utils.playertype.fingerprint.VideoStateFingerprint
import app.revanced.util.integrations.Constants.UTILS_PATH
@ -24,7 +26,7 @@ import org.jf.dexlib2.iface.instruction.ReferenceInstruction
class PlayerTypeHookPatch : BytecodePatch(
listOf(
PlayerTypeFingerprint,
VideoStateFingerprint
YouTubeControlsOverlayFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
@ -38,18 +40,26 @@ class PlayerTypeHookPatch : BytecodePatch(
}
} ?: return PlayerTypeFingerprint.toErrorResult()
VideoStateFingerprint.result?.let {
it.mutableMethod.apply {
val endIndex = it.scanResult.patternScanResult!!.endIndex
val videoStateFieldName = getInstruction<ReferenceInstruction>(endIndex).reference
addInstructions(
0, """
YouTubeControlsOverlayFingerprint.result?.let { parentResult ->
VideoStateFingerprint.also {
it.resolve(
context,
parentResult.classDef
)
}.result?.let {
it.mutableMethod.apply {
val endIndex = it.scanResult.patternScanResult!!.endIndex
val videoStateFieldName =
getInstruction<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 YouTubeControlsOverlayFingerprint.toErrorResult()
return PatchResultSuccess()
}

View File

@ -19,5 +19,5 @@ object QuickActionsElementFingerprint : MethodFingerprint(
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST
),
customFingerprint = { it, _ -> it.isWideLiteralExists(QuickActionsElementContainer) }
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(QuickActionsElementContainer) }
)

View File

@ -26,11 +26,13 @@ import app.revanced.util.enum.ResourceType.STRING
class SharedResourceIdPatch : ResourcePatch {
internal companion object {
var AccountSwitcherAccessibility: Long = -1
var AccessibilityCaptionsButtonName: Long = -1
var ActionBarRingo: Long = -1
var AdAttribution: Long = -1
var Appearance: Long = -1
var AppRelatedEndScreenResults: Long = -1
var AutoNavPreviewStub: Long = -1
var AutoNavToggle: Long = -1
var BackgroundCategory: Long = -1
var BarContainerHeight: Long = -1
var BottomPanelOverlayText: Long = -1
@ -55,6 +57,7 @@ class SharedResourceIdPatch : ResourcePatch {
var InlineTimeBarPlayedNotHighlightedColor: Long = -1
var InsetOverlayViewLayout: Long = -1
var LiveChatButton: Long = -1
var MusicAppDeeplinkButtonView: Long = -1
var QuickActionsElementContainer: Long = -1
var ReelDynRemix: Long = -1
var ReelPlayerBadge: Long = -1
@ -67,12 +70,13 @@ class SharedResourceIdPatch : ResourcePatch {
var ScrimOverlay: Long = -1
var Scrubbing: Long = -1
var SearchSuggestionEntry: Long = -1
var SettingsBooleanTimeRangeDialog: Long = -1
var SuggestedAction: Long = -1
var ToolBarPaddingHome: Long = -1
var ToolTipContentView: Long = -1
var TotalTime: Long = -1
var VideoQualityBottomSheet: Long = -1
var WatchWhileTimeBarOverlayStub: Long = -1
var VideoZoomIndicatorLayout: Long = -1
var WordMarkHeader: Long = -1
var YoutubeControlsOverlay: Long = -1
}
@ -85,11 +89,13 @@ class SharedResourceIdPatch : ResourcePatch {
?: throw PatchResultError("Failed to find resource id : $resourceName")
AccountSwitcherAccessibility = find(STRING, "account_switcher_accessibility_label")
AccessibilityCaptionsButtonName = find(STRING, "accessibility_captions_button_name")
ActionBarRingo = find(LAYOUT, "action_bar_ringo")
AdAttribution = find(ID, "ad_attribution")
Appearance = find(STRING, "app_theme_appearance_dark")
AppRelatedEndScreenResults = find(LAYOUT, "app_related_endscreen_results")
AutoNavPreviewStub = find(ID, "autonav_preview_stub")
AutoNavToggle = find(ID, "autonav_toggle")
BackgroundCategory = find(STRING, "pref_background_and_offline_category")
BarContainerHeight = find(DIMEN, "bar_container_height")
BottomPanelOverlayText = find(ID, "bottom_panel_overlay_text")
@ -116,6 +122,7 @@ class SharedResourceIdPatch : ResourcePatch {
find(COLOR, "inline_time_bar_played_not_highlighted_color")
InsetOverlayViewLayout = find(ID, "inset_overlay_view_layout")
LiveChatButton = find(ID, "live_chat_overlay_button")
MusicAppDeeplinkButtonView = find(ID, "music_app_deeplink_button_view")
QuickActionsElementContainer = find(ID, "quick_actions_element_container")
ReelDynRemix = find(ID, "reel_dyn_remix")
ReelPlayerBadge = find(ID, "reel_player_badge")
@ -128,12 +135,13 @@ class SharedResourceIdPatch : ResourcePatch {
ScrimOverlay = find(ID, "scrim_overlay")
Scrubbing = find(DIMEN, "vertical_touch_offset_to_enter_fine_scrubbing")
SearchSuggestionEntry = find(LAYOUT, "search_suggestion_entry")
SettingsBooleanTimeRangeDialog = find(LAYOUT, "setting_boolean_time_range_dialog")
SuggestedAction = find(LAYOUT, "suggested_action")
ToolBarPaddingHome = find(DIMEN, "toolbar_padding_home_action_up")
ToolTipContentView = find(LAYOUT, "tooltip_content_view")
TotalTime = find(STRING, "total_time")
VideoQualityBottomSheet = find(LAYOUT, "video_quality_bottom_sheet_list_fragment_title")
WatchWhileTimeBarOverlayStub = find(ID, "watch_while_timebar_overlay_stub")
VideoZoomIndicatorLayout = find(ID, "video_zoom_indicator_layout")
WordMarkHeader = find(ATTR, "ytWordmarkHeader")
YoutubeControlsOverlay = find(ID, "youtube_controls_overlay")

View File

@ -10,5 +10,5 @@ object ButtonTagFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"),
customFingerprint = { it, _ -> it.isWideLiteralExists(DislikeButton) }
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(DislikeButton) }
)

View File

@ -8,5 +8,5 @@ import org.jf.dexlib2.Opcode
object ThemeSetterSystemFingerprint : MethodFingerprint(
returnType = "L",
opcodes = listOf(Opcode.RETURN_OBJECT),
customFingerprint = { it, _ -> it.isWideLiteralExists(Appearance) }
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(Appearance) }
)

View File

@ -1,20 +0,0 @@
package app.revanced.patches.youtube.utils.sponsorblock.bytecode.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.InsetOverlayViewLayout
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
object OverlayViewLayoutFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.CONST,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST
),
customFingerprint = { it, _ ->
it.definingClass.endsWith("YouTubeControlsOverlay;") && it.isWideLiteralExists(
InsetOverlayViewLayout
)
}
)

View File

@ -3,5 +3,5 @@ package app.revanced.patches.youtube.utils.sponsorblock.bytecode.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object PlayerControllerFingerprint : MethodFingerprint(
customFingerprint = { it, _ -> it.definingClass.endsWith("SegmentPlaybackController;") && it.name == "setSponsorBarRect" }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("SegmentPlaybackController;") && methodDef.name == "setSponsorBarRect" }
)

View File

@ -14,17 +14,17 @@ import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.fingerprints.SeekbarFingerprint
import app.revanced.patches.youtube.utils.fingerprints.SeekbarOnDrawFingerprint
import app.revanced.patches.youtube.utils.fingerprints.TotalTimeFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.fingerprints.YouTubeControlsOverlayFingerprint
import app.revanced.patches.youtube.utils.overridespeed.patch.OverrideSpeedHookPatch
import app.revanced.patches.youtube.utils.playercontrols.patch.PlayerControlsPatch
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.InsetOverlayViewLayout
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.TotalTime
import app.revanced.patches.youtube.utils.sponsorblock.bytecode.fingerprints.EndScreenEngagementPanelsFingerprint
import app.revanced.patches.youtube.utils.sponsorblock.bytecode.fingerprints.OverlayViewLayoutFingerprint
import app.revanced.patches.youtube.utils.sponsorblock.bytecode.fingerprints.PlayerControllerFingerprint
import app.revanced.patches.youtube.utils.sponsorblock.bytecode.fingerprints.RectangleFieldInvalidatorFingerprint
import app.revanced.patches.youtube.utils.videoid.legacy.patch.LegacyVideoIdPatch
@ -57,9 +57,9 @@ import org.jf.dexlib2.iface.reference.MethodReference
class SponsorBlockBytecodePatch : BytecodePatch(
listOf(
EndScreenEngagementPanelsFingerprint,
OverlayViewLayoutFingerprint,
PlayerControllerFingerprint,
TotalTimeFingerprint
TotalTimeFingerprint,
YouTubeControlsOverlayFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
@ -175,7 +175,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
/**
* Initialize the SponsorBlock view
*/
OverlayViewLayoutFingerprint.result?.mutableMethod?.let {
YouTubeControlsOverlayFingerprint.result?.mutableMethod?.let {
it.apply {
val targetIndex = getWideLiteralIndex(InsetOverlayViewLayout) + 3
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -185,7 +185,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
"invoke-static {v$targetRegister}, $INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/ui/SponsorBlockViewController;->initialize(Landroid/view/ViewGroup;)V"
)
}
} ?: return OverlayViewLayoutFingerprint.toErrorResult()
} ?: return YouTubeControlsOverlayFingerprint.toErrorResult()
/**
* Replace strings

View File

@ -1,14 +0,0 @@
package app.revanced.patches.youtube.utils.videoid.legacy.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 LegacyVideoIdFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.DECLARED_SYNCHRONIZED or AccessFlags.FINAL or AccessFlags.PUBLIC,
parameters = listOf("L"),
opcodes = listOf(Opcode.INVOKE_INTERFACE),
customFingerprint = { it, _ -> it.definingClass.endsWith("PlaybackLifecycleMonitor;") }
)

View File

@ -0,0 +1,23 @@
package app.revanced.patches.youtube.utils.videoid.legacy.fingerprint
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object LegacyVideoIdParentFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"),
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.CHECK_CAST,
Opcode.CHECK_CAST,
Opcode.INVOKE_VIRTUAL,
Opcode.RETURN_VOID
),
customFingerprint = { methodDef, _ ->
methodDef.isWideLiteralExists(78882851)
}
)

View File

@ -5,14 +5,17 @@ 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.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.videoid.legacy.fingerprint.LegacyVideoIdFingerprint
import app.revanced.patches.youtube.utils.videoid.legacy.fingerprint.LegacyVideoIdParentFingerprint
import app.revanced.util.integrations.Constants.VIDEO_PATH
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Name("video-id-hook-legacy")
@ -20,20 +23,23 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@YouTubeCompatibility
@Version("0.0.1")
class LegacyVideoIdPatch : BytecodePatch(
listOf(LegacyVideoIdFingerprint)
listOf(LegacyVideoIdParentFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
LegacyVideoIdFingerprint.result?.let {
insertIndex = it.scanResult.patternScanResult!!.endIndex
LegacyVideoIdParentFingerprint.result?.let {
insertMethod = context
.toMethodWalker(it.method)
.nextMethod(it.scanResult.patternScanResult!!.startIndex + 3, true)
.getMethod() as MutableMethod
it.mutableMethod.apply {
insertMethod = this
videoIdRegister =
(implementation!!.instructions[insertIndex + 1] as OneRegisterInstruction).registerA
insertIndex = insertMethod.implementation!!.instructions.indexOfFirst { instruction ->
instruction.opcode == Opcode.INVOKE_INTERFACE
}
offset++ // offset so setCurrentVideoId is called before any injected call
} ?: return LegacyVideoIdFingerprint.toErrorResult()
insertRegister =
insertMethod.getInstruction<OneRegisterInstruction>(insertIndex + 1).registerA
} ?: return LegacyVideoIdParentFingerprint.toErrorResult()
injectCall("$INTEGRATIONS_CLASS_DESCRIPTOR->setVideoId(Ljava/lang/String;)V")
@ -45,7 +51,7 @@ class LegacyVideoIdPatch : BytecodePatch(
private var offset = 2
private var insertIndex: Int = 0
private var videoIdRegister: Int = 0
private var insertRegister: Int = 0
private lateinit var insertMethod: MutableMethod
@ -58,7 +64,7 @@ class LegacyVideoIdPatch : BytecodePatch(
) {
insertMethod.addInstructions(
insertIndex + offset, // move-result-object offset
"invoke-static {v$videoIdRegister}, $methodDescriptor"
"invoke-static {v$insertRegister}, $methodDescriptor"
)
}
}

View File

@ -14,6 +14,5 @@ object MainstreamVideoIdFingerprint : MethodFingerprint(
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_INTERFACE,
Opcode.MOVE_RESULT_OBJECT
),
customFingerprint = { it, _ -> it.definingClass.endsWith("SubtitlesOverlayPresenter;") }
)
)

View File

@ -0,0 +1,9 @@
package app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object MainstreamVideoIdParentFingerprint : MethodFingerprint(
returnType = "V",
parameters = listOf("L", "L"),
strings = listOf("error retrieving subtitle"),
)

View File

@ -8,5 +8,9 @@ object TimebarFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"),
customFingerprint = { it, _ -> it.definingClass.endsWith("/TimeBar;") && it.name.contains("draw") }
customFingerprint = { methodDef, _ ->
methodDef.definingClass.endsWith("/TimeBar;") && methodDef.name.contains(
"draw"
)
}
)

View File

@ -15,5 +15,5 @@ object VideoLengthFingerprint : MethodFingerprint(
Opcode.CONST_4,
Opcode.INVOKE_VIRTUAL
),
customFingerprint = { it, _ -> it.isWide32LiteralExists(45388753) }
customFingerprint = { methodDef, _ -> methodDef.isWide32LiteralExists(45388753) }
)

View File

@ -20,6 +20,7 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMu
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.playertype.patch.PlayerTypeHookPatch
import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.MainstreamVideoIdFingerprint
import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.MainstreamVideoIdParentFingerprint
import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.PlayerControllerSetTimeReferenceFingerprint
import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.PlayerInitFingerprint
import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.SeekFingerprint
@ -42,7 +43,7 @@ import org.jf.dexlib2.util.MethodUtil
@DependsOn([PlayerTypeHookPatch::class])
class MainstreamVideoIdPatch : BytecodePatch(
listOf(
MainstreamVideoIdFingerprint,
MainstreamVideoIdParentFingerprint,
PlayerControllerSetTimeReferenceFingerprint,
PlayerInitFingerprint,
SeekFingerprint,
@ -133,14 +134,21 @@ class MainstreamVideoIdPatch : BytecodePatch(
}
} ?: return VideoLengthFingerprint.toErrorResult()
MainstreamVideoIdFingerprint.result?.let {
it.mutableMethod.apply {
insertMethod = this
insertIndex = it.scanResult.patternScanResult!!.endIndex
videoIdRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
}
offset++ // offset so setVideoId is called before any injected call
} ?: return MainstreamVideoIdFingerprint.toErrorResult()
MainstreamVideoIdParentFingerprint.result?.let { parentResult ->
MainstreamVideoIdFingerprint.also {
it.resolve(
context,
parentResult.classDef
)
}.result?.let {
it.mutableMethod.apply {
insertMethod = this
insertIndex = it.scanResult.patternScanResult!!.endIndex
videoIdRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
}
offset++ // offset so setVideoId is called before any injected call
} ?: return MainstreamVideoIdFingerprint.toErrorResult()
} ?: return MainstreamVideoIdParentFingerprint.toErrorResult()
return PatchResultSuccess()
}