mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-06-12 13:17:38 +02:00
fix(TikTok - Feed filter): Hide ads in following feed (#4844)
This commit is contained in:
@ -9,6 +9,8 @@ import app.revanced.patches.tiktok.misc.settings.settingsStatusLoadFingerprint
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/tiktok/feedfilter/FeedItemsFilter;"
|
||||
|
||||
@Suppress("unused")
|
||||
val feedFilterPatch = bytecodePatch(
|
||||
name = "Feed filter",
|
||||
@ -26,14 +28,15 @@ val feedFilterPatch = bytecodePatch(
|
||||
)
|
||||
|
||||
execute {
|
||||
feedApiServiceLIZFingerprint.method.apply {
|
||||
val returnFeedItemInstruction = instructions.first { it.opcode == Opcode.RETURN_OBJECT }
|
||||
val feedItemsRegister = (returnFeedItemInstruction as OneRegisterInstruction).registerA
|
||||
|
||||
addInstruction(
|
||||
returnFeedItemInstruction.location.index,
|
||||
"invoke-static { v$feedItemsRegister }, " +
|
||||
"Lapp/revanced/extension/tiktok/feedfilter/FeedItemsFilter;->filter(Lcom/ss/android/ugc/aweme/feed/model/FeedItemList;)V",
|
||||
arrayOf(
|
||||
feedApiServiceLIZFingerprint.method to "$EXTENSION_CLASS_DESCRIPTOR->filter(Lcom/ss/android/ugc/aweme/feed/model/FeedItemList;)V",
|
||||
followFeedFingerprint.method to "$EXTENSION_CLASS_DESCRIPTOR->filter(Lcom/ss/android/ugc/aweme/follow/presenter/FollowFeedList;)V"
|
||||
).forEach { (method, filterSignature) ->
|
||||
val returnInstruction = method.instructions.first { it.opcode == Opcode.RETURN_OBJECT }
|
||||
val register = (returnInstruction as OneRegisterInstruction).registerA
|
||||
method.addInstruction(
|
||||
returnInstruction.location.index,
|
||||
"invoke-static { v$register }, $filterSignature"
|
||||
)
|
||||
}
|
||||
|
||||
@ -42,4 +45,5 @@ val feedFilterPatch = bytecodePatch(
|
||||
"invoke-static {}, Lapp/revanced/extension/tiktok/settings/SettingsStatus;->enableFeedFilter()V",
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,22 @@
|
||||
package app.revanced.patches.tiktok.feedfilter
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal val feedApiServiceLIZFingerprint = fingerprint {
|
||||
custom { method, classDef ->
|
||||
classDef.endsWith("/FeedApiService;") && method.name == "fetchFeedList"
|
||||
}
|
||||
}
|
||||
|
||||
internal val followFeedFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC)
|
||||
returns("Lcom/ss/android/ugc/aweme/follow/presenter/FollowFeedList;")
|
||||
strings("getFollowFeedList")
|
||||
opcodes(
|
||||
Opcode.INVOKE_INTERFACE_RANGE,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_INTERFACE
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user