Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
feat: remove video from personalized feed
Browse files Browse the repository at this point in the history
  • Loading branch information
mkx173 committed Mar 26, 2024
1 parent 77daec6 commit 3ef61ee
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android {
targetSdk sdk
versionCode gitCommitCount
versionName '2.9.6'
buildConfigField "String", "TARGET_VERSION", "\"12.57.0.1\""
buildConfigField "String", "TARGET_VERSION", "\"12.57.5.0\""

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
externalNativeBuild {
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/gm/tieba/tabswitch/XposedInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import gm.tieba.tabswitch.hooker.eliminate.Purge;
import gm.tieba.tabswitch.hooker.eliminate.PurgeEnter;
import gm.tieba.tabswitch.hooker.eliminate.PurgeMy;
import gm.tieba.tabswitch.hooker.eliminate.PurgeVideo;
import gm.tieba.tabswitch.hooker.eliminate.RedTip;
import gm.tieba.tabswitch.hooker.eliminate.RemoveUpdate;
import gm.tieba.tabswitch.hooker.extra.ForbidGesture;
Expand Down Expand Up @@ -152,7 +153,8 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
new RemoveUpdate(),
new FoldTopCardView(),
new MsgCenterTab(),
new NotificationDetect()
new NotificationDetect(),
new PurgeVideo()
);
final var matchers = new ArrayList<Obfuscated>(hookers.size() + 2);
matchers.add(new TbDialog());
Expand Down
24 changes: 20 additions & 4 deletions app/src/main/java/gm/tieba/tabswitch/hooker/TSPreference.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,8 @@ private LinearLayout createRootPreference(final Activity activity) {
preferenceLayout.addView(new SwitchButtonHolder(activity, "净化进吧", "purge_enter", SwitchButtonHolder.TYPE_SWITCH));
preferenceLayout.addView(new SwitchButtonHolder(activity, "净化我的", "purge_my", SwitchButtonHolder.TYPE_SWITCH));
preferenceLayout.addView(new SwitchButtonHolder(activity, "净化置顶帖", "fold_top_card_view", SwitchButtonHolder.TYPE_SWITCH));
preferenceLayout.addView(new SwitchButtonHolder(activity, "隐藏小红点", "red_tip", SwitchButtonHolder.TYPE_SWITCH));
preferenceLayout.addView(new SwitchButtonHolder(activity, "禁用更新提示", "remove_update", SwitchButtonHolder.TYPE_SWITCH));
preferenceLayout.addView(new SwitchButtonHolder(activity, "只推荐已关注的吧", "follow_filter", SwitchButtonHolder.TYPE_SWITCH));
preferenceLayout.addView(new SwitchButtonHolder(activity, "屏蔽首页视频贴", "purge_video", SwitchButtonHolder.TYPE_SWITCH));
preferenceLayout.addView(new SwitchButtonHolder(activity, "过滤首页推荐", "personalized_filter", SwitchButtonHolder.TYPE_DIALOG));
preferenceLayout.addView(new SwitchButtonHolder(activity, "过滤帖子回复", "content_filter", SwitchButtonHolder.TYPE_DIALOG));
preferenceLayout.addView(new SwitchButtonHolder(activity, "过滤吧页面", "frs_page_filter", SwitchButtonHolder.TYPE_DIALOG));
Expand Down Expand Up @@ -237,6 +236,8 @@ private LinearLayout createRootPreference(final Activity activity) {
preferenceLayout.addView(originSrcOnlyWifiButton);

preferenceLayout.addView(TSPreferenceHelper.createTextView(isPurgeEnabled ? "奇怪怪" : "其它"));
preferenceLayout.addView(new SwitchButtonHolder(activity, "隐藏小红点", "red_tip", SwitchButtonHolder.TYPE_SWITCH));
preferenceLayout.addView(new SwitchButtonHolder(activity, "禁用更新提示", "remove_update", SwitchButtonHolder.TYPE_SWITCH));
preferenceLayout.addView(new SwitchButtonHolder(activity, "禁用帖子手势", "forbid_gesture", SwitchButtonHolder.TYPE_SWITCH));
preferenceLayout.addView(new SwitchButtonHolder(activity, "用赞踩差数代替赞数", "agree_num", SwitchButtonHolder.TYPE_SWITCH));
preferenceLayout.addView(new SwitchButtonHolder(activity, "禁止检测通知开启状态", "notification_detect", SwitchButtonHolder.TYPE_SWITCH));
Expand Down Expand Up @@ -269,10 +270,10 @@ private LinearLayout createRootPreference(final Activity activity) {
intent.setData(Uri.parse("https://t.me/TabSwitch"));
activity.startActivity(intent);
}));
preferenceLayout.addView(TSPreferenceHelper.createButton("版本(适配版本)", String.format(Locale.CHINA, "%s_%d (%s)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, BuildConfig.TARGET_VERSION), true, v -> {
preferenceLayout.addView(TSPreferenceHelper.createButton("版本", String.format(Locale.CHINA, "%s_%d (%s)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, abbreviateVersion(BuildConfig.TARGET_VERSION)), true, v -> {
final Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
intent.setData(Uri.parse("https://github.com/GuhDoy/TiebaTS/actions"));
intent.setData(Uri.parse("https://github.com/GuhDoy/TiebaTS/releases"));
activity.startActivity(intent);
}));
return preferenceLayout;
Expand Down Expand Up @@ -307,4 +308,19 @@ private LinearLayout createHidePreference(final Activity activity) {
TraceChecker.sChildCount = preferenceLayout.getChildCount();
return preferenceLayout;
}

private static String abbreviateVersion(String version) {
// Split the version string by dot (.)
String[] parts = version.split("\\.");

// Check if there are at least two version codes
if (parts.length >= 2) {
// Concatenate the first two version codes
return parts[0] + parts[1];
} else {
// If there are less than two version codes, return the original string
return version;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package gm.tieba.tabswitch.hooker.eliminate;

import androidx.annotation.NonNull;

import java.util.List;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import gm.tieba.tabswitch.XposedContext;
import gm.tieba.tabswitch.hooker.IHooker;

public class PurgeVideo extends XposedContext implements IHooker {
@NonNull
@Override
public String key() {
return "purge_video";
}

@Override
public void hook() throws Throwable {
XposedHelpers.findAndHookMethod("tbclient.Personalized.DataRes$Builder", sClassLoader, "build", boolean.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
final List<?> threadList = (List<?>) XposedHelpers.getObjectField(param.thisObject, "thread_list");
if (threadList == null) return;
threadList.removeIf(o -> XposedHelpers.getObjectField(o, "video_info") != null);
}
});
}
}

0 comments on commit 3ef61ee

Please sign in to comment.