-
-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(reddit): add
hide-promoted
patch (#2350)
Co-authored-by: oSumAtrIX <[email protected]>
- Loading branch information
Showing
8 changed files
with
137 additions
and
52 deletions.
There are no files selected for viewing
12 changes: 0 additions & 12 deletions
12
src/main/kotlin/app/revanced/patches/reddit/ad/banner/annotations/HideBannerCompatibility.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
.../kotlin/app/revanced/patches/reddit/ad/comments/fingerprints/HideCommentAdsFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package app.revanced.patches.reddit.ad.comments.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
|
||
object HideCommentAdsFingerprint : MethodFingerprint( | ||
strings = listOf( | ||
"link", | ||
// CommentPageRepository is not returning a link object | ||
"is not returning a link object" | ||
), | ||
customFingerprint = { _, classDef -> | ||
classDef.sourceFile == "PostDetailPresenter.kt" | ||
}, | ||
) |
34 changes: 34 additions & 0 deletions
34
src/main/kotlin/app/revanced/patches/reddit/ad/comments/patch/HideCommentAdsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package app.revanced.patches.reddit.ad.comments.patch | ||
|
||
import app.revanced.patcher.annotation.Description | ||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.addInstructions | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.PatchResult | ||
import app.revanced.patcher.patch.PatchResultSuccess | ||
import app.revanced.patcher.patch.annotations.RequiresIntegrations | ||
import app.revanced.patches.reddit.ad.comments.fingerprints.HideCommentAdsFingerprint | ||
|
||
@Name("hide-comment-ads") | ||
@Description("Removes all comment ads.") | ||
@RequiresIntegrations | ||
@Version("0.0.1") | ||
class HideCommentAdsPatch : BytecodePatch( | ||
listOf(HideCommentAdsFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext): PatchResult { | ||
val method = HideCommentAdsFingerprint.result!!.mutableMethod | ||
// Returns a blank object instead of the comment ad. | ||
method.addInstructions( | ||
0, | ||
""" | ||
new-instance v0, Ljava/lang/Object; | ||
invoke-direct {v0}, Ljava/lang/Object;-><init>()V | ||
return-object v0 | ||
""" | ||
) | ||
return PatchResultSuccess() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/app/revanced/patches/reddit/ad/general/fingerprints/AdPostFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package app.revanced.patches.reddit.ad.general.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
|
||
object AdPostFingerprint : MethodFingerprint( | ||
"V", | ||
// "children" are present throughout multiple versions | ||
strings = listOf("children"), | ||
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("Listing;") }, | ||
) |
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/app/revanced/patches/reddit/ad/general/fingerprints/NewAdPostFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package app.revanced.patches.reddit.ad.general.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import org.jf.dexlib2.Opcode | ||
|
||
object NewAdPostFingerprint : MethodFingerprint( | ||
opcodes = listOf(Opcode.INVOKE_VIRTUAL), | ||
strings = listOf("chain", "feedElement"), | ||
customFingerprint = { _, classDef -> classDef.sourceFile == "AdElementConverter.kt" }, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters