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..0618d7a3 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,28 +16,16 @@ 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" - ); + + static final List adClassNames = new ArrayList<>(List.of( + + )); @Override public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { if (!limeOptions.removeAds.checked) return; + XposedBridge.hookAllMethods( loadPackageParam.classLoader.loadClass(Constants.REQUEST_HOOK.className), Constants.REQUEST_HOOK.methodName, @@ -51,6 +40,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { } ); + XposedHelpers.findAndHookMethod( loadPackageParam.classLoader.loadClass("com.linecorp.line.admolin.smartch.v2.view.SmartChannelViewLayout"), "dispatchDraw", @@ -63,6 +53,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { } ); + XposedHelpers.findAndHookMethod( loadPackageParam.classLoader.loadClass("com.linecorp.line.ladsdk.ui.common.view.lifecycle.LadAdView"), "onAttachedToWindow", @@ -78,6 +69,36 @@ 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,12 +115,12 @@ public void onGlobalLayout() { } } }); - } } ); } + XposedHelpers.findAndHookMethod( loadPackageParam.classLoader.loadClass(Constants.WEBVIEW_CLIENT_HOOK.className), Constants.WEBVIEW_CLIENT_HOOK.methodName,