Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
feat: remove ad for image viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
mkx173 committed Mar 9, 2024
1 parent 1f0a99f commit 8e45e10
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import de.robv.android.xposed.XC_MethodHook;
Expand All @@ -33,7 +32,7 @@
import kotlin.text.StringsKt;

public class SaveImages extends XposedContext implements IHooker {
private List<String> mList;
private ArrayList<String> mList;
private Field mDownloadImageViewField;

@NonNull
Expand All @@ -48,8 +47,9 @@ public void hook() throws Throwable {
);
XposedBridge.hookMethod(method, new XC_MethodHook() {
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
mList = (ArrayList<String>) param.args[0];
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
mList = new ArrayList<>((ArrayList<String>) param.args[0]);
mList.removeIf(o -> o.startsWith("####mLiveRoomPageProvider"));
}
});

Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/gm/tieba/tabswitch/hooker/eliminate/Purge.java
Original file line number Diff line number Diff line change
Expand Up @@ -417,5 +417,16 @@ protected void beforeHookedMethod(final MethodHookParam param) throws Throwable
XposedHelpers.setObjectField(param.thisObject, "sprite_meme_info", null);
}
});

// 吧友都在看
XposedBridge.hookMethod(
ReflectUtils.findFirstMethodByExactType("com.baidu.tbadk.coreExtra.view.ImagePagerAdapter", ArrayList.class),
new XC_MethodHook() {
@Override
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
ArrayList<String> mList = (ArrayList<String>) param.args[0];
mList.removeIf(o -> o.startsWith("####mLiveRoomPageProvider"));
}
});
}
}
13 changes: 13 additions & 0 deletions app/src/main/java/gm/tieba/tabswitch/util/ReflectUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,19 @@ public static Method findFirstMethodByExactType(final String className, final Cl
return findFirstMethodByExactType(XposedHelpers.findClass(className, sClassLoader), paramTypes);
}

public static Method findFirstMethodByExactReturnType(final Class<?> cls, final Class<?> returnType) {
for (final var method : cls.getDeclaredMethods()) {
if (method.getReturnType() == returnType) {
return method;
}
}
throw new NoSuchMethodError(returnType.toString());
}

public static Method findFirstMethodByExactReturnType(final String className, final Class<?> returnType) {
return findFirstMethodByExactReturnType(XposedHelpers.findClass(className, sClassLoader), returnType);
}

public static Object callMethod(final Method method, final Object instance, final Object... args) {
try {
method.setAccessible(true);
Expand Down

0 comments on commit 8e45e10

Please sign in to comment.