new adblock (alpha)
This commit is contained in:
@@ -8,11 +8,20 @@ import static ru.vtosters.lite.utils.Base64Utils.decode;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Globals.getUserToken;
|
||||
import static ru.vtosters.lite.utils.Newsfeed.checkCaption;
|
||||
import static ru.vtosters.lite.utils.Newsfeed.checkCopyright;
|
||||
import static ru.vtosters.lite.utils.Newsfeed.injectFiltersReposts;
|
||||
import static ru.vtosters.lite.utils.Newsfeed.isBadNews;
|
||||
import static ru.vtosters.lite.utils.Preferences.ads;
|
||||
import static ru.vtosters.lite.utils.Preferences.adsgroup;
|
||||
import static ru.vtosters.lite.utils.Preferences.adsstories;
|
||||
import static ru.vtosters.lite.utils.Preferences.authorsrecomm;
|
||||
import static ru.vtosters.lite.utils.Preferences.dev;
|
||||
import static ru.vtosters.lite.utils.Preferences.friendsblock;
|
||||
import static ru.vtosters.lite.utils.Preferences.friendsrecomm;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.hasVerification;
|
||||
import static ru.vtosters.lite.utils.Preferences.postsrecomm;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
@@ -211,6 +220,64 @@ public class JsonInjectors{
|
||||
return items;
|
||||
}
|
||||
|
||||
public static JSONArray newsfeedadtest(JSONArray items) throws JSONException{
|
||||
for (int j = 0; j < items.length(); j++) {
|
||||
var list = items.optJSONObject(j);
|
||||
var type = list.optString("type");
|
||||
|
||||
var isAds = list.has("ads")
|
||||
|| type.contains("ads")
|
||||
|| type.contains("carousel")
|
||||
|| type.contains("app_video")
|
||||
|| type.contains("html5_ad")
|
||||
|| type.contains("app_slider")
|
||||
|| type.contains("promo_button")
|
||||
|| type.contains("ads_easy_promote")
|
||||
|| type.contains("app_widget");
|
||||
|
||||
var isAuthorRecommendations = type.contains("authors_rec");
|
||||
|
||||
var isPostRecommendations = type.contains("inline_user_rec") || type.contains("live_recommended");
|
||||
|
||||
var isFriendsRecommendations = type.contains("friends_recommendations") || type.contains("user_rec") || type.contains("friends_recomm");
|
||||
|
||||
var isGroupAds = list.optBoolean("marked_as_ads");
|
||||
|
||||
var isRecomsGroup = type.contains("recommended_groups");
|
||||
|
||||
var isMusicBlock = type.contains("recommended_audios") || type.contains("recommended_artists") || type.contains("recommended_playlists");
|
||||
|
||||
var isNewsBlock = type.contains("tags_suggestions");
|
||||
|
||||
var isBadNews = isBadNews(list.optString("text"));
|
||||
|
||||
var isCopyrightBlocked = checkCopyright(list);
|
||||
|
||||
var isCaptionBlocked = checkCaption(list);
|
||||
|
||||
var reposts = injectFiltersReposts(list);
|
||||
|
||||
if (isAds && ads()
|
||||
|| isAuthorRecommendations && authorsrecomm()
|
||||
|| isPostRecommendations && postsrecomm()
|
||||
|| isFriendsRecommendations && friendsrecomm()
|
||||
|| isGroupAds && adsgroup()
|
||||
|| isRecomsGroup && authorsrecomm()
|
||||
|| isMusicBlock && authorsrecomm()
|
||||
|| isNewsBlock && ads()
|
||||
|| isBadNews
|
||||
|| isCopyrightBlocked
|
||||
|| isCaptionBlocked
|
||||
|| reposts) {
|
||||
items.remove(j);
|
||||
|
||||
if (dev()) Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, type: " + type + ", isAds: " + isAds + ", marked as ads: " + isGroupAds + ", is bad news: " + isBadNews + ", is copyright blocked: " + isCopyrightBlocked + ", is caption blocked: " + isCaptionBlocked + ", repost blocked: " + reposts + ", is author recommendations: " + isAuthorRecommendations + ", is post recommendations: " + isPostRecommendations + ", is friends recommendations: " + isFriendsRecommendations + ", is music block: " + isMusicBlock + ", is news block: " + isNewsBlock);
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
public static JSONObject music(JSONObject json) throws JSONException{
|
||||
var catalog = json.optJSONObject("catalog");
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import static ru.vtosters.lite.utils.Newsfeed.checkCopyright;
|
||||
import static ru.vtosters.lite.utils.Newsfeed.injectFiltersReposts;
|
||||
import static ru.vtosters.lite.utils.Newsfeed.isAds;
|
||||
import static ru.vtosters.lite.utils.Newsfeed.isAuthorRecommendations;
|
||||
import static ru.vtosters.lite.utils.Newsfeed.isBadNew;
|
||||
import static ru.vtosters.lite.utils.Newsfeed.isBadNews;
|
||||
import static ru.vtosters.lite.utils.Newsfeed.isFriendsRecommendations;
|
||||
import static ru.vtosters.lite.utils.Newsfeed.isGroupAds;
|
||||
import static ru.vtosters.lite.utils.Newsfeed.isMusicBlock;
|
||||
@@ -16,9 +16,6 @@ import static ru.vtosters.lite.utils.Newsfeed.isRecomsGroup;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.vkme;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.vk.core.preference.Preference;
|
||||
|
||||
import org.json.JSONException;
|
||||
@@ -44,7 +41,7 @@ public class NewsfeedHook{
|
||||
|
||||
if (checkCopyright(obj)) return false;
|
||||
|
||||
if (isBadNew(obj.optString("text", ""))) return false;
|
||||
if (isBadNews(obj.optString("text", ""))) return false;
|
||||
|
||||
if (checkCaption(obj)) return false;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.*;
|
||||
import static ru.vtosters.lite.utils.Preferences.adsgroup;
|
||||
import static ru.vtosters.lite.utils.Preferences.authorsrecomm;
|
||||
import static ru.vtosters.lite.utils.Preferences.copyright_post;
|
||||
@@ -82,7 +83,7 @@ public class Newsfeed{
|
||||
}
|
||||
}
|
||||
|
||||
return isBadNew(Array);
|
||||
return isBadNews(Array);
|
||||
} // get repost information and inject our text filters
|
||||
|
||||
public static boolean checkCopyright(JSONObject json) throws JSONException{
|
||||
@@ -109,14 +110,14 @@ public class Newsfeed{
|
||||
}
|
||||
|
||||
public static boolean isNewsBlock(String src){
|
||||
return (src.equals("tags_suggestions")) && Preferences.ads();
|
||||
return (src.equals("tags_suggestions")) && ads();
|
||||
}
|
||||
|
||||
public static String getAllFilters(){
|
||||
return getPrefsValue("spamfilters");
|
||||
}
|
||||
|
||||
public static boolean isBadNew(String text){
|
||||
public static boolean isBadNews(String text){
|
||||
for (String filter : mFilters) {
|
||||
if (text.toLowerCase().contains(filter.toLowerCase())) {
|
||||
if (dev()) Log.d("VTLite", text.toLowerCase());
|
||||
@@ -129,7 +130,7 @@ public class Newsfeed{
|
||||
public static boolean checkCaption(JSONObject postJson){
|
||||
try {
|
||||
var captionJson = postJson.getJSONObject("caption");
|
||||
if (Preferences.captions())
|
||||
if (captions())
|
||||
return true;
|
||||
|
||||
boolean postAds = postsrecomm();
|
||||
@@ -148,7 +149,7 @@ public class Newsfeed{
|
||||
return (optString.equals("ads_easy_promote") ||
|
||||
optString.equals("promo_button") ||
|
||||
optString.equals("app_widget") ||
|
||||
optString.equals("ads")) && Preferences.ads();
|
||||
optString.equals("ads")) && ads();
|
||||
}
|
||||
|
||||
public static boolean isAuthorRecommendations(String optString){
|
||||
|
||||
@@ -9,4 +9,5 @@ bitmain
|
||||
cents-apps
|
||||
cent-app
|
||||
centapp
|
||||
/?a=
|
||||
/?a=
|
||||
minerx
|
||||
@@ -539,6 +539,10 @@
|
||||
|
||||
move-result-object p1
|
||||
|
||||
invoke-static {p1}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
|
||||
|
||||
move-result-object p1
|
||||
|
||||
const/4 v0, 0x0
|
||||
|
||||
if-eqz p1, :cond_7
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
# virtual methods
|
||||
.method public final a(Lorg/json/JSONObject;Ljava/lang/String;)Lcom/vk/dto/feedlikes/FeedLikesResponse;
|
||||
.locals 9
|
||||
.locals 10
|
||||
|
||||
.line 1
|
||||
new-instance v0, Landroid/util/SparseArray;
|
||||
@@ -171,6 +171,10 @@
|
||||
|
||||
.line 14
|
||||
:cond_4
|
||||
invoke-static {v4}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
|
||||
|
||||
move-result-object v4
|
||||
|
||||
invoke-virtual {v4}, Lorg/json/JSONArray;->length()I
|
||||
|
||||
move-result v6
|
||||
@@ -183,6 +187,19 @@
|
||||
|
||||
move-result-object v7
|
||||
|
||||
invoke-static {v7}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
|
||||
|
||||
move-result v9
|
||||
|
||||
if-nez v9, :cond_99
|
||||
|
||||
add-int/lit8 v3, v3, 0x1
|
||||
|
||||
goto :goto_4
|
||||
|
||||
:cond_99
|
||||
|
||||
|
||||
invoke-static {v7, v2}, Lkotlin/jvm/internal/Intrinsics;->a(Ljava/lang/Object;Ljava/lang/String;)V
|
||||
|
||||
.line 16
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
# virtual methods
|
||||
.method public final a(Lorg/json/JSONObject;Ljava/lang/String;)Lcom/vk/dto/stories/GeoNewsResponse1;
|
||||
.locals 15
|
||||
.locals 16
|
||||
|
||||
move-object/from16 v1, p1
|
||||
|
||||
@@ -235,6 +235,10 @@
|
||||
|
||||
.line 20
|
||||
:cond_5
|
||||
invoke-static {v11}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
|
||||
|
||||
move-result-object v11
|
||||
|
||||
invoke-virtual {v11}, Lorg/json/JSONArray;->length()I
|
||||
|
||||
move-result v12
|
||||
@@ -247,6 +251,19 @@
|
||||
|
||||
move-result-object v0
|
||||
|
||||
invoke-static {v0}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
|
||||
|
||||
move-result v15
|
||||
|
||||
if-nez v15, :cond_99
|
||||
|
||||
add-int/lit8 v10, v10, 0x1
|
||||
|
||||
goto :goto_5
|
||||
|
||||
:cond_99
|
||||
|
||||
|
||||
invoke-static {v0, v6}, Lkotlin/jvm/internal/Intrinsics;->a(Ljava/lang/Object;Ljava/lang/String;)V
|
||||
|
||||
.line 22
|
||||
|
||||
@@ -210,6 +210,10 @@
|
||||
|
||||
.line 13
|
||||
:cond_2
|
||||
invoke-static {p2}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
|
||||
|
||||
move-result-object p2
|
||||
|
||||
invoke-virtual {p2}, Lorg/json/JSONArray;->length()I
|
||||
|
||||
move-result p1
|
||||
|
||||
@@ -745,6 +745,10 @@
|
||||
.line 37
|
||||
:cond_2
|
||||
:goto_2
|
||||
invoke-static {v1}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
|
||||
|
||||
move-result-object v1
|
||||
|
||||
invoke-virtual {v1}, Lorg/json/JSONArray;->length()I
|
||||
|
||||
move-result v2
|
||||
|
||||
@@ -177,6 +177,10 @@
|
||||
|
||||
.line 10
|
||||
:goto_1
|
||||
invoke-static {v5}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
|
||||
|
||||
move-result-object v5
|
||||
|
||||
invoke-virtual {v5}, Lorg/json/JSONArray;->length()I
|
||||
|
||||
move-result v4
|
||||
@@ -192,6 +196,18 @@
|
||||
|
||||
move-result-object v4
|
||||
|
||||
invoke-static {v4}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
|
||||
|
||||
move-result v8
|
||||
|
||||
if-nez v8, :cond_70
|
||||
|
||||
add-int/lit8 v0, v0, 0x1
|
||||
|
||||
goto :goto_1
|
||||
|
||||
:cond_70
|
||||
|
||||
.line 12
|
||||
invoke-virtual {v4}, Lcom/vk/dto/newsfeed/Owner;->getUid()I
|
||||
|
||||
|
||||
+4
@@ -139,6 +139,10 @@
|
||||
|
||||
move-result-object v1
|
||||
|
||||
invoke-static {v1}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
|
||||
|
||||
move-result-object v1
|
||||
|
||||
const-string v2, "profiles"
|
||||
|
||||
.line 2
|
||||
|
||||
@@ -220,7 +220,7 @@
|
||||
|
||||
# virtual methods
|
||||
.method public a(Lorg/json/JSONObject;)Lcom/vtosters/lite/api/newsfeed/NewsfeedSearch$List;
|
||||
.locals 9
|
||||
.locals 10
|
||||
.annotation system Ldalvik/annotation/Signature;
|
||||
value = {
|
||||
"(",
|
||||
@@ -365,6 +365,10 @@
|
||||
|
||||
.line 14
|
||||
:goto_2
|
||||
invoke-static {v4}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
|
||||
|
||||
move-result-object v4
|
||||
|
||||
invoke-virtual {v4}, Lorg/json/JSONArray;->length()I
|
||||
|
||||
move-result v6
|
||||
@@ -376,6 +380,17 @@
|
||||
|
||||
move-result-object v6
|
||||
|
||||
invoke-static {v6}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
|
||||
|
||||
move-result v9
|
||||
|
||||
if-nez v9, :cond_71
|
||||
|
||||
add-int/lit8 v3, v3, 0x1
|
||||
|
||||
goto :goto_3
|
||||
|
||||
:cond_71
|
||||
invoke-static {v6}, Lcom/vk/dto/newsfeed/Owner;->b(Lorg/json/JSONObject;)Lcom/vk/dto/newsfeed/Owner;
|
||||
|
||||
move-result-object v6
|
||||
@@ -396,6 +411,10 @@
|
||||
|
||||
.line 17
|
||||
:goto_3
|
||||
invoke-static {v2}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
|
||||
|
||||
move-result-object v2
|
||||
|
||||
invoke-virtual {v2}, Lorg/json/JSONArray;->length()I
|
||||
|
||||
move-result v4
|
||||
@@ -412,6 +431,19 @@
|
||||
|
||||
move-result-object v6
|
||||
|
||||
invoke-static {v6}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
|
||||
|
||||
move-result v9
|
||||
|
||||
if-nez v9, :cond_70
|
||||
|
||||
add-int/lit8 v3, v3, 0x1
|
||||
|
||||
goto :goto_3
|
||||
|
||||
:cond_70
|
||||
|
||||
|
||||
invoke-static {v4, v6, p1, v1}, Lcom/vk/dto/newsfeed/entries/NewsEntryFactory;->a(Ljava/lang/String;Lorg/json/JSONObject;Landroid/util/SparseArray;Ljava/lang/String;)Lcom/vk/dto/newsfeed/entries/NewsEntry;
|
||||
|
||||
move-result-object v4
|
||||
|
||||
@@ -524,6 +524,10 @@
|
||||
|
||||
.line 19
|
||||
:goto_2
|
||||
invoke-static {p1}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
|
||||
|
||||
move-result-object p1
|
||||
|
||||
invoke-virtual {p1}, Lorg/json/JSONArray;->length()I
|
||||
|
||||
move-result v8
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
.end method
|
||||
|
||||
.method private a(Landroid/util/SparseArray;Lorg/json/JSONArray;)[Lcom/vk/dto/newsfeed/entries/NewsEntry;
|
||||
.locals 5
|
||||
.locals 6
|
||||
.annotation system Ldalvik/annotation/Signature;
|
||||
value = {
|
||||
"(",
|
||||
@@ -75,6 +75,10 @@
|
||||
}
|
||||
.end annotation
|
||||
|
||||
invoke-static {p2}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
|
||||
|
||||
move-result-object p2
|
||||
|
||||
.line 14
|
||||
invoke-virtual {p2}, Lorg/json/JSONArray;->length()I
|
||||
|
||||
@@ -86,6 +90,10 @@
|
||||
|
||||
.line 15
|
||||
:goto_0
|
||||
invoke-static {p2}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
|
||||
|
||||
move-result-object p2
|
||||
|
||||
invoke-virtual {p2}, Lorg/json/JSONArray;->length()I
|
||||
|
||||
move-result v2
|
||||
@@ -97,6 +105,17 @@
|
||||
|
||||
move-result-object v2
|
||||
|
||||
invoke-static {v2}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
|
||||
|
||||
move-result v5
|
||||
|
||||
if-nez v5, :cond_70
|
||||
|
||||
add-int/lit8 v1, v1, 0x1
|
||||
|
||||
goto :goto_0
|
||||
|
||||
:cond_70
|
||||
const-string v3, "type"
|
||||
|
||||
const-string v4, "post"
|
||||
|
||||
Reference in New Issue
Block a user