miniapps ban
This commit is contained in:
@@ -9,6 +9,7 @@ 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.friendsrecomm;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.postsrecomm;
|
||||
|
||||
import android.util.Log;
|
||||
@@ -224,6 +225,12 @@ public class AdBlockHook {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hasMiniAppAds(list) && !isWhitelistedFilters(list)) {
|
||||
if (dev())
|
||||
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: MiniApp filters");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (NewsFeedFiltersUtils.injectFiltersReposts(list) && !isWhitelistedFilters(list)) {
|
||||
if (dev())
|
||||
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: repost ad");
|
||||
@@ -360,4 +367,17 @@ public class AdBlockHook {
|
||||
|
||||
return whitelist.contains(id);
|
||||
}
|
||||
|
||||
public static Boolean hasMiniAppAds(JSONObject list) {
|
||||
var attachments = list.optJSONArray("attachments");
|
||||
|
||||
if (attachments != null && getBoolValue("blockminiapps", false)) {
|
||||
for (int j = 0; j < attachments.length(); j++) {
|
||||
var type = attachments.optJSONObject(j).optString("type");
|
||||
if (type.contains("mini_app")) return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,11 @@
|
||||
android:key="copyright_post"
|
||||
android:summary="@string/feed_ads_sources_summary"
|
||||
android:title="@string/feed_ads_sources" />
|
||||
<com.vtosters.lite.ui.MaterialSwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="blockminiapps"
|
||||
android:summary="Блокировать посты если в них есть мини приложение"
|
||||
android:title="Посты с MiniApp" />
|
||||
<Preference
|
||||
android:key="whitelisted_filters_groups"
|
||||
android:title="@string/whitelisted_filters_groups_title" />
|
||||
|
||||
Reference in New Issue
Block a user