Skip to content

Commit

Permalink
reminder, shorts promo cards, small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
dayanch96 committed Jul 10, 2023
1 parent 25dc28e commit 95fe3a9
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ endif
DEBUG=0
FINALPACKAGE=1
ARCHS = arm64
PACKAGE_VERSION = 2.2
PACKAGE_VERSION = 2.2.1
TARGET := iphone:clang:latest:11.0

include $(THEOS)/makefiles/common.mk
Expand Down
54 changes: 48 additions & 6 deletions Settings.x
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ static const NSInteger YTLiteSection = 789;

static void resetYTLiteSettings() {
NSString *prefsPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"YTLite.plist"];
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager removeItemAtPath:prefsPath error:nil];
[[NSFileManager defaultManager] removeItemAtPath:prefsPath error:nil];

[[UIApplication sharedApplication] performSelector:@selector(suspend)];
[NSThread sleepForTimeInterval:1.0];
exit(0);
}

NSBundle *YTLiteBundle() {
Expand Down Expand Up @@ -218,7 +221,8 @@ static YTSettingsSectionItem *createSwitchItem(NSString *title, NSString *titleD
createSwitchItem(LOC(@"HideShortsThanks"), LOC(@"HideShortsThanksDesc"), @"hideShortsThanks", &kHideShortsThanks, selfObject),
createSwitchItem(LOC(@"HideShortsChannelName"), LOC(@"HideShortsChannelNameDesc"), @"hideShortsChannelName", &kHideShortsChannelName, selfObject),
createSwitchItem(LOC(@"HideShortsDescription"), LOC(@"HideShortsDescriptionDesc"), @"hideShortsDescription", &kHideShortsDescription, selfObject),
createSwitchItem(LOC(@"HideShortsAudioTrack"), LOC(@"HideShortsAudioTrackDesc"), @"hideShortsAudioTrack", &kHideShortsAudioTrack, selfObject)
createSwitchItem(LOC(@"HideShortsAudioTrack"), LOC(@"HideShortsAudioTrackDesc"), @"hideShortsAudioTrack", &kHideShortsAudioTrack, selfObject),
createSwitchItem(LOC(@"NoPromotionCards"), LOC(@"NoPromotionCardsDesc"), @"hideShortsPromoCards", &kHideShortsPromoCards, selfObject)
];
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"Shorts") pickerSectionTitle:nil rows:rows selectedItemIndex:NSNotFound parentResponder:[self parentResponder]];
[settingsViewController pushViewController:picker];
Expand Down Expand Up @@ -355,14 +359,29 @@ static YTSettingsSectionItem *createSwitchItem(NSString *title, NSString *titleD
return [%c(YTUIUtils) openURL:[NSURL URLWithString:@"https://github.com/LillieH1000"]];
}];

YTSettingsSectionItem *stalker = [%c(YTSettingsSectionItem) itemWithTitle:@"Stalker" titleDescription:LOC(@"ChineseSimplified") accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
return [%c(YTUIUtils) openURL:[NSURL URLWithString:@"https://github.com/xiangfeidexiaohuo"]];
}];

YTSettingsSectionItem *clement = [%c(YTSettingsSectionItem) itemWithTitle:@"Clement" titleDescription:LOC(@"ChineseTraditional") accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
return [%c(YTUIUtils) openURL:[NSURL URLWithString:@"https://twitter.com/a100900900"]];
}];

YTSettingsSectionItem *balackburn = [%c(YTSettingsSectionItem) itemWithTitle:@"Balackburn" titleDescription:LOC(@"French") accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
return [%c(YTUIUtils) openURL:[NSURL URLWithString:@"https://github.com/Balackburn"]];
}];

YTSettingsSectionItem *decibelios = [%c(YTSettingsSectionItem) itemWithTitle:@"DeciBelioS" titleDescription:LOC(@"Spanish") accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
return [%c(YTUIUtils) openURL:[NSURL URLWithString:@"https://github.com/Deci8BelioS"]];
}];

YTSettingsSectionItem *dayanch96 = [%c(YTSettingsSectionItem) itemWithTitle:@"Dayanch96" titleDescription:LOC(@"Developer") accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
return [%c(YTUIUtils) openURL:[NSURL URLWithString:@"https://github.com/Dayanch96/"]];
}];

YTSettingsSectionItem *reset = [%c(YTSettingsSectionItem) itemWithTitle:LOC(@"ResetSettings") titleDescription:nil accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
YTAlertView *alertView = [%c(YTAlertView) confirmationDialogWithAction:^{
resetYTLiteSettings();
exit(0);
}
actionTitle:LOC(@"Yes")
cancelTitle:LOC(@"No")];
Expand All @@ -378,7 +397,7 @@ static YTSettingsSectionItem *createSwitchItem(NSString *title, NSString *titleD
return @(OS_STRINGIFY(TWEAK_VERSION));
}
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
NSArray <YTSettingsSectionItem *> *rows = @[ps, miro, lillie, dayanch96, space, createSwitchItem(LOC(@"Advanced"), nil, @"advancedMode", &kAdvancedMode, selfObject), reset];
NSArray <YTSettingsSectionItem *> *rows = @[ps, miro, lillie, dayanch96, stalker, clement, balackburn, decibelios, space, createSwitchItem(LOC(@"Advanced"), nil, @"advancedMode", &kAdvancedMode, selfObject), reset];

YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"About") pickerSectionTitle:LOC(@"Credits") rows:rows selectedItemIndex:NSNotFound parentResponder:[self parentResponder]];
[settingsViewController pushViewController:picker];
Expand All @@ -395,4 +414,27 @@ static YTSettingsSectionItem *createSwitchItem(NSString *title, NSString *titleD
return;
} %orig;
}
%end
%end

%ctor {
if (!kAdvancedModeReminder && !kAdvancedMode) {
NSString *prefsPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"YTLite.plist"];
NSMutableDictionary *prefs = [NSMutableDictionary dictionaryWithContentsOfFile:prefsPath];
[prefs setObject:@(YES) forKey:@"advancedModeReminder"];
[prefs writeToFile:prefsPath atomically:NO];
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.dvntm.ytlite.prefschanged"), NULL, NULL, YES);

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
YTAlertView *alertView = [%c(YTAlertView) confirmationDialogWithAction:^{
[prefs setObject:@(YES) forKey:@"advancedMode"];
[prefs writeToFile:prefsPath atomically:NO];
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.dvntm.ytlite.prefschanged"), NULL, NULL, YES);
}
actionTitle:LOC(@"Yes")
cancelTitle:LOC(@"No")];
alertView.title = @"YTLite";
alertView.subtitle = [NSString stringWithFormat:LOC(@"AdvancedModeReminder"), @"YTLite", LOC(@"Version"), LOC(@"Advanced")];
[alertView show];
});
}
}
11 changes: 11 additions & 0 deletions YTLite.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ BOOL kHideShortsThanks;
BOOL kHideShortsChannelName;
BOOL kHideShortsDescription;
BOOL kHideShortsAudioTrack;
BOOL kHideShortsPromoCards;
BOOL kRemoveLabels;
BOOL kReExplore;
BOOL kRemoveShorts;
Expand All @@ -86,6 +87,7 @@ BOOL kRemoveLibrary;
BOOL kRemovePlayNext;
BOOL kNoContinueWatching;
BOOL kAdvancedMode;
BOOL kAdvancedModeReminder;
int kPivotIndex;

@interface YTSettingsSectionItemManager (Custom)
Expand All @@ -110,6 +112,12 @@ int kPivotIndex;
@property (nonatomic, strong) YTQTMButton *searchButton;
@end

@interface YTSearchView : UIView
@end

@interface YTSearchBarView : UIView
@end

@interface YTNavigationBarTitleView : UIView
@end

Expand Down Expand Up @@ -151,6 +159,9 @@ int kPivotIndex;
@interface YTReelWatchHeaderView : UIView
@end

@interface YTELMView : UIView
@end

@interface MLHAMQueuePlayer : NSObject
@property id playerEventCenter;
-(void)setRate:(float)rate;
Expand Down
64 changes: 61 additions & 3 deletions YTLite.x
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@
if (self.hasCompatibilityOptions && self.compatibilityOptions.hasAdLoggingData && kNoAds)
return nil;
NSString *description = [self description];
if (([description containsString:@"brand_promo"]
if ((([description containsString:@"brand_promo"]
|| [description containsString:@"product_carousel"]
|| [description containsString:@"product_engagement_panel"]
|| [description containsString:@"product_item"]) && kNoAds)
|| ([description containsString:@"inline_shorts"] && kHideShorts))
return [NSData data];
return %orig;
}
Expand Down Expand Up @@ -114,6 +115,32 @@
}
%end

%hook YTSearchView
- (void)layoutSubviews {
%orig;

if (kNoVoiceSearchButton && self.subviews.count > 0) {
UIView *firstSubview = self.subviews.firstObject;
if (firstSubview.subviews.count > 1) {
UIView *subview1 = firstSubview.subviews[1];
[subview1 setValue:@(1) forKey:@"hidden"];
}
}
}
%end

%hook YTSearchBarView
- (void)layoutSubviews {
%orig;

if (kNoVoiceSearchButton && ![self.superview isKindOfClass:objc_lookUpClass("YTNavigationBarTitleView")]) {
CGRect frame = self.frame;
frame.size.width += 20;
self.frame = frame;
}
}
%end

// Hide YouTube Logo
%hook YTNavigationBarTitleView
- (void)layoutSubviews { %orig; if (kNoYTLogo && self.subviews.count > 1 && [self.subviews[1].accessibilityIdentifier isEqualToString:@"id.yoodle.logo"]) self.subviews[1].hidden = YES; }
Expand Down Expand Up @@ -343,6 +370,21 @@
}
%end

// Fit Shorts Button Labels For Localizations
%hook YTReelPlayerButton
- (void)layoutSubviews {
%orig;

for (UIView *subview in self.subviews) {
if ([subview isKindOfClass:[UILabel class]]) {
UILabel *label = (UILabel *)subview;
label.adjustsFontSizeToFitWidth = YES;
break;
}
}
}
%end

// Fix Playlist Mini-bar Height For Small Screens
%hook YTPlaylistMiniBarView
- (void)setFrame:(CGRect)frame {
Expand Down Expand Up @@ -453,9 +495,21 @@
- (void)layoutSubviews {
%orig;
if (kHideShortsDescription && [self.subviews[2].accessibilityIdentifier isEqualToString:@"id.reels_smv_player_title_label"]) self.subviews[2].hidden = YES;
if (kHideShortsThanks && [self.subviews[self.subviews.count - 3].accessibilityIdentifier isEqualToString:@"id.elements.components.suggested_action"]) self.subviews[self.subviews.count - 3].hidden = YES;
if (kHideShortsThanks && [self.subviews[self.subviews.count - 3].accessibilityIdentifier isEqualToString:@"id.elements.components.suggested_action"]) self.subviews[self.subviews.count - 3].hidden = YES; // Might be useful for older versions
if (kHideShortsChannelName) self.subviews[self.subviews.count - 2].hidden = YES;
if (kHideShortsAudioTrack) self.subviews.lastObject.hidden = YES;
for (UIView *subview in self.subviews) {
if (kHideShortsPromoCards && [NSStringFromClass([subview class]) isEqualToString:@"YTBadge"]) {
subview.hidden = YES;
}
}
}
%end

%hook YTELMView
- (void)layoutSubviews {
%orig;
if (kHideShortsThanks && [self.subviews.firstObject.accessibilityIdentifier isEqualToString:@"id.elements.components.suggested_action"]) self.subviews.firstObject.hidden = YES;
}
%end

Expand Down Expand Up @@ -680,6 +734,7 @@ static void reloadPrefs() {
kHideShortsChannelName = [prefs[@"hideShortsChannelName"] boolValue] ?: NO;
kHideShortsDescription = [prefs[@"hideShortsDescription"] boolValue] ?: NO;
kHideShortsAudioTrack = [prefs[@"hideShortsAudioTrack"] boolValue] ?: NO;
kHideShortsPromoCards = [prefs[@"hideShortsPromoCards"] boolValue] ?: NO;
kRemoveLabels = [prefs[@"removeLabels"] boolValue] ?: NO;
kReExplore = [prefs[@"reExplore"] boolValue] ?: NO;
kRemoveShorts = [prefs[@"removeShorts"] boolValue] ?: NO;
Expand All @@ -690,6 +745,7 @@ static void reloadPrefs() {
kNoContinueWatching = [prefs[@"noContinueWatching"] boolValue] ?: NO;
kPivotIndex = (prefs[@"pivotIndex"] != nil) ? [prefs[@"pivotIndex"] intValue] : 0;
kAdvancedMode = [prefs[@"advancedMode"] boolValue] ?: NO;
kAdvancedModeReminder = [prefs[@"advancedModeReminder"] boolValue] ?: NO;

NSDictionary *newSettings = @{
@"noAds" : @(kNoAds),
Expand Down Expand Up @@ -742,6 +798,7 @@ static void reloadPrefs() {
@"hideShortsChannelName" : @(kHideShortsChannelName),
@"hideShortsDescription" : @(kHideShortsDescription),
@"hideShortsAudioTrack" : @(kHideShortsAudioTrack),
@"hideShortsPromoCards" : @(kHideShortsPromoCards),
@"removeLabels" : @(kRemoveLabels),
@"reExplore" : @(kReExplore),
@"removeShorts" : @(kRemoveShorts),
Expand All @@ -751,7 +808,8 @@ static void reloadPrefs() {
@"removePlayNext" : @(kRemovePlayNext),
@"noContinueWatching" : @(kNoContinueWatching),
@"pivotIndex" : @(kPivotIndex),
@"advancedMode" : @(kAdvancedMode)
@"advancedMode" : @(kAdvancedMode),
@"advancedModeReminder" : @(kAdvancedModeReminder)
};

if (![newSettings isEqualToDictionary:prefs]) [newSettings writeToFile:path atomically:NO];
Expand Down
Binary file removed layout/Library/Application Support/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@
"About" = "About";
"Credits" = "Credits";
"Developer" = "YTLite developer";
"ChineseSimplified" = "Chinese (Simplified) localization";
"ChineseTraditional" = "Chinese (Traditional) localization";
"French" = "French localization";
"Spanish" = "Spanish localization";
"Advanced" = "Advanced mode";
"AdvancedModeReminder" = "Would you like to activate Advanced mode for YTLite?\n\nThis mode provides more than 50 additional options to customize and optimize your YouTube experience. You can enable/disable it later from Settings → %@ → %@ → %@.";
"ResetSettings" = "Reset YTLite settings";
"ResetMessage" = "This option will reset YTLite settings to default and close YouTube.\n\nAre you sure you want to continue?";
"Yes" = "Yes";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@
"About" = "Acerca de";
"Credits" = "Créditos";
"Developer" = "Desarrollador de YTLite";
"ChineseSimplified" = "Chinese (Simplified) localization";
"ChineseTraditional" = "Chinese (Traditional) localization";
"French" = "French localization";
"Spanish" = "Spanish localization";
"Advanced" = "Modo avanzado";
"AdvancedModeReminder" = "Would you like to activate Advanced mode for YTLite?\n\nThis mode provides more than 50 additional options to customize and optimize your YouTube experience. You can enable/disable it later from Settings → %@ → %@ → %@.";
"ResetSettings" = "Restablecer configuración de YTLite";
"ResetMessage" = "Esta opción restablecerá la configuración de YTLite a los valores predeterminados y cerrará YouTube.\n\n¿Estás seguro de que deseas continuar?";
"Yes" = "Sí";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@
"About" = "À propos";
"Credits" = "Crédits";
"Developer" = "Développeur YTLite";
"ChineseSimplified" = "Chinese (Simplified) localization";
"ChineseTraditional" = "Chinese (Traditional) localization";
"French" = "French localization";
"Spanish" = "Spanish localization";
"Advanced" = "Mode avancé";
"AdvancedModeReminder" = "Would you like to activate Advanced mode for YTLite?\n\nThis mode provides more than 50 additional options to customize and optimize your YouTube experience. You can enable/disable it later from Settings → %@ → %@ → %@.";
"ResetSettings" = "Réinitialiser les paramètres YTLite";
"ResetMessage" = "Cette option réinitialisera les paramètres YTLite par défaut et fermera YouTube.\n\nÊtes-vous sûr de vouloir continuer ?";
"Yes" = "Oui";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@
"About" = "О твике";
"Credits" = "Авторы";
"Developer" = "Разработчик твика";
"ChineseSimplified" = "Китайская (упрощенная) локализация";
"ChineseTraditional" = "Китайская (традиционная) локализация";
"French" = "Французская локализация";
"Spanish" = "Испанская локализация";
"Advanced" = "Расширенный режим";
"AdvancedModeReminder" = "Хотите ли вы активировать расширенный режим настроек YTLite?\n\nДанный режим добавляет более 50 опций для тонкой настройки YouTube. Вы всегда сможете включить/отключить расширенный режим перейдя в Настройки → %@ → %@ → %@.";
"ResetSettings" = "Сбросить настройки твика";
"ResetMessage" = "Данное действие сбросит настройки YTLite к значениям по умолчанию и закроет YouTube.\n\nУверены, что хотите продолжить?";
"Yes" = "Да";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,13 @@
"About" = "关于";
"Credits" = "信息";
"Developer" = "YTLite开发者";
"ChineseSimplified" = "Chinese (Simplified) localization";
"ChineseTraditional" = "Chinese (Traditional) localization";
"French" = "French localization";
"Spanish" = "Spanish localization";
"Advanced" = "高级模式";
"AdvancedModeReminder" = "Would you like to activate Advanced mode for YTLite?\n\nThis mode provides more than 50 additional options to customize and optimize your YouTube experience. You can enable/disable it later from Settings → %@ → %@ → %@.";
"ResetSettings" = "重置YTLite设置";
"ResetMessage" = "此选项会将YTLite设置重置为默认值并关闭YouTube。\n\n确定要继续吗?";
"Yes" = "是";
"No" = "不";
"No" = "不";
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@
"About" = "關於";
"Credits" = "貢獻";
"Developer" = "YTLite開發者";
"ChineseSimplified" = "Chinese (Simplified) localization";
"ChineseTraditional" = "Chinese (Traditional) localization";
"French" = "French localization";
"Spanish" = "Spanish localization";
"Advanced" = "進階模式";
"AdvancedModeReminder" = "Would you like to activate Advanced mode for YTLite?\n\nThis mode provides more than 50 additional options to customize and optimize your YouTube experience. You can enable/disable it later from Settings → %@ → %@ → %@.";
"ResetSettings" = "重置YTLite設定";
"ResetMessage" = "這個選項會將YTLite重置為預設值,並關閉Youtube\n\n您確定要繼續嗎?";
"Yes" = "是";
Expand Down
Binary file added packages/com.dvntm.ytlite_2.2.1_iphoneos-arm.deb
Binary file not shown.
Binary file not shown.

0 comments on commit 95fe3a9

Please sign in to comment.