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

Commit

Permalink
feat: update purge rules
Browse files Browse the repository at this point in the history
  • Loading branch information
mkx173 committed Apr 13, 2024
1 parent 49f1b1c commit 3eb17d9
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 22 deletions.
3 changes: 2 additions & 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.8'
buildConfigField "String", "TARGET_VERSION", "\"12.59.0.1\""
buildConfigField "String", "TARGET_VERSION", "\"12.59.0.3\""
buildConfigField "String", "MIN_VERSION", "\"12.53.1.0\""

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
Expand Down Expand Up @@ -59,6 +59,7 @@ android {
}
buildFeatures {
prefab true
buildConfig true
}
lint {
checkDependencies true
Expand Down
1 change: 1 addition & 0 deletions app/src/main/assets/PurgeFrsBottom.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"card_activity",
"ai_chatroom_guide",
"friend_forum",
"game_card_guide"
];
propertiesToDelete.forEach((property) => {
delete res[property];
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/gm/tieba/tabswitch/XposedInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
// However, LSPatch incorrectly sets appComponentFactory to null, causing android.app.Instrumentation.getFactory to fall back to AppComponentFactory.DEFAULT
// (see https://github.com/LSPosed/LSPatch/blob/bbe8d93fb9230f7b04babaf1c4a11642110f55a6/patch-loader/src/main/java/org/lsposed/lspatch/loader/LSPApplication.java#L173)
if (getContext().getApplicationInfo().appComponentFactory == null) {
XposedBridge.log("Applying AppComponentFactory workaround");
XposedHelpers.findAndHookMethod(
Instrumentation.class,
"getFactory",
Expand Down
65 changes: 47 additions & 18 deletions app/src/main/java/gm/tieba/tabswitch/hooker/eliminate/Purge.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import gm.tieba.tabswitch.dao.AcRules;
import gm.tieba.tabswitch.hooker.IHooker;
import gm.tieba.tabswitch.hooker.Obfuscated;
import gm.tieba.tabswitch.hooker.deobfuscation.DeobfuscationHelper;
import gm.tieba.tabswitch.hooker.deobfuscation.Matcher;
import gm.tieba.tabswitch.hooker.deobfuscation.SmaliMatcher;
import gm.tieba.tabswitch.hooker.deobfuscation.StringMatcher;
Expand All @@ -49,13 +50,13 @@ public List<? extends Matcher> matchers() {
new SmaliMatcher("Lcom/baidu/tieba/lego/card/model/BaseCardInfo;-><init>(Lorg/json/JSONObject;)V"),
new StringMatcher("pic_amount"),
new StringMatcher("准备展示精灵动画提示控件"),
// new StringMatcher("TbChannelJsInterfaceNew"),
new StringMatcher("bottom_bubble_config"),
// new StringMatcher("top_level_navi"),
new StringMatcher("index_tab_info"),
new SmaliMatcher("Lcom/baidu/tbadk/coreExtra/floatCardView/AlaLiveTipView;-><init>(Landroid/content/Context;)V"),
new SmaliMatcher("Lcom/baidu/tbadk/editortools/meme/pan/SpriteMemePan;-><init>(Landroid/content/Context;)V"),
new StringMatcher("h5_pop_ups_config")
new StringMatcher("h5_pop_ups_config"),
new StringMatcher("sign_max_num")
);
}

Expand All @@ -77,18 +78,6 @@ public void hook() throws Throwable {
case "准备展示精灵动画提示控件": // 吧内%s新贴热议中
XposedBridge.hookAllMethods(XposedHelpers.findClass(clazz, sClassLoader), method, XC_MethodReplacement.returnConstant(false));
break;
// case "TbChannelJsInterfaceNew": // 吧友直播
// if (method.equals("getInitData")) {
// XposedHelpers.findAndHookMethod(clazz, sClassLoader, method, new XC_MethodHook() {
// @Override
// protected void afterHookedMethod(MethodHookParam param) throws Throwable {
// JSONObject resultJson = new JSONObject((String) param.getResult());
// resultJson.getJSONObject("baseData").put("clientVersion", "undefined");
// param.setResult(resultJson.toString());
// }
// });
// }
// break;
case "bottom_bubble_config": // 底部导航栏活动图标
if (method.equals("invoke")) {
XposedHelpers.findAndHookMethod(clazz, sClassLoader, method, new XC_MethodHook() {
Expand Down Expand Up @@ -119,10 +108,19 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
JSONObject syncData = ReflectUtils.getObjectField(param.thisObject, JSONObject.class);
JSONArray indexTabInfo = syncData.getJSONArray("index_tab_info");
JSONArray newIndexTabInfo = new JSONArray();
for (int i = 0; i < indexTabInfo.length(); i++) {
JSONObject currTab = indexTabInfo.getJSONObject(i);
if (!currTab.getString("tab_type").equals("202") && !currTab.getString("tab_type").equals("6")) {
newIndexTabInfo.put(currTab);
if (DeobfuscationHelper.isTbSatisfyVersionRequirement("12.59", DeobfuscationHelper.getTbVersion(getContext()))) {
for (int i = 0; i < indexTabInfo.length(); i++) {
JSONObject currTab = indexTabInfo.getJSONObject(i);
if (currTab.getString("is_main_tab").equals("1") && !currTab.getString("tab_type").equals("6")) {
newIndexTabInfo.put(currTab);
}
}
} else {
for (int i = 0; i < indexTabInfo.length(); i++) {
JSONObject currTab = indexTabInfo.getJSONObject(i);
if (!currTab.getString("tab_type").equals("202") && !currTab.getString("tab_type").equals("6")) {
newIndexTabInfo.put(currTab);
}
}
}
syncData.put("index_tab_info", newIndexTabInfo);
Expand Down Expand Up @@ -150,6 +148,15 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
});
}
break;
case "sign_max_num": // 一键签到弹窗广告
XposedHelpers.findAndHookMethod(clazz, sClassLoader, method, JSONObject.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
JSONObject jsonObject = (JSONObject) param.args[0];
jsonObject.put("advert", null);
}
});
break;
}
});
// 启动广告
Expand Down Expand Up @@ -390,6 +397,28 @@ protected void beforeHookedMethod(final MethodHookParam param) throws Throwable
XposedHelpers.setObjectField(param.thisObject, "novel_recom_card", null);
}
});

// 首页样式 AB test
XposedHelpers.findAndHookMethod(
"com.baidu.tbadk.abtest.UbsABTestDataManager",
sClassLoader,
"parseJSONArray",
JSONArray.class,
new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
JSONArray currentABTestJson = (JSONArray) param.args[0];
JSONArray newABTestJson = new JSONArray();
for (int i = 0; i < currentABTestJson.length(); i++) {
JSONObject currTest = currentABTestJson.getJSONObject(i);
if (!currTest.getString("sid").startsWith("12_57_5_home_search")) {
newABTestJson.put(currTest);
}
}
param.args[0] = newABTestJson;
}
}
);
}

// 吧页面头条贴(41), 直播贴(69 / is_live_card)
Expand Down
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
android.enableJetifier=false
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
Expand All @@ -26,5 +26,4 @@ android.nonTransitiveRClass=true
android.experimental.enableNewResourceShrinker=true
android.experimental.enableNewResourceShrinker.preciseShrinking=true
android.enableR8.fullMode=true
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false

0 comments on commit 3eb17d9

Please sign in to comment.