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

Commit

Permalink
Use title instead of buttons.
Browse files Browse the repository at this point in the history
Fix Concurrent Modify, use iterator
Bump 1.3.1
  • Loading branch information
kmod-midori committed Oct 22, 2016
1 parent 1a1b65e commit ede8059
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "moe.reimu.weiboxposed"
minSdkVersion 17
targetSdkVersion 24
versionCode 5
versionName "1.3"
versionCode 6
versionName "1.3.1"
}
buildTypes {
release {
Expand Down
31 changes: 18 additions & 13 deletions app/src/main/java/moe/reimu/weiboxposed/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import de.robv.android.xposed.IXposedHookInitPackageResources;
Expand Down Expand Up @@ -73,28 +74,34 @@ 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(scheme + " detected as promotion: buttons");
return true;
}
Object title = getObjectField(mblog, "title");
boolean is_friend_hot = false;

if (promotion != null) {
String adType = (String)getObjectField(promotion, "adtype");
String ad_type = (String)getObjectField(promotion, "adtype");
log(scheme + " detected as promotion: adtype");
if(remove_hot) {
return true;
} else {
if (!"8".equals(adType)) {
if (!"8".equals(ad_type)) {
return true;
} else {
is_friend_hot = true;
}
}
}

if (title != null && !is_friend_hot) {
String text = (String)getObjectField(title, "text");
if (!"".equals(text)) {
log(scheme + " detected as promotion: non-empty title");
return true;
}
}

} catch(NoSuchFieldError e) {
log(e.getMessage());
}
Expand All @@ -110,12 +117,10 @@ private void log(String text) {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
ArrayList<Object> origResult = (ArrayList<Object>)param.getResult();

for (Object mblog :
origResult) {
for (Iterator<Object> iterator = origResult.iterator(); iterator.hasNext(); ) {
Object mblog = iterator.next();
if (isPromotion(mblog)) {
log("Removing promotion.");
origResult.remove(mblog);
iterator.remove();
}
}
}
Expand Down

0 comments on commit ede8059

Please sign in to comment.