mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-11 13:46:17 +00:00
feat(Instagram): Add Hide suggested content patch (#6075)
This commit is contained in:
@@ -269,7 +269,7 @@ public final class app/revanced/patches/instagram/feed/LimitFeedToFollowedProfil
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class app/revanced/patches/instagram/hide/explore/HideExploreFeedKt {
|
public final class app/revanced/patches/instagram/hide/explore/HideExploreFeedKt {
|
||||||
public static final fun getHideExportFeedPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
public static final fun getHideExploreFeedPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class app/revanced/patches/instagram/hide/navigation/HideNavigationButtonsKt {
|
public final class app/revanced/patches/instagram/hide/navigation/HideNavigationButtonsKt {
|
||||||
@@ -280,6 +280,10 @@ public final class app/revanced/patches/instagram/hide/stories/HideStoriesKt {
|
|||||||
public static final fun getHideStoriesPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
public static final fun getHideStoriesPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patches/instagram/hide/suggestions/HideSuggestedContentKt {
|
||||||
|
public static final fun getHideSuggestedContent ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||||
|
}
|
||||||
|
|
||||||
public final class app/revanced/patches/instagram/misc/devmenu/EnableDeveloperMenuPatchKt {
|
public final class app/revanced/patches/instagram/misc/devmenu/EnableDeveloperMenuPatchKt {
|
||||||
public static final fun getEnableDeveloperMenuPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
public static final fun getEnableDeveloperMenuPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ package app.revanced.patches.instagram.hide.explore
|
|||||||
|
|
||||||
import app.revanced.patcher.fingerprint
|
import app.revanced.patcher.fingerprint
|
||||||
|
|
||||||
|
internal const val EXPLORE_KEY_TO_BE_HIDDEN = "sectional_items"
|
||||||
|
|
||||||
internal val exploreResponseJsonParserFingerprint = fingerprint {
|
internal val exploreResponseJsonParserFingerprint = fingerprint {
|
||||||
strings("sectional_items", "ExploreTopicalFeedResponse")
|
strings(EXPLORE_KEY_TO_BE_HIDDEN, "ExploreTopicalFeedResponse")
|
||||||
custom { method, _ -> method.name == "parseFromJson" }
|
custom { method, _ -> method.name == "parseFromJson" }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,39 @@
|
|||||||
package app.revanced.patches.instagram.hide.explore
|
package app.revanced.patches.instagram.hide.explore
|
||||||
|
|
||||||
|
import app.revanced.patcher.Fingerprint
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
|
import app.revanced.patcher.patch.BytecodePatchContext
|
||||||
import app.revanced.patcher.patch.bytecodePatch
|
import app.revanced.patcher.patch.bytecodePatch
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
|
context(BytecodePatchContext)
|
||||||
|
internal fun Fingerprint.replaceJsonFieldWithBogus(
|
||||||
|
key: String,
|
||||||
|
) {
|
||||||
|
val targetStringIndex = stringMatches!!.first { match -> match.string == key }.index
|
||||||
|
val targetStringRegister = method.getInstruction<OneRegisterInstruction>(targetStringIndex).registerA
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replacing the JSON key we want to skip with a random string that is not a valid JSON key.
|
||||||
|
* This way the feeds array will never be populated.
|
||||||
|
* Received JSON keys that are not handled are simply ignored, so there are no side effects.
|
||||||
|
*/
|
||||||
|
method.replaceInstruction(
|
||||||
|
targetStringIndex,
|
||||||
|
"const-string v$targetStringRegister, \"BOGUS\"",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
val hideExportFeedPatch = bytecodePatch(
|
val hideExploreFeedPatch = bytecodePatch(
|
||||||
name = "Hide explore feed",
|
name = "Hide explore feed",
|
||||||
description = "Hides posts and reels from the explore/search page.",
|
description = "Hides posts and reels from the explore/search page.",
|
||||||
use = false
|
use = false,
|
||||||
) {
|
) {
|
||||||
compatibleWith("com.instagram.android")
|
compatibleWith("com.instagram.android")
|
||||||
|
|
||||||
execute {
|
execute {
|
||||||
exploreResponseJsonParserFingerprint.method.apply {
|
exploreResponseJsonParserFingerprint.replaceJsonFieldWithBogus(EXPLORE_KEY_TO_BE_HIDDEN)
|
||||||
val sectionalItemStringIndex = exploreResponseJsonParserFingerprint.stringMatches!!.first().index
|
|
||||||
val sectionalItemStringRegister = getInstruction<OneRegisterInstruction>(sectionalItemStringIndex).registerA
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replacing the JSON key we want to skip with a random string that is not a valid JSON key.
|
|
||||||
* This way the feeds array will never be populated.
|
|
||||||
* Received JSON keys that are not handled are simply ignored, so there are no side effects.
|
|
||||||
*/
|
|
||||||
replaceInstruction(
|
|
||||||
sectionalItemStringIndex,
|
|
||||||
"const-string v$sectionalItemStringRegister, \"BOGUS\""
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package app.revanced.patches.instagram.hide.suggestions
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint
|
||||||
|
|
||||||
|
internal val FEED_ITEM_KEYS_TO_BE_HIDDEN = arrayOf(
|
||||||
|
"clips_netego",
|
||||||
|
"stories_netego",
|
||||||
|
"in_feed_survey",
|
||||||
|
"bloks_netego",
|
||||||
|
"suggested_igd_channels",
|
||||||
|
"suggested_top_accounts",
|
||||||
|
"suggested_users",
|
||||||
|
)
|
||||||
|
|
||||||
|
internal val feedItemParseFromJsonFingerprint = fingerprint {
|
||||||
|
strings(*FEED_ITEM_KEYS_TO_BE_HIDDEN, "FeedItem")
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package app.revanced.patches.instagram.hide.suggestions
|
||||||
|
|
||||||
|
import app.revanced.patcher.patch.bytecodePatch
|
||||||
|
import app.revanced.patches.instagram.hide.explore.replaceJsonFieldWithBogus
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
val hideSuggestedContent = bytecodePatch(
|
||||||
|
name = "Hide suggested content",
|
||||||
|
description = "Hides suggested stories, reels, threads and survey from feed (Suggested posts will still be shown).",
|
||||||
|
use = false,
|
||||||
|
) {
|
||||||
|
compatibleWith("com.instagram.android")
|
||||||
|
|
||||||
|
execute {
|
||||||
|
FEED_ITEM_KEYS_TO_BE_HIDDEN.forEach { key ->
|
||||||
|
feedItemParseFromJsonFingerprint.replaceJsonFieldWithBogus(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user