Skip to content

Commit

Permalink
adClassNames を自動で検知して追加するように変更 (#172)
Browse files Browse the repository at this point in the history
Co-authored-by: Syuugo <[email protected]>
  • Loading branch information
areteruhiro and s1204IT authored Oct 6, 2024
1 parent 0d6c9f4 commit 991138e
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 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,23 +16,8 @@
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"
);

List<String> adClassNames;

@Override
public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
Expand Down Expand Up @@ -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),
Expand All @@ -94,7 +100,6 @@ public void onGlobalLayout() {
}
}
});

}
}
);
Expand Down

0 comments on commit 991138e

Please sign in to comment.