generated from ReVanced/revanced-patches-template
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Twitter): Added
Remove videos for you
patch
- Loading branch information
swakwork
committed
Aug 10, 2024
1 parent
c0152e3
commit 25934a2
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/crimera/patches/twitter/ads/timelineEntryHook/HideVideosForYou.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,23 @@ | ||
package crimera.patches.twitter.ads.timelineEntryHook | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import crimera.patches.twitter.misc.settings.SettingsPatch | ||
import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFingerprint | ||
|
||
@Patch( | ||
name = "Remove videos for you", | ||
description = "Removes \"videos for you\" from explore", | ||
dependencies = [SettingsPatch::class,TimelineModuleItemHookPatch::class], | ||
compatiblePackages = [CompatiblePackage("com.twitter.android")], | ||
use = true | ||
) | ||
object HideVideosForYou :BytecodePatch( | ||
setOf(SettingsStatusLoadFingerprint) | ||
){ | ||
override fun execute(context: BytecodeContext) { | ||
SettingsStatusLoadFingerprint.enableSettings("hideVideosForYou") | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/kotlin/crimera/patches/twitter/ads/timelineEntryHook/TimelineModuleItemHookPatch.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,45 @@ | ||
package crimera.patches.twitter.ads.timelineEntryHook | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions | ||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.PatchException | ||
import app.revanced.patcher.patch.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import com.android.tools.smali.dexlib2.Opcode | ||
import crimera.patches.twitter.misc.settings.SettingsPatch | ||
|
||
object TimelineModuleItemHookFingerprint:MethodFingerprint( | ||
returnType = "Ljava/lang/Object", | ||
customFingerprint = {it,_-> | ||
it.definingClass == "Lcom/twitter/model/json/timeline/urt/JsonTimelineModuleItem\$\$JsonObjectMapper;" && it.name == "parse" | ||
} | ||
) | ||
|
||
@Patch( | ||
compatiblePackages = [CompatiblePackage("com.twitter.android")], | ||
) | ||
object TimelineModuleItemHookPatch:BytecodePatch( | ||
setOf(TimelineModuleItemHookFingerprint) | ||
){ | ||
override fun execute(context: BytecodeContext) { | ||
val TIMELINE_ENTRY_DESCRIPTOR = "${SettingsPatch.PATCHES_DESCRIPTOR}/TimelineEntry" | ||
|
||
val result = TimelineModuleItemHookFingerprint.result | ||
?:throw PatchException("TimelineModuleItemHookFingerprint not found") | ||
|
||
val methods = result.mutableMethod | ||
val instructions = methods.getInstructions() | ||
|
||
val returnObj = instructions.last { it.opcode == Opcode.RETURN_OBJECT }.location.index | ||
|
||
methods.addInstructions(returnObj,""" | ||
invoke-static {p1}, $TIMELINE_ENTRY_DESCRIPTOR;->checkEntry(Lcom/twitter/model/json/timeline/urt/JsonTimelineModuleItem;)Lcom/twitter/model/json/timeline/urt/JsonTimelineModuleItem; | ||
move-result-object p1 | ||
""".trimIndent()) | ||
|
||
//end | ||
} | ||
} |
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