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

Commit

Permalink
feat: update PurgeMy
Browse files Browse the repository at this point in the history
  • Loading branch information
mkx173 committed Feb 16, 2024
1 parent e1a5f56 commit 1d93ae1
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 31 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ android {
minSdk 28
targetSdk sdk
versionCode gitCommitCount
versionName '2.9.2'
versionName '2.9.3'

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
externalNativeBuild {
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/gm/tieba/tabswitch/XposedInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import gm.tieba.tabswitch.hooker.eliminate.PersonalizedFilter;
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.RedTip;
import gm.tieba.tabswitch.hooker.eliminate.RemoveUpdate;
import gm.tieba.tabswitch.hooker.eliminate.SwitchManager;
Expand Down Expand Up @@ -109,7 +110,7 @@ protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
new SwitchManager(),
new Purge(),
new PurgeEnter(),
// new PurgeMy(),
new PurgeMy(),
new RedTip(),
new FollowFilter(),
new PersonalizedFilter(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private LinearLayout createRootPreference(final Activity activity) {
}
preferenceLayout.addView(new SwitchButtonHolder(activity, "净化进吧", "purge_enter", SwitchButtonHolder.TYPE_SWITCH));
preferenceLayout.addView(new SwitchButtonHolder(activity, "净化置顶帖", "fold_top_card_view", SwitchButtonHolder.TYPE_SWITCH));
// preferenceLayout.addView(new SwitchButtonHolder(activity, "净化我的", "purge_my", SwitchButtonHolder.TYPE_SWITCH));
preferenceLayout.addView(new SwitchButtonHolder(activity, "净化我的", "purge_my", 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));
Expand Down
67 changes: 39 additions & 28 deletions app/src/main/java/gm/tieba/tabswitch/hooker/eliminate/PurgeMy.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import androidx.annotation.NonNull;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

Expand All @@ -16,9 +17,10 @@
import gm.tieba.tabswitch.hooker.IHooker;
import gm.tieba.tabswitch.hooker.Obfuscated;
import gm.tieba.tabswitch.hooker.deobfuscation.Matcher;
import gm.tieba.tabswitch.hooker.deobfuscation.SmaliMatcher;
import gm.tieba.tabswitch.hooker.deobfuscation.StringMatcher;
import gm.tieba.tabswitch.util.ReflectUtils;

@Deprecated
public class PurgeMy extends XposedContext implements IHooker, Obfuscated {

@NonNull
Expand All @@ -27,43 +29,52 @@ public String key() {
return "purge_my";
}

private final int mGridTopPadding = (int) ReflectUtils.getDimen("tbds25");

@Override
public List<? extends Matcher> matchers() {
return null;
return List.of(
new SmaliMatcher("Lcom/baidu/tieba/personCenter/view/PersonOftenFuncItemView;-><init>(Landroid/content/Context;)V")
);
}

@Override
public void hook() throws Throwable {
XposedHelpers.findAndHookMethod("tbclient.Profile.DataRes$Builder", sClassLoader, "build", boolean.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
// 我的贴吧会员
XposedHelpers.setObjectField(param.thisObject, "vip_banner", null);

// 横幅广告
XposedHelpers.setObjectField(param.thisObject, "banner", new ArrayList<>());

// 度小满 有钱花
XposedHelpers.setObjectField(param.thisObject, "finance_tab", null);

// 小程序
XposedHelpers.setObjectField(param.thisObject, "recom_naws_list", new ArrayList<>());
}
});
XposedHelpers.findAndHookMethod("tbclient.User$Builder", sClassLoader, "build", boolean.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
// 贴吧成长等级
XposedHelpers.setObjectField(param.thisObject, "user_growth", null);
}
});
// Add padding to the top of 常用功能
AcRules.findRule(matchers(), (matcher, clazz, method) -> {
switch (matcher) {
case "Lcom/baidu/tieba/R$drawable;->icon_pure_topbar_store44_svg:I": // 商店
XposedHelpers.findAndHookMethod(clazz, sClassLoader, method, int.class, new XC_MethodHook() {
XposedBridge.hookAllConstructors(
XposedHelpers.findClass(clazz, sClassLoader),
new XC_MethodHook() {
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
// R.id.person_navigation_dressup_img
final var imageView = (ImageView) ReflectUtils.getObjectField(param.thisObject, 4);
imageView.setVisibility(View.GONE);
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
View mView = ReflectUtils.getObjectField(param.thisObject, View.class);
mView.setPadding(mView.getPaddingLeft(), mGridTopPadding, mView.getPaddingRight(), 0);
}
});
break;
case "Lcom/baidu/tieba/R$drawable;->person_center_red_tip_shape:I": // 分割线
if ("com.baidu.tieba.post.PersonPostActivity".equals(clazz)) {
break;
}
for (final var md : XposedHelpers.findClass(clazz, sClassLoader).getDeclaredMethods()) {
if (Arrays.toString(md.getParameterTypes()).equals("[interface com.baidu.tbadk.TbPageContext, int]")) {
XposedBridge.hookMethod(md, new XC_MethodHook() {
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
// R.id.function_item_bottom_divider
final var view = (View) ReflectUtils.getObjectField(param.thisObject, 10);
view.setVisibility(View.GONE);
}
});
}
}
break;
}
);
});
}
}

0 comments on commit 1d93ae1

Please sign in to comment.