From 991138e202143082aff21a2e1e628b31f3d86a61 Mon Sep 17 00:00:00 2001 From: areteruhiro <108941410+areteruhiro@users.noreply.github.com> Date: Sun, 6 Oct 2024 21:01:34 +0900 Subject: [PATCH] =?UTF-8?q?adClassNames=20=E3=82=92=E8=87=AA=E5=8B=95?= =?UTF-8?q?=E3=81=A7=E6=A4=9C=E7=9F=A5=E3=81=97=E3=81=A6=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= =?UTF-8?q?=20(#172)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Syuugo --- .../chipppppppppp/lime/hooks/RemoveAds.java | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/io/github/chipppppppppp/lime/hooks/RemoveAds.java b/app/src/main/java/io/github/chipppppppppp/lime/hooks/RemoveAds.java index 73e88384..f99e1800 100644 --- a/app/src/main/java/io/github/chipppppppppp/lime/hooks/RemoveAds.java +++ b/app/src/main/java/io/github/chipppppppppp/lime/hooks/RemoveAds.java @@ -6,6 +6,7 @@ import android.view.ViewTreeObserver; import android.webkit.WebView; +import java.util.ArrayList; import java.util.List; import de.robv.android.xposed.XC_MethodHook; @@ -15,23 +16,8 @@ import io.github.chipppppppppp.lime.LimeOptions; public class RemoveAds implements IHook { - static final List adClassNames = List.of( - "com.google.android.gms.ads.nativead.NativeAdView", - "com.linecorp.line.ladsdk.ui.inventory.album.LadAlbumImageAdView", - "com.linecorp.line.ladsdk.ui.inventory.album.LadAlbumVideoAdView", - "com.linecorp.line.ladsdk.ui.inventory.album.LadAlbumYjImageAdView", - "com.linecorp.line.ladsdk.ui.inventory.home.LadHomeBigBannerImageAdView", - "com.linecorp.line.ladsdk.ui.inventory.home.LadHomeBigBannerVideoAdView", - "com.linecorp.line.ladsdk.ui.inventory.home.LadHomeImageAdView", - "com.linecorp.line.ladsdk.ui.inventory.home.LadHomePerformanceAdView", - "com.linecorp.line.ladsdk.ui.inventory.home.LadHomeYjBigBannerAdView", - "com.linecorp.line.ladsdk.ui.inventory.home.LadHomeYjImageAdView", - "com.linecorp.line.ladsdk.ui.inventory.timeline.post.LadPostAdView", - "com.linecorp.line.ladsdk.ui.inventory.wallet.LadWalletBigBannerImageAdView", - "com.linecorp.line.ladsdk.ui.inventory.wallet.LadWalletBigBannerVideoAdView", - "com.linecorp.square.v2.view.ad.common.SquareCommonHeaderGoogleBannerAdView", - "com.linecorp.square.v2.view.ad.common.SquareCommonHeaderGoogleNativeAdView" - ); + + List adClassNames; @Override public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { @@ -77,7 +63,27 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { } } ); - + + XposedHelpers.findAndHookMethod( + ViewGroup.class, + "addView", + View.class, + ViewGroup.LayoutParams.class, + new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + View view = (View) param.args[0]; + String className = view.getClass().getName(); + if (className.contains("Ad") ) { + if (!adClassNames.contains(className)) { + adClassNames.add(className); + } + view.setVisibility(View.GONE); + } + } + } + ); + for (String adClassName : adClassNames) { XposedBridge.hookAllConstructors( loadPackageParam.classLoader.loadClass(adClassName), @@ -94,7 +100,6 @@ public void onGlobalLayout() { } } }); - } } );