Skip to content

Commit d7e3d2b

Browse files
bru02chsbuffer
andauthored
Add Strava hooks (#37)
* Add Strava hooks * Strava: Improve hook stability and minor refactoring --------- Co-authored-by: ChsBuffer <[email protected]>
1 parent 5c4fcc3 commit d7e3d2b

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import io.github.chsbuffer.revancedxposed.meta.MetaHook
1515
import io.github.chsbuffer.revancedxposed.music.MusicHook
1616
import io.github.chsbuffer.revancedxposed.reddit.RedditHook
1717
import io.github.chsbuffer.revancedxposed.spotify.SpotifyHook
18+
import io.github.chsbuffer.revancedxposed.strava.StravaHook
1819
import io.github.chsbuffer.revancedxposed.youtube.YoutubeHook
1920

2021
class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
@@ -29,7 +30,8 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
2930
"com.reddit.frontpage" to { RedditHook(app, lpparam) },
3031
"com.google.android.apps.photos" to { GooglePhotosHook(lpparam) },
3132
"com.instagram.android" to { MetaHook(app, lpparam) },
32-
"com.instagram.barcelona" to { MetaHook(app, lpparam) })
33+
"com.instagram.barcelona" to { MetaHook(app, lpparam) },
34+
"com.strava" to { StravaHook(app, lpparam) })
3335

3436
fun shouldHook(packageName: String): Boolean {
3537
if (!hooksByPackage.containsKey(packageName)) return false
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package io.github.chsbuffer.revancedxposed.strava
2+
3+
import android.app.Application
4+
import de.robv.android.xposed.XC_MethodHook
5+
import de.robv.android.xposed.callbacks.XC_LoadPackage
6+
import io.github.chsbuffer.revancedxposed.BaseHook
7+
import io.github.chsbuffer.revancedxposed.Opcode
8+
import io.github.chsbuffer.revancedxposed.getObjectFieldOrNullAs
9+
import io.github.chsbuffer.revancedxposed.opcodes
10+
import org.luckypray.dexkit.query.enums.StringMatchType
11+
import java.util.Collections
12+
13+
class StravaHook(app: Application, lpparam: XC_LoadPackage.LoadPackageParam) :
14+
BaseHook(app, lpparam) {
15+
override val hooks = arrayOf(
16+
::UnlockSubscription,
17+
::DisableSubscriptionSuggestions
18+
)
19+
20+
fun UnlockSubscription() {
21+
getDexMethod("getSubscribedFingerprint") {
22+
findMethod {
23+
matcher {
24+
name = "getSubscribed"
25+
declaredClass(".SubscriptionDetailResponse", StringMatchType.EndsWith)
26+
opcodes(
27+
Opcode.IGET_BOOLEAN,
28+
)
29+
}
30+
}.single()
31+
}.hookMethod(object : XC_MethodHook() {
32+
override fun beforeHookedMethod(param: MethodHookParam) {
33+
param.result = true
34+
}
35+
})
36+
}
37+
38+
fun DisableSubscriptionSuggestions() {
39+
getDexMethod("PivotBarConstructorFingerprint") {
40+
findMethod {
41+
matcher {
42+
name = "getModules"
43+
declaredClass(".GenericLayoutEntry", StringMatchType.EndsWith)
44+
opcodes(
45+
Opcode.IGET_OBJECT,
46+
)
47+
}
48+
}.single()
49+
}.hookMethod(object : XC_MethodHook() {
50+
override fun beforeHookedMethod(param: MethodHookParam) {
51+
val pageValue = param.thisObject.getObjectFieldOrNullAs<String>("page") ?: return
52+
if (pageValue.contains("_upsell") || pageValue.contains("promo")) {
53+
param.result = Collections.EMPTY_LIST
54+
}
55+
}
56+
})
57+
}
58+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
<item>com.google.android.apps.photos</item>
88
<item>com.instagram.android</item>
99
<item>com.instagram.barcelona</item>
10+
<item>com.strava</item>
1011
</string-array>
1112
</resources>

0 commit comments

Comments
 (0)