feat(youtube): improve patching speed

This commit is contained in:
inotia00 2023-07-05 20:44:50 +09:00
parent 921cb552e5
commit 910de6f27c
87 changed files with 263 additions and 165 deletions

View File

@ -27,7 +27,6 @@ Example:
{
"name": "com.google.android.youtube",
"versions": [
"18.19.36",
"18.20.39",
"18.21.35",
"18.22.37",

View File

@ -17,6 +17,12 @@ repositories {
password = githubPassword
}
}
maven {
url = uri("https://repo.sleeping.town")
content {
includeGroup("com.unascribed")
}
}
}
dependencies {
@ -24,6 +30,8 @@ dependencies {
implementation("app.revanced:multidexlib2:2.5.3-a3836654")
// Required for meta
implementation("com.google.code.gson:gson:2.10.1")
// Required for FlexVer-Java
implementation("com.unascribed:flexver-java:1.1.0")
}
tasks {

View File

@ -10,7 +10,7 @@ import org.jf.dexlib2.Opcode
object TabLayoutFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
parameters = emptyList(),
opcodes = listOf(
Opcode.CONST,
Opcode.INVOKE_STATIC,

View File

@ -5,6 +5,6 @@ import app.revanced.util.bytecode.isWide32LiteralExists
object NewLayoutFingerprint : MethodFingerprint(
returnType = "Z",
parameters = listOf(),
parameters = emptyList(),
customFingerprint = { methodDef, _ -> methodDef.isWide32LiteralExists(45399578) }
)

View File

@ -8,7 +8,7 @@ import org.jf.dexlib2.Opcode
object NextButtonVisibilityFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
parameters = emptyList(),
opcodes = listOf(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,

View File

@ -5,6 +5,6 @@ import app.revanced.util.bytecode.isWide32LiteralExists
object SwipeToCloseFingerprint : MethodFingerprint(
returnType = "Z",
parameters = listOf(),
parameters = emptyList(),
customFingerprint = { methodDef, _ -> methodDef.isWide32LiteralExists(45398432) }
)

View File

@ -5,6 +5,6 @@ import app.revanced.util.bytecode.isWide32LiteralExists
object SleepTimerFingerprint : MethodFingerprint(
returnType = "Z",
parameters = listOf(),
parameters = emptyList(),
customFingerprint = { methodDef, _ -> methodDef.isWide32LiteralExists(45372767) }
)

View File

@ -8,7 +8,7 @@ import org.jf.dexlib2.Opcode
object BackgroundPlaybackParentFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
parameters = emptyList(),
opcodes = listOf(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT,

View File

@ -8,7 +8,7 @@ import org.jf.dexlib2.Opcode
object AudioOnlyEnablerFingerprint : MethodFingerprint(
returnType = "Z",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
parameters = emptyList(),
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.INVOKE_INTERFACE,

View File

@ -8,7 +8,7 @@ import org.jf.dexlib2.Opcode
object HideGetPremiumFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
parameters = emptyList(),
opcodes = listOf(
Opcode.IGET_BOOLEAN,
Opcode.CONST_4,

View File

@ -3,5 +3,5 @@ package app.revanced.patches.music.misc.sharebuttonhook.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object FullStackTraceActivityFingerprint : MethodFingerprint(
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("FullStackTraceActivity;") && methodDef.name == "onCreate" }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/FullStackTraceActivity;") && methodDef.name == "onCreate" }
)

View File

@ -14,5 +14,5 @@ object MusicPlaybackControlsFingerprint : MethodFingerprint(
Opcode.INVOKE_VIRTUAL,
Opcode.RETURN_VOID
),
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("MusicPlaybackControls;") }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/MusicPlaybackControls;") }
)

View File

@ -8,7 +8,7 @@ import org.jf.dexlib2.Opcode
object ShuffleClassReferenceFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
parameters = emptyList(),
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.INVOKE_INTERFACE,

View File

@ -7,7 +7,7 @@ import org.jf.dexlib2.Opcode
object VideoIdParentFingerprint : MethodFingerprint(
returnType = "V",
parameters = listOf(),
parameters = emptyList(),
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
opcodes = listOf(
Opcode.INVOKE_SUPER,
@ -16,5 +16,5 @@ object VideoIdParentFingerprint : MethodFingerprint(
Opcode.IPUT_OBJECT,
Opcode.IGET_OBJECT
),
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("WatchFragment;") && methodDef.name == "onDestroyView" }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/WatchFragment;") && methodDef.name == "onDestroyView" }
)

View File

@ -34,13 +34,15 @@ class NavigationButtonsPatch : BytecodePatch(
BottomNavScreenFingerprint.result?.let {
it.mutableMethod.apply {
val startIndex = it.scanResult.patternScanResult!!.startIndex
val reference = getInstruction<ReferenceInstruction>(startIndex).reference.toString()
val reference =
getInstruction<ReferenceInstruction>(startIndex).reference.toString()
if (!reference.endsWith("Ljava/util/List;"))
return PatchResultError("Invalid reference: $reference")
val insertIndex = startIndex + 2
val insertRegister = getInstruction<OneRegisterInstruction>(startIndex + 1).registerA
val insertRegister =
getInstruction<OneRegisterInstruction>(startIndex + 1).registerA
addInstructions(
insertIndex, """

View File

@ -5,6 +5,6 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object PremiumIconFingerprint : MethodFingerprint(
returnType = "Z",
customFingerprint = { methodDef, classDef ->
methodDef.definingClass.endsWith("MyAccount;") && methodDef.name == "isPremiumSubscriber" && classDef.sourceFile == "MyAccount.kt"
methodDef.definingClass.endsWith("/MyAccount;") && methodDef.name == "isPremiumSubscriber" && classDef.sourceFile == "MyAccount.kt"
}
)

View File

@ -5,5 +5,9 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object ShareLinkFormatterFingerprint : MethodFingerprint(
returnType = "Ljava/lang/String;",
parameters = listOf("Ljava/lang/String;", "Ljava/util/Map;"),
strings = listOf("uri.getQueryParameters(name)", "uri.queryParameterNames", "newUriBuilder.build().toString()"),
strings = listOf(
"uri.getQueryParameters(name)",
"uri.queryParameterNames",
"newUriBuilder.build().toString()"
),
)

View File

@ -9,7 +9,7 @@ import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction
object LegacyAdsFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
parameters = emptyList(),
opcodes = listOf(
Opcode.CONST_WIDE_16,
Opcode.IPUT_WIDE,

View File

@ -7,5 +7,8 @@ import org.jf.dexlib2.AccessFlags
object SubtitleTrackFingerprint : MethodFingerprint(
returnType = "Z",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
strings = listOf("DISABLE_CAPTIONS_OPTION")
strings = listOf("DISABLE_CAPTIONS_OPTION"),
customFingerprint = { methodDef, _ ->
methodDef.definingClass.endsWith("/SubtitleTrack;")
}
)

View File

@ -8,6 +8,6 @@ import org.jf.dexlib2.Opcode
object ClientInfoFingerprint : MethodFingerprint(
returnType = "L",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
parameters = emptyList(),
opcodes = listOf(Opcode.OR_INT_LIT16)
)

View File

@ -15,5 +15,5 @@ object CompactYpcOfferModuleViewFingerprint : MethodFingerprint(
Opcode.INVOKE_VIRTUAL,
Opcode.RETURN_VOID
),
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("CompactYpcOfferModuleView;") && methodDef.name == "onMeasure" }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/CompactYpcOfferModuleView;") && methodDef.name == "onMeasure" }
)

View File

@ -7,6 +7,6 @@ import org.jf.dexlib2.AccessFlags
object FlyoutPanelPatchFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PRIVATE or AccessFlags.STATIC,
parameters = listOf(),
parameters = emptyList(),
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/FlyoutPanelPatch;") && methodDef.name == "openOldPlaybackRateBottomSheetFragment" }
)

View File

@ -7,6 +7,6 @@ import org.jf.dexlib2.AccessFlags
object PlaybackRateBottomSheetBuilderFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
parameters = emptyList(),
strings = listOf("PLAYBACK_RATE_MENU_BOTTOM_SHEET_FRAGMENT")
)

View File

@ -112,6 +112,7 @@ class OldSpeedLayoutPatch : BytecodePatch(
return PatchResultSuccess()
}
private companion object {
lateinit var PLAYBACK_RATE_BOTTOM_SHEET_CLASS: String
lateinit var PLAYBACK_RATE_BOTTOM_SHEET_BUILDER_METHOD: String

View File

@ -8,8 +8,7 @@ object FullscreenEngagementPanelFingerprint : MethodFingerprint(
returnType = "L",
parameters = listOf("L"),
customFingerprint = { methodDef, _ ->
methodDef.isWideLiteralExists(
FullScreenEngagementPanel
)
methodDef.definingClass.endsWith("/FullscreenEngagementPanelOverlay;") &&
methodDef.isWideLiteralExists(FullScreenEngagementPanel)
}
)

View File

@ -12,5 +12,5 @@ object FullscreenViewAdderFingerprint : MethodFingerprint(
Opcode.CONST_4,
Opcode.INVOKE_VIRTUAL
),
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("FullscreenEngagementPanelOverlay;") }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/FullscreenEngagementPanelOverlay;") }
)

View File

@ -1,11 +1,15 @@
package app.revanced.patches.youtube.general.categorybar.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.FilterBarHeight
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object FilterBarHeightFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
opcodes = listOf(
Opcode.CONST,
Opcode.INVOKE_VIRTUAL,

View File

@ -1,11 +1,15 @@
package app.revanced.patches.youtube.general.categorybar.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.RelatedChipCloudMargin
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object RelatedChipCloudFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
opcodes = listOf(
Opcode.CONST,
Opcode.INVOKE_VIRTUAL,

View File

@ -1,11 +1,15 @@
package app.revanced.patches.youtube.general.categorybar.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.BarContainerHeight
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object SearchResultsChipBarFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
opcodes = listOf(
Opcode.CONST,
Opcode.INVOKE_VIRTUAL,

View File

@ -1,11 +1,14 @@
package app.revanced.patches.youtube.general.crowdfundingbox.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.DonationCompanion
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object CrowdfundingBoxFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
opcodes = listOf(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,

View File

@ -1,11 +1,16 @@
package app.revanced.patches.youtube.general.floatingmicrophone.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.Fab
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object FloatingMicrophoneFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = emptyList(),
opcodes = listOf(
Opcode.IGET_BOOLEAN,
Opcode.IF_EQZ,

View File

@ -6,6 +6,8 @@ import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
object AccountSwitcherAccessibilityLabelFingerprint : MethodFingerprint(
returnType = "V",
parameters = listOf("L", "Ljava/lang/Object;"),
opcodes = listOf(
Opcode.INVOKE_VIRTUAL,
Opcode.IGET_OBJECT,

View File

@ -8,5 +8,5 @@ object HideSnackBarFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L", "L"),
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("BottomUiContainer;") }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/BottomUiContainer;") }
)

View File

@ -1,11 +1,14 @@
package app.revanced.patches.youtube.general.suggestions.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.HorizontalCardList
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object BreakingNewsFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
opcodes = listOf(
Opcode.CONST,
Opcode.CONST_4,

View File

@ -8,6 +8,6 @@ import org.jf.dexlib2.Opcode
object Vp9PropsFingerprint : MethodFingerprint(
returnType = "L",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
parameters = emptyList(),
opcodes = listOf(Opcode.OR_INT_LIT16)
)

View File

@ -5,7 +5,7 @@ import org.jf.dexlib2.Opcode
object GeneralPrefsFingerprint : MethodFingerprint(
returnType = "V",
parameters = listOf(),
parameters = emptyList(),
opcodes = listOf(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
@ -14,5 +14,5 @@ object GeneralPrefsFingerprint : MethodFingerprint(
Opcode.MOVE_RESULT_OBJECT
),
strings = listOf("bedtime_reminder_toggle"),
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("GeneralPrefsFragment;") }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/GeneralPrefsFragment;") }
)

View File

@ -5,7 +5,7 @@ import org.jf.dexlib2.Opcode
object ClientFormFactorFingerprint : MethodFingerprint(
returnType = "L",
parameters = listOf(),
parameters = emptyList(),
opcodes = listOf(
Opcode.IF_EQZ,
Opcode.SGET_OBJECT,

View File

@ -5,7 +5,7 @@ import org.jf.dexlib2.Opcode
object ClientFormFactorWalkerFingerprint : MethodFingerprint(
returnType = "L",
parameters = listOf(),
parameters = emptyList(),
opcodes = listOf(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,

View File

@ -4,7 +4,6 @@ import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction
object KidsMinimizedPlaybackPolicyControllerFingerprint : MethodFingerprint(
returnType = "V",
@ -40,7 +39,6 @@ object KidsMinimizedPlaybackPolicyControllerFingerprint : MethodFingerprint(
Opcode.RETURN_VOID
),
customFingerprint = { methodDef, _ ->
methodDef.implementation!!.instructions.any {
((it as? NarrowLiteralInstruction)?.narrowLiteral == 5)
}
})
methodDef.definingClass.endsWith("/MinimizedPlaybackPolicyController;")
}
)

View File

@ -7,5 +7,5 @@ object CronetEngineBuilderFingerprint : MethodFingerprint(
returnType = "L",
accessFlags = AccessFlags.PUBLIC.value,
parameters = listOf("Z"),
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("CronetEngine\$Builder;") && methodDef.name == "enableQuic" }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/CronetEngine\$Builder;") && methodDef.name == "enableQuic" }
)

View File

@ -7,5 +7,5 @@ object ExperimentalCronetEngineBuilderFingerprint : MethodFingerprint(
returnType = "L",
accessFlags = AccessFlags.PUBLIC.value,
parameters = listOf("Z"),
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("ExperimentalCronetEngine\$Builder;") && methodDef.name == "enableQuic" }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/ExperimentalCronetEngine\$Builder;") && methodDef.name == "enableQuic" }
)

View File

@ -9,5 +9,5 @@ object PivotBarChangedFingerprint : MethodFingerprint(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT
),
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("PivotBar;") && methodDef.name == "onConfigurationChanged" }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/PivotBar;") && methodDef.name == "onConfigurationChanged" }
)

View File

@ -11,5 +11,5 @@ object PivotBarStyleFingerprint : MethodFingerprint(
Opcode.MOVE_RESULT,
Opcode.XOR_INT_2ADDR
),
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("PivotBar;") }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/PivotBar;") }
)

View File

@ -7,6 +7,6 @@ import org.jf.dexlib2.AccessFlags
object VideoEndFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
parameters = emptyList(),
customFingerprint = { methodDef, _ -> methodDef.implementation!!.instructions.count() == 3 && methodDef.annotations.isEmpty() }
)

View File

@ -3,5 +3,5 @@ package app.revanced.patches.youtube.player.castbutton.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object CastButtonFingerprint : MethodFingerprint(
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("MediaRouteButton;") && methodDef.name == "setVisibility" }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/MediaRouteButton;") && methodDef.name == "setVisibility" }
)

View File

@ -6,6 +6,7 @@ import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
object LayoutCircleFingerprint : MethodFingerprint(
returnType = "Landroid/view/View;",
opcodes = listOf(
Opcode.CONST,
Opcode.CONST_4,

View File

@ -6,6 +6,7 @@ import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
object LayoutIconFingerprint : MethodFingerprint(
returnType = "Landroid/view/View;",
opcodes = listOf(
Opcode.CONST_4,
Opcode.CONST,

View File

@ -6,6 +6,7 @@ import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
object LayoutVideoFingerprint : MethodFingerprint(
returnType = "Landroid/view/View;",
opcodes = listOf(
Opcode.CONST,
Opcode.CONST_4,

View File

@ -5,6 +5,6 @@ import app.revanced.util.bytecode.isWide32LiteralExists
object FilmStripOverlayConfigFingerprint : MethodFingerprint(
returnType = "Z",
parameters = listOf(),
parameters = emptyList(),
customFingerprint = { methodDef, _ -> methodDef.isWide32LiteralExists(45381958) }
)

View File

@ -1,32 +0,0 @@
package app.revanced.patches.youtube.player.filmstripoverlay.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 YouTubeControlsOverlayWithFixFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
parameters = emptyList(),
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.CONST_16,
Opcode.IF_NEZ,
Opcode.IF_NEZ,
Opcode.GOTO,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
Opcode.IF_EQ
),
customFingerprint = { methodDef, _ ->
methodDef.isWideLiteralExists(
YoutubeControlsOverlay
)
}
)

View File

@ -10,6 +10,7 @@ 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.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
@ -19,12 +20,13 @@ import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.FilmStr
import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.FilmStripOverlayInteractionFingerprint
import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.FilmStripOverlayParentFingerprint
import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.FilmStripOverlayPreviewFingerprint
import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.YouTubeControlsOverlayWithFixFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.fingerprints.YouTubeControlsOverlayFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.PLAYER
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
@ -45,7 +47,7 @@ import org.jf.dexlib2.iface.reference.MethodReference
class HideFilmstripOverlayPatch : BytecodePatch(
listOf(
FilmStripOverlayParentFingerprint,
YouTubeControlsOverlayWithFixFingerprint
YouTubeControlsOverlayFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
@ -66,16 +68,33 @@ class HideFilmstripOverlayPatch : BytecodePatch(
}
} ?: return FilmStripOverlayParentFingerprint.toErrorResult()
YouTubeControlsOverlayWithFixFingerprint.result?.let {
YouTubeControlsOverlayFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = getIndex("bringChildToFront") + 1
val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
val jumpIndex = getIndex("setOnClickListener") + 3
val setOnClickListenerIndex = getIndex("setOnClickListener")
val jumpIndex = setOnClickListenerIndex + 3
val fixIndex = it.scanResult.patternScanResult!!.startIndex + 4
val fixRegister = getInstruction<OneRegisterInstruction>(fixIndex).registerA
val fixValue = getInstruction<WideLiteralInstruction>(fixIndex).wideLiteral.toInt()
val initialIndex = setOnClickListenerIndex - 1
val fixRegister = getInstruction<FiveRegisterInstruction>(initialIndex).registerE
var fixValue = 12
var isFound = false
for (index in initialIndex downTo insertIndex) {
if (getInstruction(index).opcode != Opcode.CONST_16) continue
val register = getInstruction<OneRegisterInstruction>(index).registerA
if (register != fixRegister) continue
fixValue = getInstruction<WideLiteralInstruction>(index).wideLiteral.toInt()
isFound = true
break
}
if (!isFound)
return PatchResultError("Couldn't find value to prevent player crash")
addInstructionsWithLabels(
insertIndex, """
@ -86,7 +105,7 @@ class HideFilmstripOverlayPatch : BytecodePatch(
""", ExternalLabel("hidden", getInstruction(jumpIndex))
)
}
} ?: return YouTubeControlsOverlayWithFixFingerprint.toErrorResult()
} ?: return YouTubeControlsOverlayFingerprint.toErrorResult()
/**
* Add settings

View File

@ -6,8 +6,9 @@ import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object InfoCardsIncognitoFingerprint : MethodFingerprint(
returnType = "L",
returnType = "Ljava/lang/Boolean;",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L", "J"),
opcodes = listOf(Opcode.IGET_BOOLEAN),
strings = listOf("vibrator")
)

View File

@ -1,11 +0,0 @@
package app.revanced.patches.youtube.player.infocards.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
object InfoCardsIncognitoParentFingerprint : MethodFingerprint(
returnType = "L",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
strings = listOf("player_overlay_info_card_teaser"),
)

View File

@ -7,14 +7,12 @@ import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
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.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.player.infocards.fingerprints.InfoCardsIncognitoFingerprint
import app.revanced.patches.youtube.player.infocards.fingerprints.InfoCardsIncognitoParentFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.PLAYER
@ -27,25 +25,23 @@ import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
@YouTubeCompatibility
@Version("0.0.1")
class HideInfoCardsPatch : BytecodePatch(
listOf(InfoCardsIncognitoParentFingerprint)
listOf(InfoCardsIncognitoFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
InfoCardsIncognitoParentFingerprint.result?.classDef?.let { classDef ->
InfoCardsIncognitoFingerprint.also { it.resolve(context, classDef) }.result?.let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex
val targetRegister =
getInstruction<TwoRegisterInstruction>(targetIndex).registerA
InfoCardsIncognitoFingerprint.result?.let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex
val targetRegister =
getInstruction<TwoRegisterInstruction>(targetIndex).registerA
addInstructions(
targetIndex + 1, """
invoke-static {v$targetRegister}, $PLAYER->hideInfoCard(Z)Z
move-result v$targetRegister
"""
)
}
} ?: return InfoCardsIncognitoFingerprint.toErrorResult()
} ?: return InfoCardsIncognitoParentFingerprint.toErrorResult()
addInstructions(
targetIndex + 1, """
invoke-static {v$targetRegister}, $PLAYER->hideInfoCard(Z)Z
move-result v$targetRegister
"""
)
}
} ?: return InfoCardsIncognitoFingerprint.toErrorResult()
/**
* Add settings

View File

@ -11,7 +11,6 @@ object MusicAppDeeplinkButtonFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("Z", "Z"),
customFingerprint = { methodDef, _ ->
methodDef.isWideLiteralExists(
MusicAppDeeplinkButtonView
)
methodDef.definingClass.endsWith("MusicAppDeeplinkButtonController;") &&
methodDef.isWideLiteralExists(MusicAppDeeplinkButtonView)
})

View File

@ -5,6 +5,6 @@ import app.revanced.util.bytecode.isWide32LiteralExists
object SpeedOverlayConfigFingerprint : MethodFingerprint(
returnType = "Z",
parameters = listOf(),
parameters = emptyList(),
customFingerprint = { methodDef, _ -> methodDef.isWide32LiteralExists(45411330) }
)

View File

@ -5,6 +5,6 @@ import app.revanced.util.bytecode.isWide32LiteralExists
object ThumbnailPreviewConfigFingerprint : MethodFingerprint(
returnType = "Z",
parameters = listOf(),
parameters = emptyList(),
customFingerprint = { methodDef, _ -> methodDef.isWide32LiteralExists(45398577) }
)

View File

@ -6,20 +6,39 @@ import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object TimeCounterFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = emptyList(),
parameters = listOf(),
returnType = "V",
opcodes = listOf(
Opcode.RETURN_VOID,
Opcode.IGET_BOOLEAN,
Opcode.IF_EQZ,
Opcode.IGET_OBJECT,
Opcode.IGET_WIDE,
Opcode.CONST_WIDE_16,
Opcode.CMP_LONG,
Opcode.IF_LEZ,
Opcode.IGET_WIDE,
Opcode.SUB_LONG_2ADDR,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IF_EQZ,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
Opcode.IF_EQZ,
Opcode.GOTO
)
Opcode.IGET_WIDE,
Opcode.IGET_WIDE,
Opcode.SUB_LONG_2ADDR,
Opcode.IGET_WIDE,
Opcode.SUB_LONG_2ADDR,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IGET_WIDE,
Opcode.IGET_WIDE,
Opcode.SUB_LONG_2ADDR,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_INTERFACE,
Opcode.RETURN_VOID
),
customFingerprint = { _, classDef ->
// On older devices this fingerprint resolves very slowly.
// Speed this up by checking for the number of methods.
classDef.methods.count() == 14
}
)

View File

@ -1,11 +1,14 @@
package app.revanced.patches.youtube.shorts.shortscomponent.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.RightComment
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
object ShortsCommentFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
parameters = listOf("Z", "Z", "L"),
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(RightComment) }
)

View File

@ -1,11 +1,14 @@
package app.revanced.patches.youtube.shorts.shortscomponent.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.ReelRightDislikeIcon
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
object ShortsDislikeFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
parameters = listOf("Z", "Z", "L"),
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(ReelRightDislikeIcon) }
)

View File

@ -1,10 +1,13 @@
package app.revanced.patches.youtube.shorts.shortscomponent.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.ReelPlayerInfoPanel
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
object ShortsInfoPanelFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(ReelPlayerInfoPanel) }
)

View File

@ -1,11 +1,14 @@
package app.revanced.patches.youtube.shorts.shortscomponent.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.ReelRightLikeIcon
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
object ShortsLikeFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
parameters = listOf("Z", "Z", "L"),
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(ReelRightLikeIcon) }
)

View File

@ -1,9 +1,13 @@
package app.revanced.patches.youtube.shorts.shortscomponent.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.ReelPlayerBadge
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
object ShortsPaidPromotionFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(ReelPlayerBadge) }
)

View File

@ -1,11 +1,14 @@
package app.revanced.patches.youtube.shorts.shortscomponent.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.ReelDynRemix
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
object ShortsRemixFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
parameters = listOf("Z", "Z", "L"),
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(ReelDynRemix) }
)

View File

@ -1,11 +1,14 @@
package app.revanced.patches.youtube.shorts.shortscomponent.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.ReelDynShare
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
object ShortsShareFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
parameters = listOf("Z", "Z", "L"),
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(ReelDynShare) }
)

View File

@ -1,9 +1,14 @@
package app.revanced.patches.youtube.shorts.shortscomponent.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.ReelPlayerPausedStateButton
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
object ShortsSubscriptionsFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = emptyList(),
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(ReelPlayerPausedStateButton) }
)

View File

@ -1,10 +1,13 @@
package app.revanced.patches.youtube.shorts.shortscomponent.fingerprints
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 ShortsSubscriptionsTabletFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
parameters = listOf("L", "L", "Z"),
opcodes = listOf(
Opcode.INVOKE_STATIC,

View File

@ -1,9 +1,13 @@
package app.revanced.patches.youtube.shorts.shortscomponent.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.ReelPlayerFooter
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
object ShortsSubscriptionsTabletParentFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(ReelPlayerFooter) }
)

View File

@ -8,7 +8,7 @@ import org.jf.dexlib2.Opcode
object UserWasInShortsFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"),
parameters = listOf("Ljava/lang/Object;"),
opcodes = listOf(
Opcode.CHECK_CAST,
Opcode.INVOKE_INTERFACE,

View File

@ -7,5 +7,5 @@ import org.jf.dexlib2.AccessFlags
object WatchWhileActivityFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
parameters = emptyList(),
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("WatchWhileActivity;") }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/WatchWhileActivity;") }
)

View File

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

View File

@ -3,5 +3,5 @@ package app.revanced.patches.youtube.utils.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object PlayerPatchFingerprint : MethodFingerprint(
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("PlayerPatch;") && methodDef.name == "hidePlayerButton" }
customFingerprint = { methodDef, _ -> methodDef.definingClass == "Lapp/revanced/integrations/patches/layout/PlayerPatch;" && methodDef.name == "hidePlayerButton" }
)

View File

@ -10,7 +10,7 @@ import org.jf.dexlib2.Opcode
object SubtitleButtonControllerFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"),
parameters = listOf("Lcom/google/android/libraries/youtube/player/subtitles/model/SubtitleTrack;"),
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.IF_NEZ,

View File

@ -17,8 +17,7 @@ object YouTubeControlsOverlayFingerprint : MethodFingerprint(
Opcode.IF_EQZ
),
customFingerprint = { methodDef, _ ->
methodDef.isWideLiteralExists(
YoutubeControlsOverlay
)
methodDef.definingClass.endsWith("/YouTubeControlsOverlay;") &&
methodDef.isWideLiteralExists(YoutubeControlsOverlay)
}
)

View File

@ -8,7 +8,7 @@ import org.jf.dexlib2.Opcode
object ScrollTopFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
parameters = emptyList(),
opcodes = listOf(
Opcode.CHECK_CAST,
Opcode.CONST_4,

View File

@ -1,8 +1,12 @@
package app.revanced.patches.youtube.utils.fix.parameter.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
object SubtitleWindowFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
parameters = listOf("I", "I", "I", "Z", "Z"),
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("SubtitleWindowSettings;") && methodDef.name == "<init>" }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/SubtitleWindowSettings;") }
)

View File

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

View File

@ -1,11 +1,16 @@
package app.revanced.patches.youtube.utils.playercontrols.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.BottomUiContainerStub
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object BottomControlsInflateFingerprint : MethodFingerprint(
returnType = "Ljava/lang/Object;",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL or AccessFlags.SYNTHETIC,
parameters = emptyList(),
opcodes = listOf(
Opcode.CHECK_CAST,
Opcode.INVOKE_VIRTUAL,

View File

@ -1,11 +1,16 @@
package app.revanced.patches.youtube.utils.playercontrols.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.ControlsLayoutStub
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object ControlsLayoutInflateFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = emptyList(),
opcodes = listOf(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,

View File

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

View File

@ -5,5 +5,5 @@ import org.jf.dexlib2.Opcode
object PlayerControlsVisibilityModelFingerprint : MethodFingerprint(
opcodes = listOf(Opcode.IGET_BOOLEAN),
strings = listOf("hasNext", "hasPrevious", "Missing required properties:")
strings = listOf("Missing required properties:", "hasNext", "hasPrevious")
)

View File

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

View File

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

View File

@ -1,7 +1,13 @@
package app.revanced.patches.youtube.utils.sponsorblock.bytecode.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
object PlayerControllerFingerprint : MethodFingerprint(
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("SegmentPlaybackController;") && methodDef.name == "setSponsorBarRect" }
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
parameters = listOf("Ljava/lang/Object;"),
customFingerprint = { methodDef, _ -> methodDef.definingClass == "Lapp/revanced/integrations/sponsorblock/SegmentPlaybackController;"
&& methodDef.name == "setSponsorBarRect" }
)

View File

@ -158,8 +158,8 @@ class SponsorBlockBytecodePatch : BytecodePatch(
/**
* Append the new time to the player layout
*/
TotalTimeFingerprint.result?.mutableMethod?.let {
it.apply {
TotalTimeFingerprint.result?.let {
it.mutableMethod.apply {
val targetIndex = getWideLiteralIndex(TotalTime) + 2
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -175,8 +175,8 @@ class SponsorBlockBytecodePatch : BytecodePatch(
/**
* Initialize the SponsorBlock view
*/
YouTubeControlsOverlayFingerprint.result?.mutableMethod?.let {
it.apply {
YouTubeControlsOverlayFingerprint.result?.let {
it.mutableMethod.apply {
val targetIndex = getWideLiteralIndex(InsetOverlayViewLayout) + 3
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -200,17 +200,19 @@ class SponsorBlockBytecodePatch : BytecodePatch(
((rectangleFieldInvalidatorInstructions.elementAt(rectangleFieldInvalidatorInstructions.count() - 3) as ReferenceInstruction).reference as FieldReference).name
PlayerControllerFingerprint.result?.mutableMethod?.let {
val instructions = it.implementation!!.instructions
PlayerControllerFingerprint.result?.let {
it.mutableMethod.apply {
for ((index, instruction) in implementation!!.instructions.withIndex()) {
if (instruction.opcode != Opcode.CONST_STRING) continue
for ((index, instruction) in instructions.withIndex()) {
if (instruction.opcode != Opcode.CONST_STRING) continue
val register = it.getInstruction<OneRegisterInstruction>(index).registerA
it.replaceInstruction(
index,
"const-string v$register, \"$rectangleFieldName\""
)
break
val register = getInstruction<OneRegisterInstruction>(index).registerA
replaceInstruction(
index,
"const-string v$register, \"$rectangleFieldName\""
)
break
}
}
} ?: return PlayerControllerFingerprint.toErrorResult()

View File

@ -4,6 +4,9 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object VideoIdParentFingerprint : MethodFingerprint(
returnType = "V",
parameters = listOf("L", "L"),
parameters = listOf("Ljava/lang/Object;", "Ljava/lang/Exception;"),
strings = listOf("error retrieving subtitle"),
customFingerprint = { methodDef, _ ->
methodDef.definingClass.endsWith("/SubtitlesOverlayPresenter;")
}
)

View File

@ -13,7 +13,7 @@ internal object BytecodeHelper {
) {
this.classes.forEach { classDef ->
classDef.methods.forEach { method ->
if (classDef.type.endsWith("WatchWhileActivity;") && method.name == "onCreate") {
if (classDef.type.endsWith("/WatchWhileActivity;") && method.name == "onCreate") {
val hookMethod =
this.proxy(classDef).mutableClass.methods.first { it.name == "onCreate" }
@ -29,7 +29,7 @@ internal object BytecodeHelper {
internal fun BytecodeContext.updatePatchStatus(patch: String) {
this.classes.forEach { classDef ->
classDef.methods.forEach { method ->
if (classDef.type.endsWith("PatchStatus;") && method.name == patch) {
if (classDef.type.endsWith("/PatchStatus;") && method.name == patch) {
val patchStatusMethod =
this.proxy(classDef).mutableClass.methods.first { it.name == patch }