feat(YouTube/Hide feed components): Hide carousel shelf setting no longer checks browserId

This commit is contained in:
inotia00 2024-04-20 23:12:38 +09:00
parent 26829aceca
commit 844c295904
4 changed files with 51 additions and 10 deletions

View File

@ -19,8 +19,8 @@ abstract class BaseMainActivityResolvePatch(
setOf(mainActivityOnCreateFingerprint)
) {
lateinit var mainActivityMutableClass: MutableClass
lateinit var onBackPressedMethod: MutableMethod
private lateinit var constructorMethod: MutableMethod
private lateinit var onBackPressedMethod: MutableMethod
private lateinit var onCreateMethod: MutableMethod
private var constructorMethodIndex by Delegates.notNull<Int>()
private var onBackPressedMethodIndex by Delegates.notNull<Int>()

View File

@ -19,7 +19,6 @@ import app.revanced.patches.youtube.feed.components.fingerprints.LatestVideosBut
import app.revanced.patches.youtube.feed.components.fingerprints.RelatedChipCloudFingerprint
import app.revanced.patches.youtube.feed.components.fingerprints.SearchResultsChipBarFingerprint
import app.revanced.patches.youtube.feed.components.fingerprints.ShowMoreButtonFingerprint
import app.revanced.patches.youtube.utils.browseid.BrowseIdHookPatch
import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
import app.revanced.patches.youtube.utils.integrations.Constants.FEED_CLASS_DESCRIPTOR
@ -43,7 +42,6 @@ object FeedComponentsPatch : BaseBytecodePatch(
name = "Hide feed components",
description = "Adds options to hide components related to feed.",
dependencies = setOf(
BrowseIdHookPatch::class,
LithoFilterPatch::class,
NavigationBarHookPatch::class,
SettingsPatch::class,

View File

@ -10,7 +10,9 @@ import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.shared.litho.LithoFilterPatch
import app.revanced.patches.shared.litho.fingerprints.PathBuilderFingerprint
import app.revanced.patches.youtube.utils.browseid.fingerprints.BrowseIdClassFingerprint
import app.revanced.patches.youtube.utils.browseid.fingerprints.MobileTopBarDialogFingerprint
import app.revanced.patches.youtube.utils.integrations.Constants.SHARED_PATH
import app.revanced.patches.youtube.utils.mainactivity.MainActivityResolvePatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndex
@ -22,18 +24,24 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference
@Patch(
dependencies = [
LithoFilterPatch::class,
MainActivityResolvePatch::class,
SharedResourceIdPatch::class
]
)
@Deprecated("This patch will be removed in the future.")
object BrowseIdHookPatch : BytecodePatch(
setOf(
BrowseIdClassFingerprint,
MobileTopBarDialogFingerprint,
PathBuilderFingerprint
)
) {
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
"$SHARED_PATH/BrowseId;"
private const val SETTINGS_ACTIVITY_CLASS_DESCRIPTOR =
"Lcom/google/android/apps/youtube/app/settings/SettingsActivity;"
override fun execute(context: BytecodeContext) {
/**
@ -62,16 +70,40 @@ object BrowseIdHookPatch : BytecodePatch(
}
}
val mobileTopBarDialogClass =
MobileTopBarDialogFingerprint.resultOrThrow().mutableClass
val mobileTopBarDialogOnBackPressedMethod =
mobileTopBarDialogClass.methods.single { method ->
method.name == "onBackPressed"
}
val mobileTopBarDialogOnStopMethod =
mobileTopBarDialogClass.methods.single { method ->
method.name == "onStop"
}
val pathBuilderMethod = PathBuilderFingerprint.resultOrThrow().mutableMethod
val settingsActivityOnBackPressedMethod =
context.findClass(SETTINGS_ACTIVITY_CLASS_DESCRIPTOR)!!.mutableClass.methods.single { method ->
method.name == "onBackPressed"
}
/**
* Set BrowseId to integrations.
*/
PathBuilderFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
addInstruction(
0,
"invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->setBrowseIdFromField()V"
)
}
listOf(
MainActivityResolvePatch.onBackPressedMethod,
mobileTopBarDialogOnBackPressedMethod,
mobileTopBarDialogOnStopMethod,
pathBuilderMethod,
settingsActivityOnBackPressedMethod
).forEach { method ->
method.addInstruction(
0,
"invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->setBrowseIdFromField()V"
)
}
}
}

View File

@ -0,0 +1,11 @@
package app.revanced.patches.youtube.utils.browseid.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint
internal object MobileTopBarDialogFingerprint : MethodFingerprint(
returnType = "V",
customFingerprint = { methodDef, classDef ->
methodDef.name == "setContentView" &&
classDef.superclass == "Landroid/app/Dialog;"
}
)