Skip to content

Commit

Permalink
Improve contents blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
Chipppppppppp committed Jan 23, 2024
1 parent dda5866 commit d6b50ad
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions app/src/main/java/io/github/chipppppppppp/lime/Main.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.chipppppppppp.lime;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Canvas;
import android.net.Uri;
Expand Down Expand Up @@ -81,11 +82,29 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedHelpers.findAndHookMethod(hookTarget, "onAttachedToWindow", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
View view = ((View) ((View) param.thisObject).getParent().getParent().getParent());
View view = (View) param.thisObject;
view.setVisibility(View.GONE);
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
layoutParams.height = 0;
view.setLayoutParams(layoutParams);

view = (View) ((View) param.thisObject).getParent();
view.setVisibility(View.GONE);
layoutParams = view.getLayoutParams();
layoutParams.height = 0;
view.setLayoutParams(layoutParams);

view = (View) ((View) param.thisObject).getParent().getParent();
view.setVisibility(View.GONE);
layoutParams = view.getLayoutParams();
layoutParams.height = 0;
view.setLayoutParams(layoutParams);

view = (View) ((View) param.thisObject).getParent().getParent().getParent();
view.setVisibility(View.GONE);
layoutParams = view.getLayoutParams();
layoutParams.height = 0;
view.setLayoutParams(layoutParams);
}
});

Expand All @@ -107,10 +126,20 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
};
for (String adClassName : adClassNames) {
hookTarget = lparam.classLoader.loadClass(adClassName);
XposedBridge.hookAllConstructors(hookTarget, new XC_MethodHook() {
XposedBridge.hookAllMethods(hookTarget, "onAttachedToWindow", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
((View) param.thisObject).setVisibility(View.GONE);
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
View view = (View) param.thisObject;
view.setVisibility(View.GONE);
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
layoutParams.height = 0;
view.setLayoutParams(layoutParams);

view = (View) ((View) param.thisObject).getParent();
view.setVisibility(View.GONE);
layoutParams = view.getLayoutParams();
layoutParams.height = 0;
view.setLayoutParams(layoutParams);
}
});
}
Expand All @@ -122,9 +151,8 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
View view = (View) param.thisObject;
if (!(view.getContext() instanceof Activity)) return;
Activity activity = (Activity) view.getContext();
int recommendationResId = activity.getResources().getIdentifier("home_tab_contents_recommendation_placement", "id", activity.getPackageName());
Context context = view.getContext();
int recommendationResId = context.getResources().getIdentifier("home_tab_contents_recommendation_placement", "id", context.getPackageName());
if (view.getId() == recommendationResId) view.setVisibility(View.GONE);
}
});
Expand Down

0 comments on commit d6b50ad

Please sign in to comment.