mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-29 11:05:48 +01:00
feat(Facebook): Add Hide story ads
patch (#3257)
Co-authored-by: Loukious <Loukious@users.noreply.github.com> Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
2eb5604287
commit
1408c2e628
@ -0,0 +1,26 @@
|
|||||||
|
package app.revanced.patches.facebook.ads.story
|
||||||
|
|
||||||
|
import app.revanced.extensions.exception
|
||||||
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
|
import app.revanced.patches.facebook.ads.story.fingerprints.AdsInsertionFingerprint
|
||||||
|
import app.revanced.patches.facebook.ads.story.fingerprints.FetchMoreAdsFingerprint
|
||||||
|
|
||||||
|
@Patch(
|
||||||
|
name = "Hide story ads",
|
||||||
|
description = "Hides the ads in the Facebook app stories.",
|
||||||
|
compatiblePackages = [CompatiblePackage("com.facebook.katana")]
|
||||||
|
)
|
||||||
|
@Suppress("unused")
|
||||||
|
object HideStoryAdsPatch : BytecodePatch(
|
||||||
|
setOf(FetchMoreAdsFingerprint, AdsInsertionFingerprint)
|
||||||
|
) {
|
||||||
|
override fun execute(context: BytecodeContext) =
|
||||||
|
setOf(FetchMoreAdsFingerprint, AdsInsertionFingerprint).forEach { fingerprint ->
|
||||||
|
fingerprint.result?.mutableMethod?.replaceInstruction(0, "return-void")
|
||||||
|
?: throw fingerprint.exception
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
package app.revanced.patches.facebook.ads.story.fingerprints
|
||||||
|
|
||||||
|
object AdsInsertionFingerprint : FieldMethodFingerprint(fieldValue = "AdBucketDataSourceUtil\$attemptAdsInsertion\$1")
|
@ -0,0 +1,3 @@
|
|||||||
|
package app.revanced.patches.facebook.ads.story.fingerprints
|
||||||
|
|
||||||
|
object FetchMoreAdsFingerprint : FieldMethodFingerprint(fieldValue = "AdBucketDataSourceUtil\$attemptFetchMoreAds\$1")
|
@ -0,0 +1,15 @@
|
|||||||
|
package app.revanced.patches.facebook.ads.story.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.iface.value.StringEncodedValue
|
||||||
|
|
||||||
|
abstract class FieldMethodFingerprint(fieldValue: String) : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
parameters = listOf(),
|
||||||
|
customFingerprint = { methodDef, classDef ->
|
||||||
|
methodDef.name == "run" && classDef.fields.any any@{ field ->
|
||||||
|
if (field.name != "__redex_internal_original_name") return@any false
|
||||||
|
(field.initialValue as? StringEncodedValue)?.value == fieldValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user