no settings or remember speed patches
This commit is contained in:
parent
ef052c0d8f
commit
0ad2464cba
19 changed files with 214 additions and 139 deletions
|
|
@ -5,10 +5,12 @@ import app.revanced.extension.tiktok.settings.Settings;
|
|||
@SuppressWarnings("unused")
|
||||
public class DownloadsPatch {
|
||||
public static String getDownloadPath() {
|
||||
return Settings.DOWNLOAD_PATH.get();
|
||||
return "Pictures/Tiktok";
|
||||
//return Settings.DOWNLOAD_PATH.get();
|
||||
}
|
||||
|
||||
public static boolean shouldRemoveWatermark() {
|
||||
return Settings.DOWNLOAD_WATERMARK.get();
|
||||
return true;
|
||||
//return Settings.DOWNLOAD_WATERMARK.get();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,15 +2,32 @@ package app.revanced.extension.tiktok.feedfilter;
|
|||
|
||||
import app.revanced.extension.tiktok.settings.Settings;
|
||||
import com.ss.android.ugc.aweme.feed.model.Aweme;
|
||||
import com.ss.android.ugc.aweme.commerce.AwemeCommerceStruct;
|
||||
|
||||
public class AdsFilter implements IFilter {
|
||||
@Override
|
||||
public boolean getEnabled() {
|
||||
return Settings.REMOVE_ADS.get();
|
||||
return true;
|
||||
// return Settings.REMOVE_ADS.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFiltered(Aweme item) {
|
||||
return item.isAd() || item.isWithPromotionalMusic();
|
||||
try {
|
||||
// Standard Ads & Promotional Music
|
||||
if (item.isAd() || item.isWithPromotionalMusic()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Paid Partnerships (Branded Content)
|
||||
if (item.mCommerceVideoAuthInfo != null) {
|
||||
if (item.mCommerceVideoAuthInfo.isBrandedContent()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package app.revanced.extension.tiktok.feedfilter;
|
||||
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.settings.BaseSettings;
|
||||
import com.ss.android.ugc.aweme.feed.model.Aweme;
|
||||
import com.ss.android.ugc.aweme.feed.model.FeedItemList;
|
||||
import com.ss.android.ugc.aweme.follow.presenter.FollowFeedList;
|
||||
|
|
@ -8,43 +10,73 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
|
||||
public final class FeedItemsFilter {
|
||||
private static final List<IFilter> FILTERS = List.of(
|
||||
new AdsFilter(),
|
||||
new LiveFilter(),
|
||||
new StoryFilter(),
|
||||
new ImageVideoFilter(),
|
||||
new ViewCountFilter(),
|
||||
new LikeCountFilter(),
|
||||
new ShopFilter()
|
||||
);
|
||||
|
||||
public static void filter(FeedItemList feedItemList) {
|
||||
filterFeedList(feedItemList.items, item -> item);
|
||||
boolean verbose = BaseSettings.DEBUG.get();
|
||||
if (feedItemList == null || feedItemList.items == null) return;
|
||||
|
||||
filterFeedList("FeedItemList", feedItemList.items, item -> item, verbose);
|
||||
}
|
||||
|
||||
public static void filter(FollowFeedList followFeedList) {
|
||||
filterFeedList(followFeedList.mItems, feed -> (feed != null) ? feed.aweme : null);
|
||||
boolean verbose = BaseSettings.DEBUG.get();
|
||||
if (followFeedList == null || followFeedList.mItems == null) return;
|
||||
|
||||
filterFeedList("FollowFeedList", followFeedList.mItems, feed -> (feed != null) ? feed.aweme : null, verbose);
|
||||
}
|
||||
|
||||
private static <T> void filterFeedList(List<T> list, AwemeExtractor<T> extractor) {
|
||||
// Could be simplified with removeIf() but requires Android 7.0+ while TikTok supports 4.0+.
|
||||
private static <T> void filterFeedList(
|
||||
String source,
|
||||
List<T> list,
|
||||
AwemeExtractor<T> extractor,
|
||||
boolean verbose
|
||||
) {
|
||||
if (list == null) return;
|
||||
|
||||
int initialSize = list.size();
|
||||
int removed = 0;
|
||||
Iterator<T> iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T container = iterator.next();
|
||||
Aweme item = extractor.extract(container);
|
||||
if (item != null && shouldFilter(item)) {
|
||||
if (item == null) continue;
|
||||
|
||||
String reason = getInternalizedFilterReason(item);
|
||||
|
||||
if (reason != null) {
|
||||
removed++;
|
||||
iterator.remove();
|
||||
if (verbose) {
|
||||
logItem(item, reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose && removed > 0) {
|
||||
int finalRemoved = removed;
|
||||
Logger.printInfo(() -> "[ReVanced FeedFilter] " + source + ": removed " + finalRemoved + " items.");
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean shouldFilter(Aweme item) {
|
||||
for (IFilter filter : FILTERS) {
|
||||
if (filter.getEnabled() && filter.getFiltered(item)) {
|
||||
return true;
|
||||
}
|
||||
private static String getInternalizedFilterReason(Aweme item) {
|
||||
if (item.isAd() || item.isWithPromotionalMusic()) {
|
||||
return "AdsFilter";
|
||||
}
|
||||
return false;
|
||||
|
||||
if (item.getLiveId() != 0 || item.getLiveType() != null || item.isLiveReplay()) {
|
||||
return "LiveFilter";
|
||||
}
|
||||
|
||||
String shareUrl = item.getShareUrl();
|
||||
if (shareUrl != null && shareUrl.contains("placeholder_product_id")) {
|
||||
return "ShopFilter";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void logItem(Aweme item, String reason) {
|
||||
Logger.printInfo(() -> "[ReVanced FeedFilter] FILTERED: aid=" + item.getAid() + " Reason=" + reason);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ public class ImageVideoFilter implements IFilter {
|
|||
|
||||
@Override
|
||||
public boolean getFiltered(Aweme item) {
|
||||
return item.isImage() || item.isPhotoMode();
|
||||
var imageInfos = item.getImageInfos();
|
||||
boolean isImage = imageInfos != null && !imageInfos.isEmpty();
|
||||
boolean isPhotoMode = item.getPhotoModeImageInfo() != null || item.getPhotoModeTextInfo() != null;
|
||||
return isImage || isPhotoMode;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,12 @@ import com.ss.android.ugc.aweme.feed.model.Aweme;
|
|||
public class LiveFilter implements IFilter {
|
||||
@Override
|
||||
public boolean getEnabled() {
|
||||
return Settings.HIDE_LIVE.get();
|
||||
// HARDCODED: Always filter live streams
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFiltered(Aweme item) {
|
||||
return item.isLive() || item.isLiveReplay();
|
||||
return item.getLiveId() != 0 || item.isLiveReplay() || item.getLiveType() != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,11 +7,13 @@ public class ShopFilter implements IFilter {
|
|||
private static final String SHOP_INFO = "placeholder_product_id";
|
||||
@Override
|
||||
public boolean getEnabled() {
|
||||
return Settings.HIDE_SHOP.get();
|
||||
return true;
|
||||
// return Settings.HIDE_SHOP.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFiltered(Aweme item) {
|
||||
return item.getShareUrl().contains(SHOP_INFO);
|
||||
String shareUrl = item.getShareUrl();
|
||||
return shareUrl != null && shareUrl.contains(SHOP_INFO);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ public final class ShareUrlSanitizer {
|
|||
* Injection point for setting check.
|
||||
*/
|
||||
public static boolean shouldSanitize() {
|
||||
return BaseSettings.SANITIZE_SHARED_LINKS.get();
|
||||
return true;
|
||||
// return BaseSettings.SANITIZE_SHARED_LINKS.get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.ss.android.ugc.aweme.commerce;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class AwemeCommerceStruct implements Serializable {
|
||||
public long brandedContentType;
|
||||
public long brandOrganicType;
|
||||
|
||||
public boolean isBrandedContent() {
|
||||
return this.brandedContentType > 0;
|
||||
}
|
||||
|
||||
public boolean isBrandOrganicContent() {
|
||||
return this.brandOrganicType > 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,29 @@
|
|||
package com.ss.android.ugc.aweme.feed.model;
|
||||
import com.ss.android.ugc.aweme.commerce.AwemeCommerceStruct;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//Dummy class
|
||||
public class Aweme {
|
||||
|
||||
public AwemeCommerceStruct mCommerceVideoAuthInfo;
|
||||
|
||||
public String getAid() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
|
||||
public boolean isAd() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
|
||||
public boolean isLive() {
|
||||
public boolean isLiveReplay() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
|
||||
public boolean isLiveReplay() {
|
||||
public long getLiveId() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
|
||||
public String getLiveType() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
|
||||
|
|
@ -22,11 +35,15 @@ public class Aweme {
|
|||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
|
||||
public boolean isImage() {
|
||||
public List getImageInfos() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
|
||||
public boolean isPhotoMode() {
|
||||
public PhotoModeImageInfo getPhotoModeImageInfo() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
|
||||
public PhotoModeTextInfo getPhotoModeTextInfo() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
|
||||
|
|
@ -37,4 +54,8 @@ public class Aweme {
|
|||
public String getShareUrl() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
}
|
||||
|
||||
public AwemeCommerceStruct getCommerceAndAdSettingsStruct() {
|
||||
throw new UnsupportedOperationException("Stub");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.ss.android.ugc.aweme.feed.model;
|
||||
|
||||
// Dummy class
|
||||
public class PhotoModeImageInfo {
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.ss.android.ugc.aweme.feed.model;
|
||||
|
||||
// Dummy class
|
||||
public class PhotoModeTextInfo {
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue