Skip to content

Commit 7ad6d95

Browse files
committed
fix(Reddit): Update Hide ads patch for new versions of Reddit
1 parent 7780e1f commit 7ad6d95

File tree

7 files changed

+17
-9
lines changed

7 files changed

+17
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
### Threads
6060
- Hide ads
6161

62-
### Reddit (2024.17.0)
62+
### Reddit
6363
- Hide ads
6464
- Sanitize sharing links
6565

app/src/main/java/io/github/chsbuffer/revancedxposed/AppPatchInfo.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AppPatchInfo(val appName: String, val packageName: String, val patches: Ar
1313
val appPatchConfigurations = listOf(
1414
AppPatchInfo("YouTube", "com.google.android.youtube", YouTubePatches),
1515
AppPatchInfo("YT Music", "com.google.android.apps.youtube.music", YTMusicPatches),
16-
AppPatchInfo("Reddit (2024.17.0)", "com.reddit.frontpage", RedditPatches),
16+
AppPatchInfo("Reddit", "com.reddit.frontpage", RedditPatches),
1717
AppPatchInfo("Google Photos", "com.google.android.apps.photos", GooglePhotosPatches),
1818
AppPatchInfo("Instagram", "com.instagram.android", MetaPatches),
1919
AppPatchInfo("Threads", "com.instagram.barcelona", MetaPatches),

app/src/main/java/io/github/chsbuffer/revancedxposed/PatchExecutor.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ class PatchExecutor(val appContext: Application, val lpparam: LoadPackageParam):
255255
val KProperty0<FindMethodFunc>.method
256256
get() = getDexMethod(this.name, this.get()).toMethod()
257257

258+
val KProperty0<FindMethodFunc>.constructor
259+
get() = getDexMethod(this.name, this.get()).toConstructor()
260+
258261
val KProperty0<FindMethodFunc>.dexMethod
259262
get() = getDexMethod(this.name, this.get())
260263

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package io.github.chsbuffer.revancedxposed.reddit.ad.comments
22

33
import io.github.chsbuffer.revancedxposed.fingerprint
4+
import org.luckypray.dexkit.query.enums.StringMatchType
45

56
val hideCommentAdsFingerprint = fingerprint {
6-
strings(
7-
"link",
8-
// CommentPageRepository is not returning a link object
9-
"is not returning a link object"
10-
)
7+
methodMatcher {
8+
name("invokeSuspend")
9+
declaredClass("LoadAdsCombinedCall", StringMatchType.Contains)
10+
}
1111
}

app/src/main/java/io/github/chsbuffer/revancedxposed/reddit/ad/comments/HideCommentAdsPatch.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ val HideCommentAds = patch(
88
::hideCommentAdsFingerprint.hookMethod {
99
before {
1010
Logger.printDebug { "Hide Comment" }
11-
it.result = Object()
11+
it.result = it.args[0]
1212
}
1313
}
1414
}

app/src/main/java/io/github/chsbuffer/revancedxposed/reddit/ad/general/HideAdsPatch.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ val HideAds = patch(
4747
// AdElementConverter is conveniently responsible for inserting all feed ads.
4848
// By removing the appending instruction no ad posts gets appended to the feed.
4949
::AdPostSectionInitFingerprint.hookMethod {
50+
val arg = ::AdPostSectionInitFingerprint.constructor.parameters.indexOfFirst {
51+
MutableList::class.java.isAssignableFrom(it.type)
52+
}
53+
Logger.printInfo { "AdPostSection sections arg index: $arg" }
5054
before { param ->
51-
val sections = param.args[3] as MutableList<*>
55+
val sections = param.args[arg] as MutableList<*>
5256
sections.javaClass.findFieldByExactType(Array<Any>::class.java)!!
5357
.set(sections, emptyArray<Any>())
5458
Logger.printDebug { "Removed ads from popular and latest feed" }

app/src/main/res/values/arrays.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<string-array name="scope">
44
<item>com.google.android.apps.youtube.music</item>
55
<item>com.google.android.youtube</item>
6+
<item>com.reddit.frontpage</item>
67
<item>com.google.android.apps.photos</item>
78
<item>com.instagram.android</item>
89
<item>com.instagram.barcelona</item>

0 commit comments

Comments
 (0)