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){
|
||||
|
||||
Reference in New Issue
Block a user