mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-11-09 05:37:04 +01:00
chore: merge branch dev
to main
(#421)
This commit is contained in:
commit
190481cb39
42
CHANGELOG.md
42
CHANGELOG.md
@ -1,3 +1,45 @@
|
||||
# [0.111.0-dev.3](https://github.com/revanced/revanced-integrations/compare/v0.111.0-dev.2...v0.111.0-dev.3) (2023-06-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **youtube/client-spoof:** use new visitor data to work around playback issues ([be9c948](https://github.com/revanced/revanced-integrations/commit/be9c948ce6135ec7fad4d7e7dc18be64e9dbb3eb))
|
||||
|
||||
# [0.111.0-dev.2](https://github.com/revanced/revanced-integrations/compare/v0.111.0-dev.1...v0.111.0-dev.2) (2023-06-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **youtube/hide-layout-components:** preserve gap when hiding expandable chips ([b47a214](https://github.com/revanced/revanced-integrations/commit/b47a214067031c099df990d4c83a1d96ab7b3c34))
|
||||
|
||||
# [0.111.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.110.1-dev.3...v0.111.0-dev.1) (2023-06-18)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **youtube/hide-layout-components:** separate hiding expandable chips and chapters ([80fb3a3](https://github.com/revanced/revanced-integrations/commit/80fb3a31dd4604b0d1d72c6033624d2d780746ea))
|
||||
|
||||
## [0.110.1-dev.3](https://github.com/revanced/revanced-integrations/compare/v0.110.1-dev.2...v0.110.1-dev.3) (2023-06-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **reddit/hide-ads:** only filter promoted links ([efc2b9b](https://github.com/revanced/revanced-integrations/commit/efc2b9b6a39de93d6cc1052dfcea457aeaf949b2))
|
||||
|
||||
## [0.110.1-dev.2](https://github.com/revanced/revanced-integrations/compare/v0.110.1-dev.1...v0.110.1-dev.2) (2023-06-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **youtube:** separate `hide-ads` to `hide-layout-components` patch ([bdce029](https://github.com/revanced/revanced-integrations/commit/bdce0298c404be6e5c3ae6854f3609d82ad76e28))
|
||||
|
||||
## [0.110.1-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.110.0...v0.110.1-dev.1) (2023-06-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* don't include all Litho patches, when not included ([9952581](https://github.com/revanced/revanced-integrations/commit/9952581a325b780f7dea074cc4ed138d7ac2758b))
|
||||
|
||||
# [0.110.0](https://github.com/revanced/revanced-integrations/compare/v0.109.0...v0.110.0) (2023-06-12)
|
||||
|
||||
|
||||
|
@ -1,16 +1,20 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
import static app.revanced.integrations.utils.ReVancedUtils.containsAny;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.shared.PlayerType;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
|
||||
import static app.revanced.integrations.utils.ReVancedUtils.containsAny;
|
||||
|
||||
public class SpoofSignatureVerificationPatch {
|
||||
/**
|
||||
* Enable/disable all workarounds that are required due to signature spoofing.
|
||||
*/
|
||||
private static final boolean WORKAROUND = true;
|
||||
|
||||
/**
|
||||
* Protobuf parameters used for autoplay in scrim.
|
||||
* Prepend this parameter to mute video playback (for autoplay in feed)
|
||||
@ -18,10 +22,12 @@ public class SpoofSignatureVerificationPatch {
|
||||
private static final String PROTOBUF_PARAMETER_SCRIM = "SAFgAXgB";
|
||||
|
||||
/**
|
||||
* Protobuf parameter of shorts and YouTube stories.
|
||||
* Protobuf parameter also used by
|
||||
* <a href="https://github.com/yt-dlp/yt-dlp/blob/81ca451480051d7ce1a31c017e005358345a9149/yt_dlp/extractor/youtube.py#L3602">yt-dlp</a>
|
||||
* <br>
|
||||
* Known issue: captions are positioned on upper area in the player.
|
||||
*/
|
||||
private static final String PROTOBUF_PARAMETER_SHORTS = "8AEB"; // "8AEByAMTuAQP"
|
||||
private static final String PROTOBUF_PLAYER_PARAMS = "CgIQBg==";
|
||||
|
||||
/**
|
||||
* Target Protobuf parameters.
|
||||
@ -66,17 +72,18 @@ public class SpoofSignatureVerificationPatch {
|
||||
|
||||
LogHelper.printDebug(() -> "Original protobuf parameter value: " + originalValue);
|
||||
|
||||
// Video is Short or Story.
|
||||
var isPlayingShorts = originalValue.contains(PROTOBUF_PARAMETER_SHORTS);
|
||||
if (isPlayingShorts) return originalValue;
|
||||
if (!WORKAROUND) return PROTOBUF_PLAYER_PARAMS;
|
||||
|
||||
var isPlayingVideo = originalValue.contains(PROTOBUF_PLAYER_PARAMS);
|
||||
if (isPlayingVideo) return originalValue;
|
||||
|
||||
boolean isPlayingFeed = containsAny(originalValue, PROTOBUF_PARAMETER_TARGETS) && PlayerType.getCurrent() == PlayerType.INLINE_MINIMAL;
|
||||
if (isPlayingFeed) {
|
||||
// Videos in feed won't autoplay with sound.
|
||||
return PROTOBUF_PARAMETER_SCRIM + PROTOBUF_PARAMETER_SHORTS;
|
||||
return PROTOBUF_PARAMETER_SCRIM + PROTOBUF_PLAYER_PARAMS;
|
||||
} else {
|
||||
// Spoof the parameter to prevent playback issues.
|
||||
return PROTOBUF_PARAMETER_SHORTS;
|
||||
return PROTOBUF_PLAYER_PARAMS;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(() -> "overrideProtobufParameter failure", ex);
|
||||
@ -143,6 +150,10 @@ public class SpoofSignatureVerificationPatch {
|
||||
}
|
||||
}
|
||||
|
||||
if (!WORKAROUND) {
|
||||
return new int[]{ap, ah, av};
|
||||
}
|
||||
|
||||
// Videos with custom captions that specify screen positions appear to always have correct screen positions (even with spoofing).
|
||||
// But for auto generated and most other captions, the spoof incorrectly gives various default Shorts caption settings.
|
||||
// Check for these known default shorts captions parameters, and replace with the known correct values.
|
||||
|
@ -1,160 +1,23 @@
|
||||
package app.revanced.integrations.patches.components;
|
||||
|
||||
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
|
||||
|
||||
public final class AdsFilter extends Filter {
|
||||
private final String[] exceptions;
|
||||
|
||||
private final CustomFilterGroup custom;
|
||||
|
||||
// region Mix playlists
|
||||
private final ByteArrayAsStringFilterGroup mixPlaylists;
|
||||
private final ByteArrayAsStringFilterGroup imageHosting;
|
||||
|
||||
// endregion
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
public AdsFilter() {
|
||||
exceptions = new String[]{
|
||||
"home_video_with_context",
|
||||
"related_video_with_context",
|
||||
"comment_thread", // skip filtering anything in the comments
|
||||
"|comment.", // skip filtering anything in the comments replies
|
||||
"home_video_with_context", // Don't filter anything in the home page video component.
|
||||
"related_video_with_context", // Don't filter anything in the related video component.
|
||||
"comment_thread", // Don't filter anything in the comments.
|
||||
"|comment.", // Don't filter anything in the comments replies.
|
||||
"library_recent_shelf",
|
||||
};
|
||||
|
||||
custom = new CustomFilterGroup(
|
||||
SettingsEnum.CUSTOM_FILTER,
|
||||
SettingsEnum.CUSTOM_FILTER_STRINGS
|
||||
);
|
||||
|
||||
final var communityPosts = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_COMMUNITY_POSTS,
|
||||
"post_base_wrapper"
|
||||
);
|
||||
|
||||
final var communityGuidelines = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_COMMUNITY_GUIDELINES,
|
||||
"community_guidelines"
|
||||
);
|
||||
|
||||
final var subscribersCommunityGuidelines = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_SUBSCRIBERS_COMMUNITY_GUIDELINES,
|
||||
"sponsorships_comments_upsell"
|
||||
);
|
||||
|
||||
|
||||
final var channelMemberShelf = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_CHANNEL_MEMBER_SHELF,
|
||||
"member_recognition_shelf"
|
||||
);
|
||||
|
||||
final var compactBanner = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_COMPACT_BANNER,
|
||||
"compact_banner"
|
||||
);
|
||||
|
||||
final var inFeedSurvey = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_FEED_SURVEY,
|
||||
"in_feed_survey",
|
||||
"slimline_survey"
|
||||
);
|
||||
|
||||
final var medicalPanel = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_MEDICAL_PANELS,
|
||||
"medical_panel"
|
||||
);
|
||||
|
||||
final var paidContent = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_PAID_CONTENT,
|
||||
"paid_content_overlay"
|
||||
);
|
||||
|
||||
final var merchandise = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_MERCHANDISE_BANNERS,
|
||||
"product_carousel"
|
||||
);
|
||||
|
||||
final var infoPanel = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_HIDE_INFO_PANELS,
|
||||
"publisher_transparency_panel",
|
||||
"single_item_information_panel"
|
||||
);
|
||||
|
||||
final var latestPosts = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_HIDE_LATEST_POSTS,
|
||||
"post_shelf"
|
||||
);
|
||||
|
||||
final var channelGuidelines = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_HIDE_CHANNEL_GUIDELINES,
|
||||
"channel_guidelines_entry_banner"
|
||||
);
|
||||
|
||||
final var audioTrackButton = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_AUDIO_TRACK_BUTTON,
|
||||
"multi_feed_icon_button"
|
||||
);
|
||||
|
||||
final var artistCard = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_ARTIST_CARDS,
|
||||
"official_card"
|
||||
);
|
||||
|
||||
final var selfSponsor = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_SELF_SPONSOR,
|
||||
"cta_shelf_card"
|
||||
);
|
||||
|
||||
final var chapterTeaser = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_CHAPTER_TEASER,
|
||||
"expandable_metadata",
|
||||
"macro_markers_carousel"
|
||||
);
|
||||
|
||||
final var viewProducts = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_PRODUCTS_BANNER,
|
||||
"product_item",
|
||||
"products_in_video"
|
||||
);
|
||||
|
||||
final var webLinkPanel = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_WEB_SEARCH_RESULTS,
|
||||
"web_link_panel"
|
||||
);
|
||||
|
||||
final var channelBar = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_CHANNEL_BAR,
|
||||
"channel_bar"
|
||||
);
|
||||
|
||||
final var relatedVideos = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_RELATED_VIDEOS,
|
||||
"fullscreen_related_videos"
|
||||
);
|
||||
|
||||
final var quickActions = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_QUICK_ACTIONS,
|
||||
"quick_actions"
|
||||
);
|
||||
|
||||
final var imageShelf = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_IMAGE_SHELF,
|
||||
"image_shelf"
|
||||
);
|
||||
|
||||
final var graySeparator = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_GRAY_SEPARATOR,
|
||||
"cell_divider" // layout residue (gray line above the buttoned ad),
|
||||
);
|
||||
|
||||
final var buttonedAd = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_BUTTONED_ADS,
|
||||
"_buttoned_layout",
|
||||
@ -192,107 +55,50 @@ public final class AdsFilter extends Filter {
|
||||
"offer_module_root"
|
||||
);
|
||||
|
||||
// region Mix playlists
|
||||
|
||||
mixPlaylists = new ByteArrayAsStringFilterGroup(
|
||||
SettingsEnum.HIDE_MIX_PLAYLISTS,
|
||||
"&list=",
|
||||
"YouTube Music"
|
||||
);
|
||||
|
||||
imageHosting = new ByteArrayAsStringFilterGroup(
|
||||
SettingsEnum.HIDE_MIX_PLAYLISTS, // Unused
|
||||
"ggpht.com"
|
||||
);
|
||||
|
||||
// endregion
|
||||
|
||||
this.pathFilterGroups.addAll(
|
||||
generalAds,
|
||||
buttonedAd,
|
||||
channelBar,
|
||||
communityPosts,
|
||||
paidContent,
|
||||
latestPosts,
|
||||
movieAds,
|
||||
chapterTeaser,
|
||||
communityGuidelines,
|
||||
quickActions,
|
||||
relatedVideos,
|
||||
compactBanner,
|
||||
inFeedSurvey,
|
||||
viewProducts,
|
||||
medicalPanel,
|
||||
merchandise,
|
||||
infoPanel,
|
||||
channelGuidelines,
|
||||
audioTrackButton,
|
||||
artistCard,
|
||||
selfSponsor,
|
||||
webLinkPanel,
|
||||
imageShelf,
|
||||
subscribersCommunityGuidelines,
|
||||
channelMemberShelf
|
||||
);
|
||||
|
||||
final var carouselAd = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_GENERAL_ADS,
|
||||
"carousel_ad"
|
||||
);
|
||||
|
||||
this.identifierFilterGroups.addAll(
|
||||
graySeparator,
|
||||
carouselAd
|
||||
final var viewProducts = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_PRODUCTS_BANNER,
|
||||
"product_item",
|
||||
"products_in_video"
|
||||
);
|
||||
}
|
||||
|
||||
private boolean isMixPlaylistFiltered(final byte[] _protobufBufferArray) {
|
||||
if (!mixPlaylists.isEnabled()) return false;
|
||||
final var webLinkPanel = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_WEB_SEARCH_RESULTS,
|
||||
"web_link_panel"
|
||||
);
|
||||
|
||||
// Two checks are required to prevent false positives.
|
||||
final var merchandise = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_MERCHANDISE_BANNERS,
|
||||
"product_carousel"
|
||||
);
|
||||
|
||||
// First check if the current buffer potentially contains a mix playlist.
|
||||
if (!mixPlaylists.check(_protobufBufferArray).isFiltered()) return false;
|
||||
final var selfSponsor = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_SELF_SPONSOR,
|
||||
"cta_shelf_card"
|
||||
);
|
||||
|
||||
// Ensure that the buffer actually contains a mix playlist.
|
||||
return imageHosting.check(_protobufBufferArray).isFiltered();
|
||||
this.pathFilterGroups.addAll(
|
||||
generalAds,
|
||||
buttonedAd,
|
||||
merchandise,
|
||||
viewProducts,
|
||||
selfSponsor,
|
||||
webLinkPanel,
|
||||
movieAds
|
||||
);
|
||||
this.identifierFilterGroups.addAll(carouselAd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFiltered(final String path, final String identifier, final byte[] _protobufBufferArray) {
|
||||
FilterResult result;
|
||||
if (ReVancedUtils.containsAny(path, exceptions))
|
||||
return false;
|
||||
|
||||
if (custom.isEnabled() && custom.check(path).isFiltered())
|
||||
result = FilterResult.CUSTOM;
|
||||
else if (ReVancedUtils.containsAny(path, exceptions))
|
||||
result = FilterResult.EXCEPTION;
|
||||
else {
|
||||
var filtered =
|
||||
pathFilterGroups.contains(path) || // Check if the path is filtered.
|
||||
identifierFilterGroups.contains(identifier) || // Check if the identifier is filtered.
|
||||
isMixPlaylistFiltered(_protobufBufferArray); // Check if the buffer contains a mix playlist.
|
||||
|
||||
result = filtered ? FilterResult.FILTERED : FilterResult.UNFILTERED;
|
||||
}
|
||||
|
||||
LogHelper.printDebug(() -> String.format("%s (ID: %s): %s", result.message, identifier, path));
|
||||
|
||||
return result.filter;
|
||||
}
|
||||
|
||||
private enum FilterResult {
|
||||
UNFILTERED(false, "Unfiltered"),
|
||||
EXCEPTION(false, "Exception"),
|
||||
FILTERED(true, "Filtered"),
|
||||
CUSTOM(true, "Custom");
|
||||
|
||||
final Boolean filter;
|
||||
final String message;
|
||||
|
||||
FilterResult(boolean filter, String message) {
|
||||
this.filter = filter;
|
||||
this.message = message;
|
||||
}
|
||||
return super.isFiltered(path, identifier, _protobufBufferArray);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,3 @@
|
||||
package app.revanced.integrations.patches.components;
|
||||
|
||||
final class DummyFilter extends Filter { }
|
@ -0,0 +1,222 @@
|
||||
package app.revanced.integrations.patches.components;
|
||||
|
||||
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
|
||||
|
||||
public final class LayoutComponentsFilter extends Filter {
|
||||
private final String[] exceptions;
|
||||
|
||||
private final CustomFilterGroup custom;
|
||||
|
||||
// region Mix playlists
|
||||
private final ByteArrayAsStringFilterGroup mixPlaylists;
|
||||
private final ByteArrayAsStringFilterGroup imageHosting;
|
||||
|
||||
// endregion
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
public LayoutComponentsFilter() {
|
||||
exceptions = new String[]{
|
||||
"home_video_with_context",
|
||||
"related_video_with_context",
|
||||
"comment_thread", // skip filtering anything in the comments
|
||||
"|comment.", // skip filtering anything in the comments replies
|
||||
"library_recent_shelf",
|
||||
};
|
||||
|
||||
custom = new CustomFilterGroup(
|
||||
SettingsEnum.CUSTOM_FILTER,
|
||||
SettingsEnum.CUSTOM_FILTER_STRINGS
|
||||
);
|
||||
|
||||
final var communityPosts = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_COMMUNITY_POSTS,
|
||||
"post_base_wrapper"
|
||||
);
|
||||
|
||||
final var communityGuidelines = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_COMMUNITY_GUIDELINES,
|
||||
"community_guidelines"
|
||||
);
|
||||
|
||||
final var subscribersCommunityGuidelines = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_SUBSCRIBERS_COMMUNITY_GUIDELINES,
|
||||
"sponsorships_comments_upsell"
|
||||
);
|
||||
|
||||
|
||||
final var channelMemberShelf = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_CHANNEL_MEMBER_SHELF,
|
||||
"member_recognition_shelf"
|
||||
);
|
||||
|
||||
final var compactBanner = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_COMPACT_BANNER,
|
||||
"compact_banner"
|
||||
);
|
||||
|
||||
final var inFeedSurvey = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_FEED_SURVEY,
|
||||
"in_feed_survey",
|
||||
"slimline_survey"
|
||||
);
|
||||
|
||||
final var medicalPanel = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_MEDICAL_PANELS,
|
||||
"medical_panel"
|
||||
);
|
||||
|
||||
final var paidContent = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_PAID_CONTENT,
|
||||
"paid_content_overlay"
|
||||
);
|
||||
|
||||
final var infoPanel = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_HIDE_INFO_PANELS,
|
||||
"publisher_transparency_panel",
|
||||
"single_item_information_panel"
|
||||
);
|
||||
|
||||
final var latestPosts = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_HIDE_LATEST_POSTS,
|
||||
"post_shelf"
|
||||
);
|
||||
|
||||
final var channelGuidelines = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_HIDE_CHANNEL_GUIDELINES,
|
||||
"channel_guidelines_entry_banner"
|
||||
);
|
||||
|
||||
final var audioTrackButton = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_AUDIO_TRACK_BUTTON,
|
||||
"multi_feed_icon_button"
|
||||
);
|
||||
|
||||
final var artistCard = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_ARTIST_CARDS,
|
||||
"official_card"
|
||||
);
|
||||
|
||||
final var expandableMetadata = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_EXPANDABLE_CHIP,
|
||||
"inline_expander"
|
||||
);
|
||||
|
||||
final var chapters = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_CHAPTERS,
|
||||
"macro_markers_carousel"
|
||||
);
|
||||
|
||||
final var channelBar = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_CHANNEL_BAR,
|
||||
"channel_bar"
|
||||
);
|
||||
|
||||
final var relatedVideos = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_RELATED_VIDEOS,
|
||||
"fullscreen_related_videos"
|
||||
);
|
||||
|
||||
final var quickActions = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_QUICK_ACTIONS,
|
||||
"quick_actions"
|
||||
);
|
||||
|
||||
final var imageShelf = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_IMAGE_SHELF,
|
||||
"image_shelf"
|
||||
);
|
||||
|
||||
final var graySeparator = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_GRAY_SEPARATOR,
|
||||
"cell_divider" // layout residue (gray line above the buttoned ad),
|
||||
);
|
||||
|
||||
// region Mix playlists
|
||||
|
||||
mixPlaylists = new ByteArrayAsStringFilterGroup(
|
||||
SettingsEnum.HIDE_MIX_PLAYLISTS,
|
||||
"&list=",
|
||||
"YouTube Music"
|
||||
);
|
||||
|
||||
imageHosting = new ByteArrayAsStringFilterGroup(
|
||||
SettingsEnum.HIDE_MIX_PLAYLISTS, // Unused
|
||||
"ggpht.com"
|
||||
);
|
||||
|
||||
// endregion
|
||||
|
||||
this.pathFilterGroups.addAll(
|
||||
channelBar,
|
||||
communityPosts,
|
||||
paidContent,
|
||||
latestPosts,
|
||||
chapters,
|
||||
communityGuidelines,
|
||||
quickActions,
|
||||
expandableMetadata,
|
||||
relatedVideos,
|
||||
compactBanner,
|
||||
inFeedSurvey,
|
||||
medicalPanel,
|
||||
infoPanel,
|
||||
channelGuidelines,
|
||||
audioTrackButton,
|
||||
artistCard,
|
||||
imageShelf,
|
||||
subscribersCommunityGuidelines,
|
||||
channelMemberShelf
|
||||
);
|
||||
|
||||
final var carouselAd = new StringFilterGroup(
|
||||
SettingsEnum.HIDE_GENERAL_ADS,
|
||||
"carousel_ad"
|
||||
);
|
||||
|
||||
this.identifierFilterGroups.addAll(
|
||||
graySeparator,
|
||||
carouselAd
|
||||
);
|
||||
}
|
||||
|
||||
private boolean isMixPlaylistFiltered(final byte[] _protobufBufferArray) {
|
||||
if (!mixPlaylists.isEnabled()) return false;
|
||||
|
||||
// Two checks are required to prevent false positives.
|
||||
|
||||
// First check if the current buffer potentially contains a mix playlist.
|
||||
if (!mixPlaylists.check(_protobufBufferArray).isFiltered()) return false;
|
||||
|
||||
// Ensure that the buffer actually contains a mix playlist.
|
||||
return imageHosting.check(_protobufBufferArray).isFiltered();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFiltered(final String path, final String identifier, final byte[] _protobufBufferArray) {
|
||||
if (custom.isEnabled() && custom.check(path).isFiltered())
|
||||
return true;
|
||||
|
||||
if (ReVancedUtils.containsAny(path, exceptions))
|
||||
return false; // Exceptions are not filtered.
|
||||
|
||||
if (super.isFiltered(path, identifier, _protobufBufferArray))
|
||||
return true;
|
||||
|
||||
return isMixPlaylistFiltered(_protobufBufferArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide the view, which shows ads in the homepage.
|
||||
*
|
||||
* @param view The view, which shows ads.
|
||||
*/
|
||||
public static void hideAdAttributionView(View view) {
|
||||
ReVancedUtils.hideViewBy1dpUnderCondition(SettingsEnum.HIDE_GENERAL_ADS, view);
|
||||
}
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
package app.revanced.integrations.patches.components;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
@ -12,10 +14,6 @@ import java.util.Iterator;
|
||||
import java.util.Spliterator;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
|
||||
abstract class FilterGroup<T> {
|
||||
final static class FilterGroupResult {
|
||||
private final boolean filtered;
|
||||
@ -235,15 +233,15 @@ abstract class Filter {
|
||||
@SuppressWarnings("unused")
|
||||
public final class LithoFilterPatch {
|
||||
private static final Filter[] filters = new Filter[]{
|
||||
new AdsFilter(),
|
||||
new ButtonsFilter(),
|
||||
new CommentsFilter(),
|
||||
new ShortsFilter()
|
||||
new DummyFilter() // Replaced by patch.
|
||||
};
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static boolean filter(final StringBuilder pathBuilder, final String identifier, final ByteBuffer protobufBuffer) {
|
||||
// TODO: Maybe this can be moved to the Filter class, to prevent unnecessary string creation
|
||||
// because some filters might not need the path.
|
||||
var path = pathBuilder.toString();
|
||||
|
||||
// It is assumed that protobufBuffer is empty as well in this case.
|
||||
if (path.isEmpty()) return false;
|
||||
|
||||
@ -254,10 +252,16 @@ public final class LithoFilterPatch {
|
||||
|
||||
var protobufBufferArray = protobufBuffer.array();
|
||||
|
||||
// check if any filter-group
|
||||
for (var filter : filters)
|
||||
if (filter.isFiltered(path, identifier, protobufBufferArray)) return true;
|
||||
for (var filter : filters) {
|
||||
var filtered = filter.isFiltered(path, identifier, protobufBufferArray);
|
||||
|
||||
LogHelper.printDebug(() ->
|
||||
String.format("%s (ID: %s): %s", filtered ? "Filtered" : "Unfiltered", identifier, path)
|
||||
);
|
||||
|
||||
if (filtered) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -67,7 +67,8 @@ public enum SettingsEnum {
|
||||
// Layout
|
||||
HIDE_CHANNEL_BAR("revanced_hide_channel_bar", BOOLEAN, FALSE),
|
||||
HIDE_CHANNEL_MEMBER_SHELF("revanced_hide_channel_member_shelf", BOOLEAN, TRUE),
|
||||
HIDE_CHAPTER_TEASER("revanced_hide_chapter_teaser", BOOLEAN, TRUE),
|
||||
HIDE_EXPANDABLE_CHIP("revanced_hide_expandable_chip", BOOLEAN, TRUE),
|
||||
HIDE_CHAPTERS("revanced_hide_chapters", BOOLEAN, TRUE),
|
||||
HIDE_COMMUNITY_GUIDELINES("revanced_hide_community_guidelines", BOOLEAN, TRUE),
|
||||
HIDE_COMMUNITY_POSTS("revanced_hide_community_posts", BOOLEAN, FALSE),
|
||||
HIDE_COMPACT_BANNER("revanced_hide_compact_banner", BOOLEAN, TRUE),
|
||||
@ -497,92 +498,16 @@ public enum SettingsEnum {
|
||||
setting.load();
|
||||
}
|
||||
|
||||
//
|
||||
// TODO: eventually delete this
|
||||
// renamed settings with new path names, but otherwise the new and old settings are identical
|
||||
//
|
||||
// TODO: eventually delete this.
|
||||
// region Migration
|
||||
|
||||
SettingsEnum[][] renamedSettings = {
|
||||
// TODO: do _not_ delete this SB private user id migration property until sometime in 2024.
|
||||
// This is the only setting that cannot be reconfigured if lost,
|
||||
// and more time should be given for users who rarely upgrade.
|
||||
{DEPRECATED_SB_UUID_OLD_MIGRATION_SETTING, SB_PRIVATE_USER_ID},
|
||||
|
||||
// TODO: delete the rest of these migration settings. When to delete? Anytime.
|
||||
{DEPRECATED_ADREMOVER_BUTTONED_REMOVAL, HIDE_BUTTONED_ADS},
|
||||
{DEPRECATED_ADREMOVER_GENERAL_ADS_REMOVAL, HIDE_GENERAL_ADS},
|
||||
{DEPRECATED_ADREMOVER_HIDE_LATEST_POSTS, HIDE_HIDE_LATEST_POSTS},
|
||||
{DEPRECATED_ADREMOVER_PAID_CONTENT, HIDE_PAID_CONTENT},
|
||||
{DEPRECATED_ADREMOVER_SELF_SPONSOR, HIDE_SELF_SPONSOR},
|
||||
{DEPRECATED_REMOVE_VIDEO_ADS, HIDE_VIDEO_ADS},
|
||||
{DEPRECATED_ADREMOVER_CUSTOM_ENABLED, CUSTOM_FILTER},
|
||||
{DEPRECATED_ADREMOVER_CUSTOM_REMOVAL, CUSTOM_FILTER_STRINGS},
|
||||
|
||||
{DEPRECATED_HIDE_CHANNEL_MEMBER_SHELF, HIDE_CHANNEL_MEMBER_SHELF},
|
||||
{DEPRECATED_HIDE_CHAPTER_TEASER, HIDE_CHAPTER_TEASER},
|
||||
{DEPRECATED_HIDE_COMMUNITY_GUIDELINES, HIDE_COMMUNITY_GUIDELINES},
|
||||
{DEPRECATED_HIDE_COMMUNITY_POSTS, HIDE_COMMUNITY_POSTS},
|
||||
{DEPRECATED_HIDE_COMPACT_BANNER, HIDE_COMPACT_BANNER},
|
||||
{DEPRECATED_HIDE_EMERGENCY_BOX, HIDE_EMERGENCY_BOX},
|
||||
{DEPRECATED_HIDE_FEED_SURVEY_REMOVAL, HIDE_FEED_SURVEY},
|
||||
{DEPRECATED_HIDE_GRAY_SEPARATOR, HIDE_GRAY_SEPARATOR},
|
||||
{DEPRECATED_HIDE_HIDE_CHANNEL_GUIDELINES, HIDE_HIDE_CHANNEL_GUIDELINES},
|
||||
{DEPRECATED_HIDE_INFO_PANEL_REMOVAL, HIDE_HIDE_INFO_PANELS},
|
||||
{DEPRECATED_HIDE_MEDICAL_PANEL_REMOVAL, HIDE_MEDICAL_PANELS},
|
||||
{DEPRECATED_HIDE_MERCHANDISE_REMOVAL, HIDE_MERCHANDISE_BANNERS},
|
||||
{DEPRECATED_HIDE_MOVIE_REMOVAL, HIDE_MOVIES_SECTION},
|
||||
{DEPRECATED_HIDE_SUBSCRIBERS_COMMUNITY_GUIDELINES_REMOVAL, HIDE_SUBSCRIBERS_COMMUNITY_GUIDELINES},
|
||||
{DEPRECATED_HIDE_VIEW_PRODUCTS, HIDE_PRODUCTS_BANNER},
|
||||
{DEPRECATED_HIDE_WEB_SEARCH_RESULTS, HIDE_WEB_SEARCH_RESULTS},
|
||||
{DEPRECATED_HIDE_SHORTS, HIDE_SHORTS},
|
||||
{DEPRECATED_DISABLE_RESUMING_SHORTS_PLAYER, DISABLE_RESUMING_SHORTS_PLAYER},
|
||||
{DEPRECATED_HIDE_INFO_CARDS, HIDE_INFO_CARDS},
|
||||
|
||||
{DEPRECATED_ETERNAL_DOWNLOADER, EXTERNAL_DOWNLOADER},
|
||||
{DEPRECATED_EXTERNAL_DOWNLOADER_PACKAGE_NAME, EXTERNAL_DOWNLOADER_PACKAGE_NAME},
|
||||
{DEPRECATED_COPY_VIDEO_URL, COPY_VIDEO_URL},
|
||||
{DEPRECATED_COPY_VIDEO_URL_TIMESTAMP, COPY_VIDEO_URL_TIMESTAMP},
|
||||
|
||||
{DEPRECATED_SHOW_OLD_VIDEO_MENU, SHOW_OLD_VIDEO_MENU},
|
||||
{DEPRECATED_VIDEO_QUALITY_DEFAULT_WIFI, VIDEO_QUALITY_DEFAULT_WIFI},
|
||||
{DEPRECATED_VIDEO_QUALITY_DEFAULT_MOBILE, VIDEO_QUALITY_DEFAULT_MOBILE},
|
||||
{DEPRECATED_PLAYBACK_SPEED_DEFAULT, PLAYBACK_SPEED_DEFAULT},
|
||||
|
||||
{DEPRECATED_AUTO_CAPTIONS, AUTO_CAPTIONS},
|
||||
{DEPRECATED_PLAYER_POPUP_PANELS, PLAYER_POPUP_PANELS},
|
||||
{DEPRECATED_SWIPE_BRIGHTNESS, SWIPE_BRIGHTNESS},
|
||||
{DEPRECATED_SWIPE_VOLUME, SWIPE_VOLUME},
|
||||
{DEPRECATED_PRESS_TO_SWIPE, SWIPE_PRESS_TO_ENGAGE},
|
||||
{DEPRECATED_SWIPE_HAPTIC_FEEDBACK, SWIPE_HAPTIC_FEEDBACK},
|
||||
|
||||
{DEPRECATED_DEBUG, DEBUG},
|
||||
{DEPRECATED_DEBUG_STACKTRACE, DEBUG_STACKTRACE},
|
||||
{DEPRECATED_DEBUG_TOAST_ON_ERROR, DEBUG_TOAST_ON_ERROR},
|
||||
|
||||
{DEPRECATED_EXTERNAL_BROWSER, EXTERNAL_BROWSER},
|
||||
{DEPRECATED_AUTO_REPEAT, AUTO_REPEAT},
|
||||
{DEPRECATED_TAP_SEEKING, SEEKBAR_TAPPING},
|
||||
{DEPRECATED_HDR_AUTO_BRIGHTNESS, HDR_AUTO_BRIGHTNESS},
|
||||
|
||||
{DEPRECATED_RYD_USER_ID, RYD_USER_ID},
|
||||
{DEPRECATED_RYD_DISLIKE_PERCENTAGE, RYD_DISLIKE_PERCENTAGE},
|
||||
{DEPRECATED_RYD_COMPACT_LAYOUT, RYD_COMPACT_LAYOUT},
|
||||
|
||||
{DEPRECATED_SB_ENABLED, SB_ENABLED},
|
||||
{DEPRECATED_SB_VOTING_BUTTON, SB_VOTING_BUTTON},
|
||||
{DEPRECATED_SB_CREATE_NEW_SEGMENT, SB_CREATE_NEW_SEGMENT},
|
||||
{DEPRECATED_SB_COMPACT_SKIP_BUTTON, SB_COMPACT_SKIP_BUTTON},
|
||||
{DEPRECATED_SB_MIN_DURATION, SB_SEGMENT_MIN_DURATION},
|
||||
{DEPRECATED_SB_VIDEO_LENGTH_WITHOUT_SEGMENTS, SB_VIDEO_LENGTH_WITHOUT_SEGMENTS},
|
||||
{DEPRECATED_SB_API_URL, SB_API_URL},
|
||||
{DEPRECATED_SB_TOAST_ON_SKIP, SB_TOAST_ON_SKIP},
|
||||
{DEPRECATED_SB_AUTO_HIDE_SKIP_BUTTON, SB_AUTO_HIDE_SKIP_BUTTON},
|
||||
{DEPRECATED_SB_TRACK_SKIP_COUNT, SB_TRACK_SKIP_COUNT},
|
||||
{DEPRECATED_SB_ADJUST_NEW_SEGMENT_STEP, SB_CREATE_NEW_SEGMENT_STEP},
|
||||
{DEPRECATED_SB_LAST_VIP_CHECK, SB_LAST_VIP_CHECK},
|
||||
{DEPRECATED_SB_IS_VIP, SB_USER_IS_VIP},
|
||||
{DEPRECATED_SB_LOCAL_TIME_SAVED_NUMBER_SEGMENTS, SB_LOCAL_TIME_SAVED_NUMBER_SEGMENTS},
|
||||
{DEPRECATED_SB_LOCAL_TIME_SAVED_MILLISECONDS, SB_LOCAL_TIME_SAVED_MILLISECONDS},
|
||||
};
|
||||
|
||||
for (SettingsEnum[] oldNewSetting : renamedSettings) {
|
||||
SettingsEnum oldSetting = oldNewSetting[0];
|
||||
SettingsEnum newSetting = oldNewSetting[1];
|
||||
@ -594,9 +519,8 @@ public enum SettingsEnum {
|
||||
oldSetting.saveValue(oldSetting.defaultValue); // reset old value
|
||||
}
|
||||
}
|
||||
//
|
||||
// TODO end
|
||||
//
|
||||
|
||||
// endregion
|
||||
}
|
||||
|
||||
private void load() {
|
||||
|
@ -13,12 +13,9 @@ public final class FilterPromotedLinksPatch {
|
||||
final List<Object> filteredList = new ArrayList<>();
|
||||
|
||||
for (Object item : links) {
|
||||
if (!(item instanceof ILink)) continue;
|
||||
if (item instanceof ILink && ((ILink) item).getPromoted()) continue;
|
||||
|
||||
final var link = (ILink) item;
|
||||
final var isPromotedAd = link.getPromoted();
|
||||
|
||||
if (!isPromotedAd) filteredList.add(item);
|
||||
filteredList.add(item);
|
||||
}
|
||||
|
||||
return filteredList;
|
||||
|
@ -1,3 +1,3 @@
|
||||
org.gradle.jvmargs = -Xmx2048m
|
||||
android.useAndroidX = true
|
||||
version = 0.110.0
|
||||
version = 0.111.0-dev.3
|
||||
|
Loading…
Reference in New Issue
Block a user