mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
fix(youtube/litho-filter): exception occurs when only patches that use LowlevelFilter are included
This commit is contained in:
@ -6,7 +6,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.music.utils.annotations.MusicCompatibility
|
||||
import app.revanced.patches.music.utils.litho.fingerprints.LithoFilterFingerprint
|
||||
import app.revanced.patches.shared.patch.litho.ComponentParserPatch
|
||||
import app.revanced.patches.shared.patch.litho.ComponentParserPatch.Companion.pathBuilderHook
|
||||
@ -14,7 +13,6 @@ import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH
|
||||
import java.io.Closeable
|
||||
|
||||
@DependsOn([ComponentParserPatch::class])
|
||||
@MusicCompatibility
|
||||
class LithoFilterPatch : BytecodePatch(
|
||||
listOf(LithoFilterFingerprint)
|
||||
), Closeable {
|
||||
|
@ -9,7 +9,6 @@ import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.litho.patch.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus
|
||||
import app.revanced.util.integrations.Constants.PATCHES_PATH
|
||||
|
||||
@Patch
|
||||
@ -38,7 +37,5 @@ class DescriptionComponentsPatch : BytecodePatch() {
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-description-components")
|
||||
|
||||
context.updatePatchStatus("DescriptionComponent")
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import app.revanced.patches.youtube.general.suggestions.fingerprints.SuggestionC
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.litho.patch.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.GENERAL
|
||||
import app.revanced.util.integrations.Constants.PATCHES_PATH
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@ -39,7 +39,7 @@ class SuggestionsShelfPatch : BytecodePatch(
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
/**
|
||||
* Legacy code for old layout
|
||||
* Only used to tablet layout and the old UI components.
|
||||
*/
|
||||
BreakingNewsFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
@ -48,22 +48,20 @@ class SuggestionsShelfPatch : BytecodePatch(
|
||||
|
||||
addInstruction(
|
||||
targetIndex + 1,
|
||||
"invoke-static {v$targetRegister}, $GENERAL->hideBreakingNewsShelf(Landroid/view/View;)V"
|
||||
"invoke-static {v$targetRegister}, $FILTER_CLASS_DESCRIPTOR->hideBreakingNewsShelf(Landroid/view/View;)V"
|
||||
)
|
||||
}
|
||||
} ?: throw BreakingNewsFingerprint.exception
|
||||
|
||||
/**
|
||||
* For new layout
|
||||
*
|
||||
* Target method only removes the horizontal video shelf's content in the feed.
|
||||
* Since the header of the horizontal video shelf is not removed, it must be removed through the low level filter
|
||||
* Since the header of the horizontal video shelf is not removed, it should be removed through the SuggestionsShelfFilter
|
||||
*/
|
||||
SuggestionContentsBuilderFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
addInstructionsWithLabels(
|
||||
2, """
|
||||
invoke-static/range {p2 .. p2}, $GENERAL->hideSuggestionsShelf(Ljava/lang/Object;)Z
|
||||
invoke-static/range {p2 .. p2}, $FILTER_CLASS_DESCRIPTOR->filterSuggestionsShelfSubComponents(Ljava/lang/Object;)Z
|
||||
move-result v0
|
||||
if-eqz v0, :show
|
||||
""" + emptyComponentLabel, ExternalLabel("show", getInstruction(2))
|
||||
@ -71,6 +69,8 @@ class SuggestionsShelfPatch : BytecodePatch(
|
||||
}
|
||||
} ?: throw SuggestionContentsBuilderFingerprint.exception
|
||||
|
||||
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
|
||||
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
@ -85,4 +85,9 @@ class SuggestionsShelfPatch : BytecodePatch(
|
||||
SettingsPatch.updatePatchStatus("hide-suggestions-shelf")
|
||||
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val FILTER_CLASS_DESCRIPTOR =
|
||||
"$PATCHES_PATH/ads/SuggestionsShelfFilter;"
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import app.revanced.extensions.injectHideCall
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
@ -12,9 +13,10 @@ import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.youtube.player.suggestactions.fingerprints.SuggestedActionsFingerprint
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.litho.patch.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.utils.playertype.patch.PlayerTypeHookPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus
|
||||
import app.revanced.util.integrations.Constants.PATCHES_PATH
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@ -23,6 +25,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@DependsOn(
|
||||
[
|
||||
LithoFilterPatch::class,
|
||||
PlayerTypeHookPatch::class,
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
]
|
||||
@ -37,16 +40,15 @@ class SuggestedActionsPatch : BytecodePatch(
|
||||
val targetIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
implementation!!.injectHideCall(
|
||||
addInstruction(
|
||||
targetIndex + 1,
|
||||
targetRegister,
|
||||
"layout/PlayerPatch",
|
||||
"hideSuggestedActions"
|
||||
"invoke-static {v$targetRegister}, $FILTER_CLASS_DESCRIPTOR->hideSuggestedActions(Landroid/view/View;)V"
|
||||
|
||||
)
|
||||
}
|
||||
} ?: throw SuggestedActionsFingerprint.exception
|
||||
|
||||
context.updatePatchStatus("SuggestedActions")
|
||||
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
@ -61,4 +63,9 @@ class SuggestedActionsPatch : BytecodePatch(
|
||||
SettingsPatch.updatePatchStatus("hide-suggested-actions")
|
||||
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val FILTER_CLASS_DESCRIPTOR =
|
||||
"$PATCHES_PATH/ads/SuggestedActionFilter;"
|
||||
}
|
||||
}
|
||||
|
@ -10,23 +10,13 @@ import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
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.litho.fingerprints.GeneralByteBufferFingerprint
|
||||
import app.revanced.patches.youtube.utils.litho.fingerprints.LithoFilterFingerprint
|
||||
import app.revanced.patches.youtube.utils.litho.fingerprints.LowLevelByteBufferFingerprint
|
||||
import app.revanced.patches.youtube.utils.playertype.patch.PlayerTypeHookPatch
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.ADS_PATH
|
||||
import java.io.Closeable
|
||||
|
||||
@DependsOn(
|
||||
[
|
||||
ComponentParserPatch::class,
|
||||
PlayerTypeHookPatch::class,
|
||||
SettingsPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@DependsOn([ComponentParserPatch::class])
|
||||
class LithoFilterPatch : BytecodePatch(
|
||||
listOf(
|
||||
GeneralByteBufferFingerprint,
|
||||
|
Reference in New Issue
Block a user