generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
tiktok-feed-filter
, tiktok-settings
and `tiktok-force-logi…
…n` patch (#501)
- Loading branch information
Showing
15 changed files
with
428 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
...main/kotlin/app/revanced/patches/tiktok/feedfilter/annotations/FeedFilterCompatibility.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.tiktok.feedfilter.annotations | ||
|
||
import app.revanced.patcher.annotation.Compatibility | ||
import app.revanced.patcher.annotation.Package | ||
|
||
@Compatibility( | ||
[ | ||
Package("com.ss.android.ugc.trill"), | ||
Package("com.zhiliaoapp.musically") | ||
] | ||
) | ||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
internal annotation class FeedFilterCompatibility |
23 changes: 23 additions & 0 deletions
23
...otlin/app/revanced/patches/tiktok/feedfilter/fingerprints/FeedApiServiceLIZFingerprint.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 app.revanced.patches.tiktok.feedfilter.fingerprints | ||
|
||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.tiktok.feedfilter.annotations.FeedFilterCompatibility | ||
import org.jf.dexlib2.AccessFlags | ||
|
||
@Name("feed-api-service-fingerprint") | ||
@MatchingMethod( | ||
"Lcom/ss/android/ugc/aweme/feed/FeedApiService;", | ||
"LIZ", | ||
) | ||
@FeedFilterCompatibility | ||
@Version("0.0.1") | ||
object FeedApiServiceLIZFingerprint : MethodFingerprint( | ||
access = AccessFlags.PUBLIC or AccessFlags.STATIC or AccessFlags.FINAL or AccessFlags.SYNTHETIC, | ||
customFingerprint = { methodDef -> | ||
methodDef.definingClass.endsWith("/FeedApiService;") && methodDef.name == "LIZ" | ||
} | ||
) |
51 changes: 51 additions & 0 deletions
51
src/main/kotlin/app/revanced/patches/tiktok/feedfilter/patch/TiktokFeedFilter.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,51 @@ | ||
package app.revanced.patches.tiktok.feedfilter.patch | ||
|
||
import app.revanced.patcher.annotation.Description | ||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.data.impl.BytecodeData | ||
import app.revanced.patcher.extensions.addInstruction | ||
import app.revanced.patcher.patch.PatchResult | ||
import app.revanced.patcher.patch.PatchResultSuccess | ||
import app.revanced.patcher.patch.annotations.DependsOn | ||
import app.revanced.patcher.patch.annotations.Patch | ||
import app.revanced.patcher.patch.impl.BytecodePatch | ||
import app.revanced.patches.tiktok.feedfilter.annotations.FeedFilterCompatibility | ||
import app.revanced.patches.tiktok.feedfilter.fingerprints.FeedApiServiceLIZFingerprint | ||
import app.revanced.patches.tiktok.misc.integrations.patch.TikTokIntegrationsPatch | ||
import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsStatusLoadFingerprint | ||
import app.revanced.patches.tiktok.misc.settings.patch.TikTokSettingsPatch | ||
import org.jf.dexlib2.Opcode | ||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction | ||
|
||
@Patch | ||
@DependsOn([TikTokIntegrationsPatch::class, TikTokSettingsPatch::class]) | ||
@Name("tiktok-feed-filter") | ||
@Description("Filters tiktok videos: removing ads, removing livestreams.") | ||
@FeedFilterCompatibility | ||
@Version("0.0.1") | ||
class TiktokFeedFilter : BytecodePatch( | ||
listOf( | ||
FeedApiServiceLIZFingerprint, | ||
SettingsStatusLoadFingerprint | ||
) | ||
) { | ||
override fun execute(data: BytecodeData): PatchResult { | ||
val method = FeedApiServiceLIZFingerprint.result!!.mutableMethod | ||
for ((index, instruction) in method.implementation!!.instructions.withIndex()) { | ||
if (instruction.opcode != Opcode.RETURN_OBJECT) continue | ||
val feedItemsRegister = (instruction as OneRegisterInstruction).registerA | ||
method.addInstruction( | ||
index, | ||
"invoke-static {v$feedItemsRegister}, Lapp/revanced/tiktok/feedfilter/FeedItemsFilter;->filter(Lcom/ss/android/ugc/aweme/feed/model/FeedItemList;)V" | ||
) | ||
break | ||
} | ||
val method2 = SettingsStatusLoadFingerprint.result!!.mutableMethod | ||
method2.addInstruction( | ||
0, | ||
"invoke-static {}, Lapp/revanced/tiktok/settingsmenu/SettingsStatus;->enableFeedFilter()V" | ||
) | ||
return PatchResultSuccess() | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...app/revanced/patches/tiktok/misc/forcelogin/annotations/DisableForceLoginCompatibility.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.tiktok.misc.forcelogin.annotations | ||
|
||
import app.revanced.patcher.annotation.Compatibility | ||
import app.revanced.patcher.annotation.Package | ||
|
||
@Compatibility( | ||
[ | ||
Package("com.ss.android.ugc.trill"), | ||
Package("com.zhiliaoapp.musically") | ||
] | ||
) | ||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
internal annotation class DisableForceLoginCompatibility |
18 changes: 18 additions & 0 deletions
18
.../revanced/patches/tiktok/misc/forcelogin/fingerprints/MandatoryLoginServiceFingerprint.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,18 @@ | ||
package app.revanced.patches.tiktok.misc.forcelogin.fingerprints | ||
|
||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.tiktok.misc.forcelogin.annotations.DisableForceLoginCompatibility | ||
|
||
@Name("mandatory-login-service-fingerprint") | ||
@MatchingMethod("/MandatoryLoginService;", "enableForcedLogin") | ||
@DisableForceLoginCompatibility | ||
@Version("0.0.1") | ||
object MandatoryLoginServiceFingerprint : MethodFingerprint( | ||
customFingerprint = { methodDef -> | ||
methodDef.definingClass.endsWith("/MandatoryLoginService;") && | ||
methodDef.name == "enableForcedLogin" | ||
} | ||
) |
18 changes: 18 additions & 0 deletions
18
...revanced/patches/tiktok/misc/forcelogin/fingerprints/MandatoryLoginServiceFingerprint2.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,18 @@ | ||
package app.revanced.patches.tiktok.misc.forcelogin.fingerprints | ||
|
||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.tiktok.misc.forcelogin.annotations.DisableForceLoginCompatibility | ||
|
||
@Name("mandatory-login-service-fingerprint2") | ||
@MatchingMethod("/MandatoryLoginService;", "shouldShowForcedLogin") | ||
@DisableForceLoginCompatibility | ||
@Version("0.0.1") | ||
object MandatoryLoginServiceFingerprint2 : MethodFingerprint( | ||
customFingerprint = { methodDef -> | ||
methodDef.definingClass.endsWith("/MandatoryLoginService;") && | ||
methodDef.name == "shouldShowForcedLogin" | ||
} | ||
) |
43 changes: 43 additions & 0 deletions
43
src/main/kotlin/app/revanced/patches/tiktok/misc/forcelogin/patch/DisableForceLoginPatch.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,43 @@ | ||
package app.revanced.patches.tiktok.misc.forcelogin.patch | ||
|
||
import app.revanced.patcher.annotation.Description | ||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.data.impl.BytecodeData | ||
import app.revanced.patcher.extensions.addInstructions | ||
import app.revanced.patcher.patch.PatchResult | ||
import app.revanced.patcher.patch.PatchResultSuccess | ||
import app.revanced.patcher.patch.annotations.Patch | ||
import app.revanced.patcher.patch.impl.BytecodePatch | ||
import app.revanced.patches.tiktok.misc.forcelogin.annotations.DisableForceLoginCompatibility | ||
import app.revanced.patches.tiktok.misc.forcelogin.fingerprints.MandatoryLoginServiceFingerprint | ||
import app.revanced.patches.tiktok.misc.forcelogin.fingerprints.MandatoryLoginServiceFingerprint2 | ||
|
||
@Patch | ||
@Name("tiktok-force-login") | ||
@Description("Do not force login.") | ||
@DisableForceLoginCompatibility | ||
@Version("0.0.1") | ||
class DisableForceLoginPatch : BytecodePatch( | ||
listOf( | ||
MandatoryLoginServiceFingerprint, | ||
MandatoryLoginServiceFingerprint2 | ||
) | ||
) { | ||
override fun execute(data: BytecodeData): PatchResult { | ||
listOf( | ||
MandatoryLoginServiceFingerprint, | ||
MandatoryLoginServiceFingerprint2 | ||
).forEach { fingerprint -> | ||
val method = fingerprint.result!!.mutableMethod | ||
method.addInstructions( | ||
0, | ||
""" | ||
const/4 v0, 0x0 | ||
return v0 | ||
""" | ||
) | ||
} | ||
return PatchResultSuccess() | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
.../revanced/patches/tiktok/misc/integrations/annotations/TikTokIntegrationsCompatibility.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.tiktok.misc.integrations.annotations | ||
|
||
import app.revanced.patcher.annotation.Compatibility | ||
import app.revanced.patcher.annotation.Package | ||
|
||
@Compatibility( | ||
[ | ||
Package("com.ss.android.ugc.trill"), | ||
Package("com.zhiliaoapp.musically") | ||
] | ||
) | ||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
internal annotation class TikTokIntegrationsCompatibility |
20 changes: 20 additions & 0 deletions
20
...main/kotlin/app/revanced/patches/tiktok/misc/integrations/fingerprints/InitFingerprint.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,20 @@ | ||
package app.revanced.patches.tiktok.misc.integrations.fingerprints | ||
|
||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.tiktok.misc.integrations.annotations.TikTokIntegrationsCompatibility | ||
|
||
@Name("init-fingerprint") | ||
@MatchingMethod( | ||
"Lcom/ss/android/ugc/aweme/app/host/AwemeHostApplication;", "onCreate" | ||
) | ||
@TikTokIntegrationsCompatibility | ||
@Version("0.0.1") | ||
object InitFingerprint : MethodFingerprint( | ||
customFingerprint = { methodDef -> | ||
methodDef.definingClass.endsWith("/AwemeHostApplication;") && | ||
methodDef.name == "onCreate" | ||
} | ||
) |
38 changes: 38 additions & 0 deletions
38
...ain/kotlin/app/revanced/patches/tiktok/misc/integrations/patch/TikTokIntegrationsPatch.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,38 @@ | ||
package app.revanced.patches.tiktok.misc.integrations.patch | ||
|
||
import app.revanced.patcher.annotation.Description | ||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.data.impl.BytecodeData | ||
import app.revanced.patcher.extensions.addInstruction | ||
import app.revanced.patcher.patch.PatchResult | ||
import app.revanced.patcher.patch.PatchResultError | ||
import app.revanced.patcher.patch.PatchResultSuccess | ||
import app.revanced.patcher.patch.impl.BytecodePatch | ||
import app.revanced.patches.tiktok.misc.integrations.annotations.TikTokIntegrationsCompatibility | ||
import app.revanced.patches.tiktok.misc.integrations.fingerprints.InitFingerprint | ||
|
||
@Name("tiktok-integrations") | ||
@Description("Applies mandatory patches to implement the ReVanced integrations into the application.") | ||
@TikTokIntegrationsCompatibility | ||
@Version("0.0.1") | ||
class TikTokIntegrationsPatch : BytecodePatch( | ||
listOf( | ||
InitFingerprint | ||
) | ||
) { | ||
override fun execute(data: BytecodeData): PatchResult { | ||
if (data.findClass("Lapp/revanced/tiktok/utils/ReVancedUtils") == null) | ||
return PatchResultError("Integrations have not been merged yet. This patch can not succeed without the integrations.") | ||
val result = InitFingerprint.result!! | ||
|
||
val method = result.mutableMethod | ||
val implementation = method.implementation!! | ||
val count = implementation.registerCount - 1 | ||
|
||
method.addInstruction( | ||
0, "sput-object v$count, Lapp/revanced/tiktok/utils/ReVancedUtils;->context:Landroid/content/Context;" | ||
) | ||
return PatchResultSuccess() | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...tlin/app/revanced/patches/tiktok/misc/settings/annotations/TikTokSettingsCompatibility.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.tiktok.misc.settings.annotations | ||
|
||
import app.revanced.patcher.annotation.Compatibility | ||
import app.revanced.patcher.annotation.Package | ||
|
||
@Compatibility( | ||
[ | ||
Package("com.ss.android.ugc.trill"), | ||
Package("com.zhiliaoapp.musically") | ||
] | ||
) | ||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
internal annotation class TikTokSettingsCompatibility |
21 changes: 21 additions & 0 deletions
21
...evanced/patches/tiktok/misc/settings/fingerprints/AdPersonalizationActivityFingerprint.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,21 @@ | ||
package app.revanced.patches.tiktok.misc.settings.fingerprints | ||
|
||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.tiktok.misc.settings.annotations.TikTokSettingsCompatibility | ||
|
||
@Name("ad-personalization-activity-fingerprint") | ||
@MatchingMethod( | ||
"Lcom/bytedance/ies/ugc/aweme/commercialize/compliance/personalization/AdPersonalizationActivity;", | ||
"onCreate" | ||
) | ||
@TikTokSettingsCompatibility | ||
@Version("0.0.1") | ||
object AdPersonalizationActivityFingerprint : MethodFingerprint( | ||
customFingerprint = { methodDef -> | ||
methodDef.definingClass.endsWith("/AdPersonalizationActivity;") && | ||
methodDef.name == "onCreate" | ||
} | ||
) |
21 changes: 21 additions & 0 deletions
21
.../revanced/patches/tiktok/misc/settings/fingerprints/CopyRightSettingsStringFingerprint.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,21 @@ | ||
package app.revanced.patches.tiktok.misc.settings.fingerprints | ||
|
||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.tiktok.misc.settings.annotations.TikTokSettingsCompatibility | ||
|
||
@Name("copyright-settings-string-fingerprint") | ||
@MatchingMethod( | ||
"Lcom/ss/android/ugc/aweme/setting/ui/SettingNewVersionFragment;", | ||
"onViewCreated" | ||
) | ||
@TikTokSettingsCompatibility | ||
@Version("0.0.1") | ||
object CopyRightSettingsStringFingerprint : MethodFingerprint( | ||
customFingerprint = { methodDef -> | ||
methodDef.definingClass.endsWith("/SettingNewVersionFragment;") && | ||
methodDef.name == "onViewCreated" | ||
} | ||
) |
21 changes: 21 additions & 0 deletions
21
...n/app/revanced/patches/tiktok/misc/settings/fingerprints/SettingsStatusLoadFingerprint.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,21 @@ | ||
package app.revanced.patches.tiktok.misc.settings.fingerprints | ||
|
||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.tiktok.misc.settings.annotations.TikTokSettingsCompatibility | ||
|
||
@Name("settings-status-load-fingerprint") | ||
@MatchingMethod( | ||
"Lapp/revanced/tiktok/settingsmenu/SettingsStatus;", | ||
"load" | ||
) | ||
@TikTokSettingsCompatibility | ||
@Version("0.0.1") | ||
object SettingsStatusLoadFingerprint : MethodFingerprint( | ||
customFingerprint = { methodDef -> | ||
methodDef.definingClass.endsWith("Lapp/revanced/tiktok/settingsmenu/SettingsStatus;") && | ||
methodDef.name == "load" | ||
} | ||
) |
Oops, something went wrong.