refactor: reformat code and optimize imports

This commit is contained in:
inotia00
2023-06-20 18:27:17 +09:00
parent 0f820822cf
commit bf643c23c5
252 changed files with 1292 additions and 725 deletions

View File

@ -0,0 +1,18 @@
package app.revanced.patches.youtube.utils.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility(
[Package(
"com.google.android.youtube", arrayOf(
"18.19.36",
"18.20.39",
"18.21.35",
"18.22.37"
)
)]
)
@Target(AnnotationTarget.CLASS)
internal annotation class YouTubeCompatibility

View File

@ -0,0 +1,8 @@
package app.revanced.patches.youtube.utils.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object LayoutConstructorFingerprint : MethodFingerprint(
strings = listOf("1.0x"),
customFingerprint = { it, _ -> it.definingClass.endsWith("YouTubeControlsOverlay;") }
)

View File

@ -0,0 +1,35 @@
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
import org.jf.dexlib2.Opcode
object LayoutSwitchFingerprint : MethodFingerprint(
returnType = "I",
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
parameters = listOf("L"),
opcodes = listOf(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT,
Opcode.IF_NEZ,
Opcode.CONST_4,
Opcode.RETURN,
Opcode.CONST_16,
Opcode.IF_GE,
Opcode.CONST_4,
Opcode.RETURN,
Opcode.CONST_16,
Opcode.IF_GE,
Opcode.CONST_4,
Opcode.RETURN,
Opcode.CONST_16,
Opcode.IF_GE,
Opcode.CONST_4,
Opcode.RETURN,
Opcode.CONST_4,
Opcode.RETURN
)
)

View File

@ -0,0 +1,9 @@
package app.revanced.patches.youtube.utils.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object OnBackPressedFingerprint : MethodFingerprint(
opcodes = listOf(Opcode.RETURN_VOID),
customFingerprint = { it, _ -> it.definingClass.endsWith("WatchWhileActivity;") && it.name == "onBackPressed" }
)

View File

@ -0,0 +1,18 @@
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.ImageOnlyTab
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object PivotBarCreateButtonViewFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
opcodes = listOf(
Opcode.MOVE_OBJECT,
Opcode.INVOKE_DIRECT_RANGE, // unique instruction anchor
),
customFingerprint = { it, _ -> it.isWideLiteralExists(ImageOnlyTab) }
)

View File

@ -0,0 +1,8 @@
package app.revanced.patches.youtube.utils.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object SeekbarFingerprint : MethodFingerprint(
returnType = "V",
strings = listOf("timed_markers_width")
)

View File

@ -0,0 +1,7 @@
package app.revanced.patches.youtube.utils.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object SeekbarOnDrawFingerprint : MethodFingerprint(
customFingerprint = { methodDef, _ -> methodDef.name == "onDraw" }
)

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 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;"),
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.IF_NEZ,
Opcode.RETURN_VOID,
Opcode.IGET_BOOLEAN,
Opcode.CONST_4,
Opcode.IF_NEZ,
Opcode.CONST,
Opcode.INVOKE_VIRTUAL,
Opcode.IGET_OBJECT
),
customFingerprint = { it, _ -> it.definingClass.endsWith("SubtitleButtonController;") }
)

View File

@ -0,0 +1,10 @@
package app.revanced.patches.youtube.utils.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.TotalTime
import app.revanced.util.bytecode.isWideLiteralExists
object TotalTimeFingerprint : MethodFingerprint(
returnType = "V",
customFingerprint = { it, _ -> it.isWideLiteralExists(TotalTime) }
)

View File

@ -10,7 +10,7 @@ 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.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.fix.clientspoof.fingerprints.UserAgentHeaderBuilderFingerprint
import app.revanced.patches.youtube.utils.microg.shared.Constants.PACKAGE_NAME
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
@ -27,7 +27,8 @@ class ClientSpoofPatch : BytecodePatch(
UserAgentHeaderBuilderFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val packageNameRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
val packageNameRegister =
getInstruction<FiveRegisterInstruction>(insertIndex).registerD
addInstruction(
insertIndex,

View File

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

View File

@ -11,9 +11,11 @@ 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.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.fingerprints.OnBackPressedFingerprint
import app.revanced.patches.youtube.utils.fix.doublebacktoclose.fingerprint.*
import app.revanced.patches.youtube.utils.fingerprints.OnBackPressedFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
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
import app.revanced.util.integrations.Constants.UTILS_PATH
@Name("double-back-to-close")

View File

@ -14,11 +14,13 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.fix.protobufpoof.fingerprints.BadResponseFingerprint
import app.revanced.patches.youtube.utils.fix.protobufpoof.fingerprints.ProtobufParameterBuilderFingerprint
import app.revanced.patches.youtube.utils.fix.protobufpoof.fingerprints.SubtitleWindowFingerprint
import app.revanced.patches.youtube.utils.playertype.patch.PlayerTypeHookPatch
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.patches.youtube.utils.videoid.mainstream.patch.MainstreamVideoIdPatch
import app.revanced.patches.youtube.utils.fix.protobufpoof.fingerprints.*
import app.revanced.util.integrations.Constants.MISC_PATH
@Patch
@ -48,17 +50,17 @@ class ProtobufSpoofPatch : BytecodePatch(
.toMethodWalker(it.method)
.nextMethod(it.scanResult.patternScanResult!!.startIndex, true)
.getMethod() as MutableMethod
).apply {
val protobufParam = 3
).apply {
val protobufParam = 3
addInstructions(
0,
"""
addInstructions(
0,
"""
invoke-static {p$protobufParam}, $MISC_PATH/ProtobufSpoofPatch;->overrideProtobufParameter(Ljava/lang/String;)Ljava/lang/String;
move-result-object p$protobufParam
"""
)
}
)
}
} ?: return ProtobufParameterBuilderFingerprint.toErrorResult()
// hook video playback result

View File

@ -1,5 +1,6 @@
package app.revanced.patches.youtube.utils.fix.swiperefresh.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
@ -9,9 +10,8 @@ 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.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.fix.swiperefresh.fingerprint.SwipeRefreshLayoutFingerprint
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.extensions.toErrorResult
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Name("fix-swipe-refresh")

View File

@ -2,9 +2,15 @@ package app.revanced.patches.youtube.utils.integrations.patch
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.patch.annotations.RequiresIntegrations
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch
import app.revanced.patches.youtube.utils.integrations.fingerprints.*
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.integrations.fingerprints.APIPlayerServiceFingerprint
import app.revanced.patches.youtube.utils.integrations.fingerprints.ApplicationInitFingerprint
import app.revanced.patches.youtube.utils.integrations.fingerprints.EmbeddedPlayerControlsOverlayFingerprint
import app.revanced.patches.youtube.utils.integrations.fingerprints.EmbeddedPlayerFingerprint
import app.revanced.patches.youtube.utils.integrations.fingerprints.RemoteEmbedFragmentFingerprint
import app.revanced.patches.youtube.utils.integrations.fingerprints.RemoteEmbeddedPlayerFingerprint
import app.revanced.patches.youtube.utils.integrations.fingerprints.StandalonePlayerActivityFingerprint
import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH
@Name("integrations")

View File

@ -8,7 +8,7 @@ import org.jf.dexlib2.Opcode
object ByteBufferFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
parameters = listOf("L","L"),
parameters = listOf("L", "L"),
opcodes = listOf(
Opcode.SGET_OBJECT,
Opcode.INVOKE_VIRTUAL,

View File

@ -8,9 +8,9 @@ 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.shared.annotation.YouTubeCompatibility
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

View File

@ -9,7 +9,7 @@ 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.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.litho.fingerprints.LithoThemeFingerprint
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
@ -26,7 +26,7 @@ class LithoThemePatch : BytecodePatch(
override fun execute(context: BytecodeContext): PatchResult {
LithoThemeFingerprint.result?.mutableMethod?.let {
with (it.implementation!!.instructions) {
with(it.implementation!!.instructions) {
for (index in size - 1 downTo 0) {
val invokeInstruction = this[index] as? ReferenceInstruction ?: continue
if ((invokeInstruction.reference as MethodReference).name != "setColor") continue

View File

@ -8,5 +8,8 @@ object ServiceCheckFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
parameters = listOf("L", "I"),
strings = listOf("Google Play Services not available", "GooglePlayServices not available due to error ")
strings = listOf(
"Google Play Services not available",
"GooglePlayServices not available due to error "
)
)

View File

@ -7,12 +7,17 @@ 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.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.patch.packagename.PackageNamePatch
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.fix.clientspoof.patch.ClientSpoofPatch
import app.revanced.patches.youtube.utils.fix.protobufpoof.patch.ProtobufSpoofPatch
import app.revanced.patches.youtube.utils.microg.bytecode.fingerprints.CastContextFetchFingerprint
import app.revanced.patches.youtube.utils.microg.bytecode.fingerprints.CastDynamiteModuleFingerprint
import app.revanced.patches.youtube.utils.microg.bytecode.fingerprints.CastDynamiteModuleV2Fingerprint
import app.revanced.patches.youtube.utils.microg.bytecode.fingerprints.GooglePlayUtilityFingerprint
import app.revanced.patches.youtube.utils.microg.bytecode.fingerprints.PrimeFingerprint
import app.revanced.patches.youtube.utils.microg.bytecode.fingerprints.ServiceCheckFingerprint
import app.revanced.patches.youtube.utils.microg.shared.Constants.PACKAGE_NAME
import app.revanced.patches.youtube.utils.microg.bytecode.fingerprints.*
import app.revanced.util.bytecode.BytecodeHelper.injectInit
import app.revanced.util.microg.MicroGBytecodeHelper

View File

@ -9,8 +9,8 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.patch.packagename.PackageNamePatch
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.microg.bytecode.patch.MicroGBytecodePatch
import app.revanced.patches.youtube.utils.microg.shared.Constants.PACKAGE_NAME
import app.revanced.patches.youtube.utils.microg.shared.Constants.SPOOFED_PACKAGE_NAME

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.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.fingerprints.OnBackPressedFingerprint
import app.revanced.patches.youtube.utils.fingerprints.OnBackPressedFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
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
@ -54,9 +54,11 @@ class NavBarIndexPatch : BytecodePatch(
NavBarBuilderFingerprint.result?.let {
val endIndex = it.scanResult.patternScanResult!!.endIndex
val onClickListener = it.mutableMethod.getInstruction<ReferenceInstruction>(endIndex).reference.toString()
val onClickListener =
it.mutableMethod.getInstruction<ReferenceInstruction>(endIndex).reference.toString()
val targetMethod = context.findClass(onClickListener)?.mutableClass?.methods?.first { method -> method.name == "onClick" }
val targetMethod =
context.findClass(onClickListener)?.mutableClass?.methods?.first { method -> method.name == "onClick" }
targetMethod?.apply {
for ((index, instruction) in implementation!!.instructions.withIndex()) {

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 = { it, _ -> it.definingClass.endsWith("/VideoSpeedPatch;") && it.name == "overrideSpeed" }
)

View File

@ -19,15 +19,21 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMut
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
import app.revanced.patcher.util.smali.toInstructions
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.utils.overridespeed.fingerprints.*
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.overridespeed.fingerprints.SpeedClassFingerprint
import app.revanced.patches.youtube.utils.overridespeed.fingerprints.VideoSpeedChangedFingerprint
import app.revanced.patches.youtube.utils.overridespeed.fingerprints.VideoSpeedParentFingerprint
import app.revanced.patches.youtube.utils.overridespeed.fingerprints.VideoSpeedPatchFingerprint
import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH
import app.revanced.util.integrations.Constants.VIDEO_PATH
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.reference.FieldReference
import org.jf.dexlib2.immutable.*
import org.jf.dexlib2.immutable.ImmutableField
import org.jf.dexlib2.immutable.ImmutableMethod
import org.jf.dexlib2.immutable.ImmutableMethodImplementation
import org.jf.dexlib2.immutable.ImmutableMethodParameter
@Name("override-speed-hook")
@YouTubeCompatibility
@ -82,10 +88,11 @@ class OverrideSpeedHookPatch : BytecodePatch(
).toMutable()
)
with(context
.toMethodWalker(this)
.nextMethod(endIndex, true)
.getMethod() as MutableMethod
with(
context
.toMethodWalker(this)
.nextMethod(endIndex, true)
.getMethod() as MutableMethod
) {
addInstruction(
this.implementation!!.instructions.size - 1,

View File

@ -11,7 +11,7 @@ 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.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.playerbutton.fingerprints.LiveChatFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.util.integrations.Constants.PLAYER
@ -33,9 +33,11 @@ class PlayerButtonPatch : BytecodePatch(
val instructions = it.mutableMethod.getInstruction(endIndex)
val imageButtonClass =
context
.findClass((instructions as BuilderInstruction21c)
.reference.toString())!!
.mutableClass
.findClass(
(instructions as BuilderInstruction21c)
.reference.toString()
)!!
.mutableClass
for (method in imageButtonClass.methods) {
imageButtonClass.findMutableMethodOf(method).apply {
@ -46,7 +48,8 @@ class PlayerButtonPatch : BytecodePatch(
val definedInstruction = (instructions as? BuilderInstruction35c)
if (definedInstruction?.reference.toString() ==
"Landroid/view/View;->setVisibility(I)V") {
"Landroid/view/View;->setVisibility(I)V"
) {
jumpInstruction = !jumpInstruction
if (jumpInstruction) return@forEachIndexed

View File

@ -15,8 +15,7 @@ import app.revanced.patcher.patch.PatchResultError
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.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
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
@ -25,6 +24,7 @@ import app.revanced.patches.youtube.utils.playercontrols.fingerprints.SeekEDUVis
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.SpeedEduVisibleFingerprint
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.SpeedEduVisibleParentFingerprint
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.UserScrubbingFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.util.bytecode.getStringIndex
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@ -49,17 +49,24 @@ class PlayerControlsPatch : BytecodePatch(
) {
override fun execute(context: BytecodeContext): PatchResult {
val playerControlsVisibilityModelClassDef = PlayerControlsVisibilityModelFingerprint.result?.classDef?: return PlayerControlsVisibilityModelFingerprint.toErrorResult()
val playerControlsVisibilityModelClassDef =
PlayerControlsVisibilityModelFingerprint.result?.classDef
?: return PlayerControlsVisibilityModelFingerprint.toErrorResult()
SeekEDUVisibleFingerprint.resolve(context, playerControlsVisibilityModelClassDef)
seekEDUVisibleResult = SeekEDUVisibleFingerprint.result?: return SeekEDUVisibleFingerprint.toErrorResult()
seekEDUVisibleResult =
SeekEDUVisibleFingerprint.result ?: return SeekEDUVisibleFingerprint.toErrorResult()
UserScrubbingFingerprint.resolve(context, playerControlsVisibilityModelClassDef)
userScrubbingResult = UserScrubbingFingerprint.result?: return UserScrubbingFingerprint.toErrorResult()
userScrubbingResult =
UserScrubbingFingerprint.result ?: return UserScrubbingFingerprint.toErrorResult()
playerControlsVisibilityResult = PlayerControlsVisibilityFingerprint.result?: return PlayerControlsVisibilityFingerprint.toErrorResult()
controlsLayoutInflateResult = ControlsLayoutInflateFingerprint.result?: return ControlsLayoutInflateFingerprint.toErrorResult()
inflateResult = BottomControlsInflateFingerprint.result?: return BottomControlsInflateFingerprint.toErrorResult()
playerControlsVisibilityResult = PlayerControlsVisibilityFingerprint.result
?: return PlayerControlsVisibilityFingerprint.toErrorResult()
controlsLayoutInflateResult = ControlsLayoutInflateFingerprint.result
?: return ControlsLayoutInflateFingerprint.toErrorResult()
inflateResult = BottomControlsInflateFingerprint.result
?: return BottomControlsInflateFingerprint.toErrorResult()
SpeedEduVisibleParentFingerprint.result?.let { parentResult ->
var speedIndex = 0
@ -72,7 +79,8 @@ class PlayerControlsPatch : BytecodePatch(
if (instruction.opcode != Opcode.IGET_BOOLEAN) continue
if (getInstruction<TwoRegisterInstruction>(index).registerA == targetRegister) {
speedEDUVisibleReference = getInstruction<ReferenceInstruction>(index).reference
speedEDUVisibleReference =
getInstruction<ReferenceInstruction>(index).reference
speedIndex = index
break
}
@ -80,7 +88,12 @@ class PlayerControlsPatch : BytecodePatch(
if (speedIndex == 0) return PatchResultError("SpeedEduVisibleParent Instruction not found!")
}
SpeedEduVisibleFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.let {
SpeedEduVisibleFingerprint.also {
it.resolve(
context,
parentResult.classDef
)
}.result?.mutableMethod?.let {
it.implementation!!.instructions.apply {
for ((index, instruction) in withIndex()) {
if (instruction.opcode != Opcode.IPUT_BOOLEAN) continue
@ -88,7 +101,8 @@ class PlayerControlsPatch : BytecodePatch(
if (it.getInstruction<ReferenceInstruction>(index).reference == speedEDUVisibleReference) {
speedEDUVisibleMutableMethod = it
speedEDUVisibleIndex = index
speedEDUVisibleRegister = it.getInstruction<TwoRegisterInstruction>(index).registerA
speedEDUVisibleRegister =
it.getInstruction<TwoRegisterInstruction>(index).registerA
break
}
}
@ -146,7 +160,10 @@ class PlayerControlsPatch : BytecodePatch(
fun injectVisibility(descriptor: String) {
playerControlsVisibilityResult.injectVisibilityCall(descriptor, "changeVisibility")
seekEDUVisibleResult.injectVisibilityCall(descriptor, "changeVisibilityNegatedImmediate")
seekEDUVisibleResult.injectVisibilityCall(
descriptor,
"changeVisibilityNegatedImmediate"
)
userScrubbingResult.injectVisibilityCall(descriptor, "changeVisibilityNegatedImmediate")
injectSpeedEduVisibilityCall(descriptor)
}

View File

@ -9,7 +9,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.playeroverlay.fingerprint.PlayerOverlaysOnFinishInflateFingerprint
import app.revanced.util.integrations.Constants.UTILS_PATH

View File

@ -11,7 +11,7 @@ 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.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
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

View File

@ -10,7 +10,7 @@ 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.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.quickactionscontainer.fingerprints.QuickActionsElementFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.util.integrations.Constants.FULLSCREEN

View File

@ -8,10 +8,16 @@ import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.util.enum.ResourceType
import app.revanced.util.enum.ResourceType.*
import app.revanced.util.enum.ResourceType.ATTR
import app.revanced.util.enum.ResourceType.COLOR
import app.revanced.util.enum.ResourceType.DIMEN
import app.revanced.util.enum.ResourceType.DRAWABLE
import app.revanced.util.enum.ResourceType.ID
import app.revanced.util.enum.ResourceType.LAYOUT
import app.revanced.util.enum.ResourceType.STRING
@Name("shared-resource-id")
@DependsOn([ResourceMappingPatch::class])
@ -104,8 +110,10 @@ class SharedResourceIdPatch : ResourcePatch {
FullScreenEngagementPanel = find(ID, "fullscreen_engagement_panel_holder")
HorizontalCardList = find(LAYOUT, "horizontal_card_list")
ImageOnlyTab = find(LAYOUT, "image_only_tab")
InlineTimeBarColorizedBarPlayedColorDark = find(COLOR, "inline_time_bar_colorized_bar_played_color_dark")
InlineTimeBarPlayedNotHighlightedColor = find(COLOR, "inline_time_bar_played_not_highlighted_color")
InlineTimeBarColorizedBarPlayedColorDark =
find(COLOR, "inline_time_bar_colorized_bar_played_color_dark")
InlineTimeBarPlayedNotHighlightedColor =
find(COLOR, "inline_time_bar_played_not_highlighted_color")
InsetOverlayViewLayout = find(ID, "inset_overlay_view_layout")
LiveChatButton = find(ID, "live_chat_overlay_button")
QuickActionsElementContainer = find(ID, "quick_actions_element_container")

View File

@ -15,10 +15,7 @@ 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.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.utils.returnyoutubedislike.oldlayout.patch.ReturnYouTubeDislikeOldLayoutPatch
import app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.patch.ReturnYouTubeDislikeShortsPatch
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.DislikeFingerprint
import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.LikeFingerprint
import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.RemoveLikeFingerprint
@ -26,6 +23,9 @@ import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerpri
import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.TextComponentConstructorFingerprint
import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.TextComponentContextFingerprint
import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.TextComponentTmpFingerprint
import app.revanced.patches.youtube.utils.returnyoutubedislike.oldlayout.patch.ReturnYouTubeDislikeOldLayoutPatch
import app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.patch.ReturnYouTubeDislikeShortsPatch
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.patches.youtube.utils.videoid.mainstream.patch.MainstreamVideoIdPatch
import app.revanced.util.integrations.Constants.UTILS_PATH
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
@ -74,7 +74,12 @@ class ReturnYouTubeDislikePatch : BytecodePatch(
TextComponentConstructorFingerprint.result?.let { parentResult ->
TextComponentContextFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
TextComponentContextFingerprint.also {
it.resolve(
context,
parentResult.classDef
)
}.result?.let {
it.mutableMethod.apply {
val conversionContextIndex = it.scanResult.patternScanResult!!.startIndex
conversionContextFieldReference =
@ -82,7 +87,12 @@ class ReturnYouTubeDislikePatch : BytecodePatch(
}
} ?: return TextComponentContextFingerprint.toErrorResult()
TextComponentTmpFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
TextComponentTmpFingerprint.also {
it.resolve(
context,
parentResult.classDef
)
}.result?.let {
it.mutableMethod.apply {
val startIndex = it.scanResult.patternScanResult!!.startIndex
tmpRegister =
@ -91,11 +101,17 @@ class ReturnYouTubeDislikePatch : BytecodePatch(
} ?: return TextComponentTmpFingerprint.toErrorResult()
TextComponentAtomicReferenceFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
TextComponentAtomicReferenceFingerprint.also {
it.resolve(
context,
parentResult.classDef
)
}.result?.let {
it.mutableMethod.apply {
val atomicReferenceStartIndex = it.scanResult.patternScanResult!!.startIndex
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val moveCharSequenceInstruction = getInstruction<TwoRegisterInstruction>(insertIndex)
val moveCharSequenceInstruction =
getInstruction<TwoRegisterInstruction>(insertIndex)
val atomicReferenceRegister =
getInstruction<FiveRegisterInstruction>(atomicReferenceStartIndex).registerC
@ -129,6 +145,7 @@ class ReturnYouTubeDislikePatch : BytecodePatch(
return PatchResultSuccess()
}
private companion object {
const val INTEGRATIONS_RYD_CLASS_DESCRIPTOR =
"$UTILS_PATH/ReturnYouTubeDislikePatch;"

View File

@ -10,7 +10,7 @@ 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.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.DislikeButton
import app.revanced.patches.youtube.utils.returnyoutubedislike.oldlayout.fingerprints.ButtonTagFingerprint
@ -31,8 +31,10 @@ class ReturnYouTubeDislikeOldLayoutPatch : BytecodePatch(
it.mutableMethod.apply {
val dislikeButtonIndex = getWideLiteralIndex(DislikeButton)
val resourceIdentifierRegister = getInstruction<OneRegisterInstruction>(dislikeButtonIndex).registerA
val textViewRegister = getInstruction<OneRegisterInstruction>(dislikeButtonIndex + 4).registerA
val resourceIdentifierRegister =
getInstruction<OneRegisterInstruction>(dislikeButtonIndex).registerA
val textViewRegister =
getInstruction<OneRegisterInstruction>(dislikeButtonIndex + 4).registerA
addInstruction(
dislikeButtonIndex + 4,
@ -43,6 +45,7 @@ class ReturnYouTubeDislikeOldLayoutPatch : BytecodePatch(
return PatchResultSuccess()
}
private companion object {
const val INTEGRATIONS_RYD_CLASS_DESCRIPTOR =
"$UTILS_PATH/ReturnYouTubeDislikePatch;"

View File

@ -10,7 +10,7 @@ import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.fingerprints.ShortsTextViewFingerprint
import app.revanced.util.integrations.Constants.UTILS_PATH
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
@ -27,7 +27,8 @@ class ReturnYouTubeDislikeShortsPatch : BytecodePatch(
val patternResult = it.scanResult.patternScanResult!!
// If the field is true, the TextView is for a dislike button.
val isDisLikesBooleanReference = getInstruction<ReferenceInstruction>(patternResult.endIndex).reference
val isDisLikesBooleanReference =
getInstruction<ReferenceInstruction>(patternResult.endIndex).reference
val textViewFieldReference = // Like/Dislike button TextView field
getInstruction<ReferenceInstruction>(patternResult.endIndex - 2).reference
@ -54,6 +55,7 @@ class ReturnYouTubeDislikeShortsPatch : BytecodePatch(
} ?: return ShortsTextViewFingerprint.toErrorResult()
return PatchResultSuccess()
}
private companion object {
const val INTEGRATIONS_RYD_CLASS_DESCRIPTOR =
"$UTILS_PATH/ReturnYouTubeDislikePatch;"

View File

@ -13,7 +13,7 @@ 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.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.returnyoutubeusername.fingerprints.SpannableStringBuilderFingerprint
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import org.jf.dexlib2.iface.instruction.ReferenceInstruction

View File

@ -10,8 +10,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.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.bytecode.fingerprints.ThemeSetterSystemFingerprint
@ -55,6 +55,7 @@ class SettingsBytecodePatch : BytecodePatch(
return PatchResultSuccess()
}
companion object {
const val SET_THEME =
"invoke-static {v0}, $INTEGRATIONS_PATH/utils/ThemeHelper;->setTheme(Ljava/lang/Object;)V"

View File

@ -1,6 +1,5 @@
package app.revanced.patches.youtube.utils.settings.resource.patch
import app.revanced.extensions.doRecursively
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
@ -9,8 +8,8 @@ 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.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.patch.settings.AbstractSettingsResourcePatch
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.bytecode.patch.SettingsBytecodePatch
@ -25,7 +24,6 @@ import app.revanced.util.resources.ResourceUtils.copyResources
import org.w3c.dom.Element
import java.io.File
import java.nio.file.Paths
import kotlin.io.path.exists
@Patch
@Name("settings")
@ -79,20 +77,20 @@ class SettingsPatch : AbstractSettingsResourcePatch(
arrayOf("Theme.YouTube.Settings", "Theme.YouTube.Settings.Dark").forEach { themeName ->
context.xmlEditor["res/values/styles.xml"].use { editor ->
with(editor.file) {
val resourcesNode = getElementsByTagName("resources").item(0) as Element
val resourcesNode = getElementsByTagName("resources").item(0) as Element
val newElement: Element = createElement("item")
newElement.setAttribute("name", "android:listDivider")
val newElement: Element = createElement("item")
newElement.setAttribute("name", "android:listDivider")
for (i in 0 until resourcesNode.childNodes.length) {
val node = resourcesNode.childNodes.item(i) as? Element ?: continue
for (i in 0 until resourcesNode.childNodes.length) {
val node = resourcesNode.childNodes.item(i) as? Element ?: continue
if (node.getAttribute("name") == themeName) {
newElement.appendChild(createTextNode("@null"))
if (node.getAttribute("name") == themeName) {
newElement.appendChild(createTextNode("@null"))
node.appendChild(newElement)
}
node.appendChild(newElement)
}
}
}
}
}
@ -115,8 +113,11 @@ class SettingsPatch : AbstractSettingsResourcePatch(
if (File(targetDirectory).exists()) {
fun copyResources(resourceGroups: List<ResourceUtils.ResourceGroup>) {
try { context.copyFiles(resourceGroups, iconPath) }
catch (_: Exception) { context.makeDirectoryAndCopyFiles(resourceGroups, iconPath) }
try {
context.copyFiles(resourceGroups, iconPath)
} catch (_: Exception) {
context.makeDirectoryAndCopyFiles(resourceGroups, iconPath)
}
}
val iconResourceFileNames =
@ -136,6 +137,7 @@ class SettingsPatch : AbstractSettingsResourcePatch(
return PatchResultSuccess()
}
companion object {
internal lateinit var contexts: ResourceContext

View File

@ -12,5 +12,9 @@ object OverlayViewLayoutFingerprint : MethodFingerprint(
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST
),
customFingerprint = { it, _ -> it.definingClass.endsWith("YouTubeControlsOverlay;") && it.isWideLiteralExists(InsetOverlayViewLayout) }
customFingerprint = { it, _ ->
it.definingClass.endsWith("YouTubeControlsOverlay;") && it.isWideLiteralExists(
InsetOverlayViewLayout
)
}
)

View File

@ -13,8 +13,10 @@ object RectangleFieldInvalidatorFingerprint : MethodFingerprint(
// the method has definitely more than 5 instructions
if (instructionCount < 5) return@custom false
val referenceInstruction = instructions.elementAt(instructionCount - 2) // the second to last instruction
val reference = ((referenceInstruction as? ReferenceInstruction)?.reference as? MethodReference)
val referenceInstruction =
instructions.elementAt(instructionCount - 2) // the second to last instruction
val reference =
((referenceInstruction as? ReferenceInstruction)?.reference as? MethodReference)
reference?.parameterTypes?.size == 1 && reference.name == "invalidate" // the reference is the invalidate(..) method
}

View File

@ -14,16 +14,19 @@ 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.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.fingerprints.SeekbarFingerprint
import app.revanced.patches.shared.fingerprints.SeekbarOnDrawFingerprint
import app.revanced.patches.shared.fingerprints.TotalTimeFingerprint
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.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.*
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
import app.revanced.patches.youtube.utils.videoid.mainstream.patch.MainstreamVideoIdPatch
import app.revanced.util.bytecode.BytecodeHelper.injectInit
@ -81,7 +84,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
*/
insertMethod = SeekbarFingerprint.result!!.let {
SeekbarOnDrawFingerprint.apply { resolve(context, it.mutableClass) }
}.result?.mutableMethod?: return SeekbarFingerprint.toErrorResult()
}.result?.mutableMethod ?: return SeekbarFingerprint.toErrorResult()
insertInstructions = insertMethod.implementation!!.instructions
@ -126,7 +129,9 @@ class SponsorBlockBytecodePatch : BytecodePatch(
val drawSegmentInstructionInsertIndex = index - 1
val (canvasInstance, centerY) =
insertMethod.getInstruction<FiveRegisterInstruction>(drawSegmentInstructionInsertIndex).let { it.registerC to it.registerE }
insertMethod.getInstruction<FiveRegisterInstruction>(
drawSegmentInstructionInsertIndex
).let { it.registerC to it.registerE }
insertMethod.addInstruction(
drawSegmentInstructionInsertIndex,
@ -139,8 +144,8 @@ class SponsorBlockBytecodePatch : BytecodePatch(
* Voting & Shield button
*/
arrayOf("CreateSegmentButtonController", "VotingButtonController").forEach {
PlayerControlsPatch.initializeSB("$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/ui/$it;")
PlayerControlsPatch.injectVisibility("$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/ui/$it;")
PlayerControlsPatch.initializeSB("$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/ui/$it;")
PlayerControlsPatch.injectVisibility("$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/ui/$it;")
}
EndScreenEngagementPanelsFingerprint.result?.mutableMethod?.let {
@ -170,8 +175,8 @@ class SponsorBlockBytecodePatch : BytecodePatch(
/**
* Initialize the SponsorBlock view
*/
OverlayViewLayoutFingerprint.result?.mutableMethod?.let{
it.apply{
OverlayViewLayoutFingerprint.result?.mutableMethod?.let {
it.apply {
val targetIndex = getWideLiteralIndex(InsetOverlayViewLayout) + 3
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
@ -185,7 +190,10 @@ class SponsorBlockBytecodePatch : BytecodePatch(
/**
* Replace strings
*/
RectangleFieldInvalidatorFingerprint.resolve(context, SeekbarOnDrawFingerprint.result!!.classDef)
RectangleFieldInvalidatorFingerprint.resolve(
context,
SeekbarOnDrawFingerprint.result!!.classDef
)
val rectangleFieldInvalidatorInstructions =
RectangleFieldInvalidatorFingerprint.result!!.method.implementation!!.instructions
val rectangleFieldName =

View File

@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.patches.youtube.utils.sponsorblock.bytecode.patch.SponsorBlockBytecodePatch
import app.revanced.util.resources.ResourceUtils
@ -65,26 +65,32 @@ class SponsorBlockResourcePatch : ResourcePatch {
// copy nodes from host resources to their real xml files
hostingXmlResources.forEach { (path, resources) ->
resources.forEach { resource ->
val hostingResourceStream = this.javaClass.classLoader.getResourceAsStream("youtube/sponsorblock/host/$path/$resource.xml")!!
val hostingResourceStream =
this.javaClass.classLoader.getResourceAsStream("youtube/sponsorblock/host/$path/$resource.xml")!!
val targetXmlEditor = context.xmlEditor["res/$path/$resource.xml"]
"RelativeLayout".copyXmlNode(
context.xmlEditor[hostingResourceStream],
targetXmlEditor
).also {
val children = targetXmlEditor.file.getElementsByTagName("RelativeLayout").item(0).childNodes
val children = targetXmlEditor.file.getElementsByTagName("RelativeLayout")
.item(0).childNodes
// Replace the startOf with the voting button view so that the button does not overlap
for (i in 1 until children.length) {
val view = children.item(i)
// Replace the attribute for a specific node only
if (!(view.hasAttributes() && view.attributes.getNamedItem("android:id").nodeValue.endsWith("player_video_heading"))) continue
if (!(view.hasAttributes() && view.attributes.getNamedItem("android:id").nodeValue.endsWith(
"player_video_heading"
))
) continue
// voting button id from the voting button view from the youtube_controls_layout.xml host file
val votingButtonId = "@+id/sb_voting_button"
view.attributes.getNamedItem("android:layout_toStartOf").nodeValue = votingButtonId
view.attributes.getNamedItem("android:layout_toStartOf").nodeValue =
votingButtonId
break
}

View File

@ -10,7 +10,7 @@ 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.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.videoid.legacy.fingerprint.LegacyVideoIdFingerprint
import app.revanced.util.integrations.Constants.VIDEO_PATH
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@ -29,7 +29,8 @@ class LegacyVideoIdPatch : BytecodePatch(
it.mutableMethod.apply {
insertMethod = this
videoIdRegister = (implementation!!.instructions[insertIndex + 1] as OneRegisterInstruction).registerA
videoIdRegister =
(implementation!!.instructions[insertIndex + 1] as OneRegisterInstruction).registerA
}
offset++ // offset so setCurrentVideoId is called before any injected call
} ?: return LegacyVideoIdFingerprint.toErrorResult()

View File

@ -5,7 +5,7 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object VideoTimeHighPrecisionFingerprint : MethodFingerprint (
object VideoTimeHighPrecisionFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
parameters = listOf("J", "J", "J", "J", "I", "L"),

View File

@ -17,9 +17,16 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
import app.revanced.patches.shared.annotation.YouTubeCompatibility
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.*
import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.MainstreamVideoIdFingerprint
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
import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.TimebarFingerprint
import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.VideoLengthFingerprint
import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.VideoTimeHighPrecisionFingerprint
import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.VideoTimeHighPrecisionParentFingerprint
import app.revanced.util.integrations.Constants.VIDEO_PATH
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.builder.MutableMethodImplementation
@ -48,7 +55,8 @@ class MainstreamVideoIdPatch : BytecodePatch(
override fun execute(context: BytecodeContext): PatchResult {
PlayerInitFingerprint.result?.let { parentResult ->
playerInitMethod = parentResult.mutableClass.methods.first { MethodUtil.isConstructor(it) }
playerInitMethod =
parentResult.mutableClass.methods.first { MethodUtil.isConstructor(it) }
// hook the player controller for use through integrations
onCreateHook(INTEGRATIONS_CLASS_DESCRIPTOR, "initialize")
@ -85,7 +93,12 @@ class MainstreamVideoIdPatch : BytecodePatch(
* Set the high precision video time method
*/
VideoTimeHighPrecisionParentFingerprint.result?.let { parentResult ->
VideoTimeHighPrecisionFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.let { method ->
VideoTimeHighPrecisionFingerprint.also {
it.resolve(
context,
parentResult.classDef
)
}.result?.mutableMethod?.let { method ->
highPrecisionTimeMethod = method
} ?: return VideoTimeHighPrecisionFingerprint.toErrorResult()
} ?: return VideoTimeHighPrecisionParentFingerprint.toErrorResult()