Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
More logs & button detection
Browse files Browse the repository at this point in the history
  • Loading branch information
kmod-midori committed Aug 4, 2016
1 parent 4b257d4 commit 97f86a5
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions app/src/main/java/moe/reimu/weiboxposed/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import de.robv.android.xposed.callbacks.XC_InitPackageResources.InitPackageResourcesParam;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

import static de.robv.android.xposed.XposedBridge.log;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import static de.robv.android.xposed.XposedHelpers.getObjectField;

Expand All @@ -48,7 +49,7 @@ public void initZygote(StartupParam startupParam) throws Throwable {
prefs = new XSharedPreferences(MOD_PACKAGE_NAME, SettingsActivity.PREF_NAME);
prefs.makeWorldReadable();

XposedBridge.log("[WeiboXposed] Pref Init.");
log("[WeiboXposed] Pref Init.");
}

@Override
Expand All @@ -70,14 +71,26 @@ private void hookSelf(final XC_LoadPackage.LoadPackageParam lpparam) {

public boolean isPromotion(Object mblog) {
try {
Object buttons = getObjectField(mblog, "buttons");
Object promotion = getObjectField(mblog, "promotion");

String scheme = (String)getObjectField(mblog, "scheme");

if (buttons != null) {
log("[WeiboXposed] " + scheme + " detected as promotion: buttons");
return true;
}

if (promotion != null) {
String adType = (String)getObjectField(promotion, "adtype");
return !"8".equals(adType);
if (!"8".equals(adType)) {
log("[WeiboXposed] " + scheme + " detected as promotion: adtype");
return true;
}
}

} catch(NoSuchFieldError e) {
return false;
log("[WiboXposed] " + e.getMessage());
}

return false;
Expand All @@ -86,8 +99,8 @@ public boolean isPromotion(Object mblog) {
private void hookWeibo(final XC_LoadPackage.LoadPackageParam lpparam) {
prefs.reload();
boolean useExpMethod = prefs.getBoolean("switch_remove_mode", false);
XposedBridge.log("[WeiboXposed] App Weibo Loaded");
XposedBridge.log("[WeiboXposed] Remove Mode: " + useExpMethod);
log("[WeiboXposed] App Weibo Loaded");
log("[WeiboXposed] Remove Mode: " + useExpMethod);

XC_MethodHook callbackCancel = new XC_MethodHook() {
@Override
Expand Down Expand Up @@ -117,7 +130,9 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {

for (Object mblog :
origResult) {
if (isPromotion(mblog)) continue;
if (isPromotion(mblog)) {
log("[WeiboXposed][DATA] Removing promotion.");
}
result.add(mblog);
}

Expand All @@ -143,7 +158,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}

if (isPromotion(status)) {
XposedBridge.log("[WeiboXposed] Removing #" + getObjectField(status, "id"));
log("[WeiboXposed][VIEW] Removing promotion.");
TextView tv = new TextView(AndroidAppHelper.currentApplication()); // Empty view
param.setResult(tv);
}
Expand Down

0 comments on commit 97f86a5

Please sign in to comment.