mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-08 10:34:33 +02:00
feat(Reddit): add Hide recommended communities shelf
patch https://github.com/inotia00/ReVanced_Extended/issues/2114
This commit is contained in:
parent
e1f3da76c4
commit
130a5871bd
@ -0,0 +1,45 @@
|
||||
package app.revanced.patches.reddit.layout.communities
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.reddit.layout.communities.fingerprints.CommunityRecommendationSectionFingerprint
|
||||
import app.revanced.patches.reddit.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH
|
||||
import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus
|
||||
import app.revanced.patches.reddit.utils.settings.SettingsPatch
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
|
||||
@Suppress("unused")
|
||||
object RecommendedCommunitiesPatch : BaseBytecodePatch(
|
||||
name = "Hide recommended communities shelf",
|
||||
description = "Adds an option to hide the recommended communities shelves in subreddits.",
|
||||
dependencies = setOf(SettingsPatch::class),
|
||||
compatiblePackages = COMPATIBLE_PACKAGE,
|
||||
fingerprints = setOf(CommunityRecommendationSectionFingerprint)
|
||||
) {
|
||||
private const val INTEGRATIONS_METHOD_DESCRIPTOR =
|
||||
"$PATCHES_PATH/RecommendedCommunitiesPatch;->hideRecommendedCommunitiesShelf()Z"
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
CommunityRecommendationSectionFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
addInstructionsWithLabels(
|
||||
0,
|
||||
"""
|
||||
invoke-static {}, $INTEGRATIONS_METHOD_DESCRIPTOR
|
||||
move-result v0
|
||||
if-eqz v0, :off
|
||||
return-void
|
||||
""", ExternalLabel("off", getInstruction(0))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
updateSettingsStatus("enableRecommendedCommunitiesShelf")
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package app.revanced.patches.reddit.layout.communities.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal object CommunityRecommendationSectionFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.definingClass.endsWith("/CommunityRecommendationSection;")
|
||||
}
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user