Skip to content

Commit

Permalink
Update RemoveAds.java
Browse files Browse the repository at this point in the history
  • Loading branch information
areteruhiro authored Sep 28, 2024
1 parent 8761751 commit 868ed3e
Showing 1 changed file with 39 additions and 18 deletions.
57 changes: 39 additions & 18 deletions app/src/main/java/io/github/chipppppppppp/lime/hooks/RemoveAds.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,28 +16,16 @@
import io.github.chipppppppppp.lime.LimeOptions;

public class RemoveAds implements IHook {
static final List<String> 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<String> 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,
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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),
Expand All @@ -94,12 +115,12 @@ public void onGlobalLayout() {
}
}
});

}
}
);
}


XposedHelpers.findAndHookMethod(
loadPackageParam.classLoader.loadClass(Constants.WEBVIEW_CLIENT_HOOK.className),
Constants.WEBVIEW_CLIENT_HOOK.methodName,
Expand Down

0 comments on commit 868ed3e

Please sign in to comment.