Skip to content

Commit

Permalink
refactor(Twitter): refactor default feature flag hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Swakshan committed May 2, 2024
1 parent 03fb96c commit 6fd6001
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 26 deletions.
Expand Up @@ -20,11 +20,8 @@ object DisableChirpFontPatch: BytecodePatch(
setOf( FeatureFlagLoadFingerprint,SettingsStatusLoadFingerprint)
) {
override fun execute(context: BytecodeContext) {
FeatureFlagLoadFingerprint.result!!.mutableMethod.addInstruction(
0,
"${SettingsPatch.FSTS_DESCRIPTOR}->chirpFont()V"
)

FeatureFlagLoadFingerprint.enableSettings("chirpFont")
SettingsStatusLoadFingerprint.enableSettings("enableFont")
//end
}
Expand Down
Expand Up @@ -20,11 +20,7 @@ object HideBookmarkInTimelinePatch:BytecodePatch(
) {
override fun execute(context: BytecodeContext) {

FeatureFlagLoadFingerprint.result!!.mutableMethod.addInstruction(
0,
"${SettingsPatch.FSTS_DESCRIPTOR}->bookmarkInTimeline()V"
)

FeatureFlagLoadFingerprint.enableSettings("bookmarkInTimeline")
SettingsStatusLoadFingerprint.enableSettings("hideInlineBmk")

//end
Expand Down
Expand Up @@ -22,11 +22,7 @@ class HideFABMenuButtonsPatch : BytecodePatch(
){
override fun execute(context: BytecodeContext) {
SettingsStatusLoadFingerprint.enableSettings("hideFABBtns")

FeatureFlagLoadFingerprint.result?.mutableMethod?.addInstruction(
0,
"${SettingsPatch.FSTS_DESCRIPTOR}->fabMenu()V"
) ?: throw PatchException("FeatureFlagLoadFingerprint not found")
FeatureFlagLoadFingerprint.enableSettings("fabMenu")
//end
}
}
Expand Up @@ -22,11 +22,7 @@ class HideImmersivePlayer : BytecodePatch(
){
override fun execute(context: BytecodeContext) {
SettingsStatusLoadFingerprint.enableSettings("hideImmersivePlayer")

FeatureFlagLoadFingerprint.result!!.mutableMethod.addInstruction(
0,
"${SettingsPatch.FSTS_DESCRIPTOR}->immersivePlayer()V"
)
FeatureFlagLoadFingerprint.enableSettings("immersivePlayer")
//end
}
}
Expand Up @@ -21,11 +21,7 @@ object RemoveViewCountPatch: BytecodePatch(
setOf(FeatureFlagLoadFingerprint,SettingsStatusLoadFingerprint)
) {
override fun execute(context: BytecodeContext) {
FeatureFlagLoadFingerprint.result!!.mutableMethod.addInstruction(
0,
"${SettingsPatch.FSTS_DESCRIPTOR}->viewCount()V"
)

FeatureFlagLoadFingerprint.enableSettings("viewCount")
SettingsStatusLoadFingerprint.enableSettings("hideViewCount")
}

Expand Down
@@ -1,10 +1,20 @@
package crimera.patches.twitter.featureFlag.fingerprints

import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.fingerprint.MethodFingerprint
import app.revanced.patcher.patch.PatchException
import crimera.patches.twitter.misc.settings.SettingsPatch

object FeatureFlagLoadFingerprint:MethodFingerprint(
customFingerprint = { methodDef, _ ->
methodDef.definingClass.endsWith("Lapp/revanced/integrations/twitter/patches/FeatureSwitchPatch;") &&
methodDef.name == "load"
}
)
){
fun enableSettings(functionName: String) {
result?.mutableMethod?.addInstruction(
0,
"${SettingsPatch.FSTS_DESCRIPTOR}->$functionName()V"
) ?: throw PatchException("FeatureFlagLoadFingerprint not found")
}
}
Expand Up @@ -10,7 +10,7 @@ object HideCommunityNoteFingerprint : MethodFingerprint(
"birdwatch_pivot",
),
customFingerprint = {it,_ ->
it.definingClass =="Lcom/twitter/api/model/json/core/JsonApiTweet\$\$JsonObjectMapper;"
it.definingClass =="Lcom/twitter/api/model/json/core/JsonApiTweet\$\$JsonObjectMapper;" && it.name == "parseField"
}

)

0 comments on commit 6fd6001

Please sign in to comment.