From 3eb17d9e2662e7d4789f646f626ea86ae0c4e214 Mon Sep 17 00:00:00 2001 From: mkx173 Date: Fri, 12 Apr 2024 20:15:05 -0700 Subject: [PATCH] feat: update purge rules --- app/build.gradle | 3 +- app/src/main/assets/PurgeFrsBottom.js | 1 + .../java/gm/tieba/tabswitch/XposedInit.java | 1 - .../tabswitch/hooker/eliminate/Purge.java | 65 ++++++++++++++----- gradle.properties | 3 +- 5 files changed, 51 insertions(+), 22 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4c908d38..2e4ffa03 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' @@ -59,6 +59,7 @@ android { } buildFeatures { prefab true + buildConfig true } lint { checkDependencies true diff --git a/app/src/main/assets/PurgeFrsBottom.js b/app/src/main/assets/PurgeFrsBottom.js index b52d76b9..3bed7ebc 100644 --- a/app/src/main/assets/PurgeFrsBottom.js +++ b/app/src/main/assets/PurgeFrsBottom.js @@ -16,6 +16,7 @@ "card_activity", "ai_chatroom_guide", "friend_forum", + "game_card_guide" ]; propertiesToDelete.forEach((property) => { delete res[property]; diff --git a/app/src/main/java/gm/tieba/tabswitch/XposedInit.java b/app/src/main/java/gm/tieba/tabswitch/XposedInit.java index 8d0f9127..dd585e27 100644 --- a/app/src/main/java/gm/tieba/tabswitch/XposedInit.java +++ b/app/src/main/java/gm/tieba/tabswitch/XposedInit.java @@ -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", diff --git a/app/src/main/java/gm/tieba/tabswitch/hooker/eliminate/Purge.java b/app/src/main/java/gm/tieba/tabswitch/hooker/eliminate/Purge.java index 0a0a593e..59c12c83 100644 --- a/app/src/main/java/gm/tieba/tabswitch/hooker/eliminate/Purge.java +++ b/app/src/main/java/gm/tieba/tabswitch/hooker/eliminate/Purge.java @@ -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; @@ -49,13 +50,13 @@ public List matchers() { new SmaliMatcher("Lcom/baidu/tieba/lego/card/model/BaseCardInfo;->(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;->(Landroid/content/Context;)V"), new SmaliMatcher("Lcom/baidu/tbadk/editortools/meme/pan/SpriteMemePan;->(Landroid/content/Context;)V"), - new StringMatcher("h5_pop_ups_config") + new StringMatcher("h5_pop_ups_config"), + new StringMatcher("sign_max_num") ); } @@ -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() { @@ -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); @@ -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; } }); // 启动广告 @@ -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) diff --git a/gradle.properties b/gradle.properties index 44c2bf3f..9ade8f71 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 @@ -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