hide Paid promotion card by @PoomSmart

This commit is contained in:
qnblackcat
2022-06-30 10:28:19 +07:00
parent ca0650d73a
commit c2d1581698
2 changed files with 56 additions and 9 deletions
+11 -1
View File
@@ -22,6 +22,7 @@ extern BOOL hideAutoplaySwitch();
extern BOOL castConfirm(); extern BOOL castConfirm();
extern BOOL ytMiniPlayer(); extern BOOL ytMiniPlayer();
extern BOOL hidePreviousAndNextButton(); extern BOOL hidePreviousAndNextButton();
extern BOOL hidePaidPromotionCard();
// Settings // Settings
%hook YTAppSettingsPresentationData %hook YTAppSettingsPresentationData
@@ -41,6 +42,15 @@ extern BOOL hidePreviousAndNextButton();
YTSettingsViewController *delegate = [self valueForKey:@"_dataDelegate"]; YTSettingsViewController *delegate = [self valueForKey:@"_dataDelegate"];
NSBundle *tweakBundle = uYouPlusBundle(); NSBundle *tweakBundle = uYouPlusBundle();
YTSettingsSectionItem *hidePaidPromotionCard = [[%c(YTSettingsSectionItem) alloc] initWithTitle:LOC(@"HIDE_PAID_PROMOTION_CARDS") titleDescription:LOC(@"HIDE_PAID_PROMOTION_CARDS_DESC")];
hidePaidPromotionCard.hasSwitch = YES;
hidePaidPromotionCard.switchVisible = YES;
hidePaidPromotionCard.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"hidePaidPromotionCard_enabled"];
hidePaidPromotionCard.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hidePaidPromotionCard_enabled"];
return YES;
};
YTSettingsSectionItem *hidePreviousAndNextButton = [[%c(YTSettingsSectionItem) alloc] initWithTitle:LOC(@"HIDE_PREVIOUS_AND_NEXT_BUTTON") titleDescription:LOC(@"HIDE_PREVIOUS_AND_NEXT_BUTTON_DESC")]; YTSettingsSectionItem *hidePreviousAndNextButton = [[%c(YTSettingsSectionItem) alloc] initWithTitle:LOC(@"HIDE_PREVIOUS_AND_NEXT_BUTTON") titleDescription:LOC(@"HIDE_PREVIOUS_AND_NEXT_BUTTON_DESC")];
hidePreviousAndNextButton.hasSwitch = YES; hidePreviousAndNextButton.hasSwitch = YES;
hidePreviousAndNextButton.switchVisible = YES; hidePreviousAndNextButton.switchVisible = YES;
@@ -149,7 +159,7 @@ extern BOOL hidePreviousAndNextButton();
return YES; return YES;
}; };
NSMutableArray <YTSettingsSectionItem *> *sectionItems = [NSMutableArray arrayWithArray:@[autoFull, castConfirm, ytMiniPlayer, hideAutoplaySwitch, hideCC, hideHUD, hidePreviousAndNextButton, hideHoverCard, bigYTMiniPlayer, oledDarkMode, oledKeyBoard, reExplore]]; NSMutableArray <YTSettingsSectionItem *> *sectionItems = [NSMutableArray arrayWithArray:@[autoFull, castConfirm, ytMiniPlayer, hideAutoplaySwitch, hideCC, hideHUD, hidePaidPromotionCard, hidePreviousAndNextButton, hideHoverCard, bigYTMiniPlayer, oledDarkMode, oledKeyBoard, reExplore]];
[delegate setSectionItems:sectionItems forCategory:uYouPlusSection title:@"uYouPlus" titleDescription:nil headerHidden:NO]; [delegate setSectionItems:sectionItems forCategory:uYouPlusSection title:@"uYouPlus" titleDescription:nil headerHidden:NO];
} }
+45 -8
View File
@@ -13,6 +13,8 @@
#import "Tweaks/YouTubeHeader/YTIBrowseRequest.h" #import "Tweaks/YouTubeHeader/YTIBrowseRequest.h"
#import "Tweaks/YouTubeHeader/YTCommonColorPalette.h" #import "Tweaks/YouTubeHeader/YTCommonColorPalette.h"
#import "Tweaks/YouTubeHeader/ASCollectionView.h" #import "Tweaks/YouTubeHeader/ASCollectionView.h"
#import "Tweaks/YouTubeHeader/YTPlayerOverlay.h"
#import "Tweaks/YouTubeHeader/YTPlayerOverlayProvider.h"
// Tweak's bundle for Localizations support - @PoomSmart - https://github.com/PoomSmart/YouPiP/commit/aea2473f64c75d73cab713e1e2d5d0a77675024f // Tweak's bundle for Localizations support - @PoomSmart - https://github.com/PoomSmart/YouPiP/commit/aea2473f64c75d73cab713e1e2d5d0a77675024f
NSBundle *uYouPlusBundle() { NSBundle *uYouPlusBundle() {
@@ -66,6 +68,9 @@ BOOL castConfirm() {
BOOL ytMiniPlayer() { BOOL ytMiniPlayer() {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"ytMiniPlayer_enabled"]; return [[NSUserDefaults standardUserDefaults] boolForKey:@"ytMiniPlayer_enabled"];
} }
BOOL hidePaidPromotionCard(){
return [[NSUserDefaults standardUserDefaults] boolForKey:@"hidePaidPromotionCard_enabled"];
}
# pragma mark - Tweaks # pragma mark - Tweaks
// YTMiniPlayerEnabler: https://github.com/level3tjg/YTMiniplayerEnabler/ // YTMiniPlayerEnabler: https://github.com/level3tjg/YTMiniplayerEnabler/
@@ -277,6 +282,37 @@ BOOL ytMiniPlayer() {
} }
%end %end
//
%hook FRPSliderCell
- (void)didMoveToWindow {
%orig;
if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
MSHookIvar<UILabel *>(self, "_lLabel").textColor = [UIColor whiteColor];
MSHookIvar<UILabel *>(self, "_rLabel").textColor = [UIColor whiteColor];
MSHookIvar<UILabel *>(self, "_cLabel").textColor = [UIColor whiteColor];
}
}
%end
// Hide Paid Promotion Card
%hook YTMainAppVideoPlayerOverlayViewController
- (void)setPaidContentWithPlayerData:(id)data {
if (hidePaidPromotionCard()) {}
else { return %orig; }
}
- (void)playerOverlayProvider:(YTPlayerOverlayProvider *)provider didInsertPlayerOverlay:(YTPlayerOverlay *)overlay {
if ([[overlay overlayIdentifier] isEqualToString:@"player_overlay_paid_content"] && hidePaidPromotionCard()) return;
%orig;
}
%end
%hook YTInlineMutedPlaybackPlayerOverlayViewController
- (void)setPaidContentWithPlayerData:(id)data {
if (hidePaidPromotionCard()) {}
else { return %orig; }
}
%end
# pragma mark - IAmYouTube - https://github.com/PoomSmart/IAmYouTube/ # pragma mark - IAmYouTube - https://github.com/PoomSmart/IAmYouTube/
%hook YTVersionUtils %hook YTVersionUtils
+ (NSString *)appName { return YT_NAME; } + (NSString *)appName { return YT_NAME; }
@@ -333,6 +369,7 @@ BOOL ytMiniPlayer() {
%end %end
# pragma mark - OLED dark mode by BandarHL # pragma mark - OLED dark mode by BandarHL
UIColor* raisedColor = [UIColor colorWithRed:0.02 green:0.02 blue:0.02 alpha:1.0];
%group gOLED %group gOLED
%hook YTCommonColorPalette %hook YTCommonColorPalette
- (UIColor *)brandBackgroundSolid { - (UIColor *)brandBackgroundSolid {
@@ -349,13 +386,13 @@ BOOL ytMiniPlayer() {
} }
- (UIColor *)brandBackgroundSecondary { - (UIColor *)brandBackgroundSecondary {
if (self.pageStyle == 1) { if (self.pageStyle == 1) {
return [[UIColor blackColor] colorWithAlphaComponent:0.88]; return [[UIColor blackColor] colorWithAlphaComponent:0.9];
} }
return %orig; return %orig;
} }
- (UIColor *)raisedBackground { - (UIColor *)raisedBackground {
if (self.pageStyle == 1) { if (self.pageStyle == 1) {
return [UIColor blackColor]; return raisedColor;
} }
return %orig; return %orig;
} }
@@ -518,11 +555,11 @@ BOOL ytMiniPlayer() {
- (void)didMoveToWindow { - (void)didMoveToWindow {
%orig; %orig;
if (isDarkMode()) { if (isDarkMode()) {
if ([self.nextResponder isKindOfClass:%c(ASScrollView)]) { self.backgroundColor = [UIColor clearColor]; } if ([self.nextResponder isKindOfClass:%c(ASScrollView)]) { self.backgroundColor = raisedColor; }
if ([self.accessibilityIdentifier isEqualToString:@"eml.cvr"]) { self.backgroundColor = [UIColor blackColor]; } if ([self.accessibilityIdentifier isEqualToString:@"eml.cvr"]) { self.backgroundColor = [UIColor blackColor]; }
if ([self.accessibilityIdentifier isEqualToString:@"rich_header"]) { self.backgroundColor = [UIColor blackColor]; } if ([self.accessibilityIdentifier isEqualToString:@"rich_header"]) { self.backgroundColor = [UIColor blackColor]; }
if ([self.accessibilityIdentifier isEqualToString:@"id.ui.comment_cell"]) { self.backgroundColor = [UIColor blackColor]; } if ([self.accessibilityIdentifier isEqualToString:@"id.ui.comment_cell"]) { self.backgroundColor = [UIColor blackColor]; }
if ([self.accessibilityIdentifier isEqualToString:@"id.ui.cancel.button"]) { self.superview.backgroundColor = [UIColor blackColor]; } if ([self.accessibilityIdentifier isEqualToString:@"id.ui.cancel.button"]) { self.superview.backgroundColor = raisedColor; }
if ([self.accessibilityIdentifier isEqualToString:@"id.elements.components.filter_chip_bar"]) { self.backgroundColor = [UIColor blackColor]; } if ([self.accessibilityIdentifier isEqualToString:@"id.elements.components.filter_chip_bar"]) { self.backgroundColor = [UIColor blackColor]; }
if ([self.accessibilityIdentifier isEqualToString:@"id.elements.components.comment_composer"]) { self.backgroundColor = [UIColor blackColor]; } if ([self.accessibilityIdentifier isEqualToString:@"id.elements.components.comment_composer"]) { self.backgroundColor = [UIColor blackColor]; }
if ([self.accessibilityIdentifier isEqualToString:@"id.elements.components.video_list_entry"]) { self.backgroundColor = [UIColor blackColor]; } if ([self.accessibilityIdentifier isEqualToString:@"id.elements.components.video_list_entry"]) { self.backgroundColor = [UIColor blackColor]; }
@@ -537,7 +574,7 @@ BOOL ytMiniPlayer() {
%hook ASWAppSwitchingSheetHeaderView %hook ASWAppSwitchingSheetHeaderView
- (void)setBackgroundColor:(UIColor *)color { - (void)setBackgroundColor:(UIColor *)color {
if (isDarkMode()) { if (isDarkMode()) {
return %orig([UIColor blackColor]); return %orig(raisedColor);
} }
return %orig; return %orig;
} }
@@ -546,7 +583,7 @@ BOOL ytMiniPlayer() {
%hook ASWAppSwitchingSheetFooterView %hook ASWAppSwitchingSheetFooterView
- (void)setBackgroundColor:(UIColor *)color { - (void)setBackgroundColor:(UIColor *)color {
if (isDarkMode()) { if (isDarkMode()) {
return %orig([UIColor blackColor]); return %orig(raisedColor);
} }
return %orig; return %orig;
} }
@@ -556,8 +593,8 @@ BOOL ytMiniPlayer() {
- (void)didMoveToWindow { - (void)didMoveToWindow {
%orig; %orig;
if (isDarkMode()) { if (isDarkMode()) {
self.subviews[1].backgroundColor = [UIColor blackColor]; self.subviews[1].backgroundColor = raisedColor;
self.superview.backgroundColor = [UIColor blackColor]; self.superview.backgroundColor = raisedColor;
} }
} }
%end %end