fix(TikTok - Feed filter): Hide ads in following feed (#4844)

This commit is contained in:
Jaimy Smets
2025-04-26 15:49:28 +02:00
committed by GitHub
parent f925479a93
commit c255ac18e0
5 changed files with 71 additions and 19 deletions

View File

@ -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",
)
}
}

View File

@ -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
)
}