Skip to content

Commit 4fa79b7

Browse files
committed
Bugfixes, Remove Play Next and Continue Watching options
1 parent 2568dec commit 4fa79b7

9 files changed

Lines changed: 223 additions & 149 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ endif
55
DEBUG=0
66
FINALPACKAGE=1
77
ARCHS = arm64
8-
PACKAGE_VERSION = 2.0
8+
PACKAGE_VERSION = 2.1
99
TARGET := iphone:clang:latest:11.0
1010

1111
include $(THEOS)/makefiles/common.mk

Settings.x

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ static YTSettingsSectionItem *createSwitchItem(NSString *title, NSString *titleD
119119
NSArray <YTSettingsSectionItem *> *rows = @[
120120
createSwitchItem(LOC(@"RemoveCast"), LOC(@"RemoveCastDesc"), @"noCast", &kNoCast, selfObject),
121121
createSwitchItem(LOC(@"RemoveNotifications"), LOC(@"RemoveNotificationsDesc"), @"removeNotifsButton", &kNoNotifsButton, selfObject),
122-
createSwitchItem(LOC(@"RemoveSearch"), LOC(@"RemoveSearchDesc"), @"removeSearchButton", &kNoSearchButton, selfObject)
122+
createSwitchItem(LOC(@"RemoveSearch"), LOC(@"RemoveSearchDesc"), @"removeSearchButton", &kNoSearchButton, selfObject),
123+
createSwitchItem(LOC(@"RemoveVoiceSearch"), LOC(@"RemoveVoiceSearchDesc"), @"removeVoiceSearchButton", &kNoVoiceSearchButton, selfObject)
123124
];
124125

125126
if (kAdvancedMode) {
@@ -153,7 +154,7 @@ static YTSettingsSectionItem *createSwitchItem(NSString *title, NSString *titleD
153154
createSwitchItem(LOC(@"HidePrevNext"), LOC(@"HidePrevNextDesc"), @"hidePrevNext", &kHidePrevNext, selfObject),
154155
createSwitchItem(LOC(@"ReplacePrevNext"), LOC(@"ReplacePrevNextDesc"), @"replacePrevNext", &kReplacePrevNext, selfObject),
155156
createSwitchItem(LOC(@"NoDarkBg"), LOC(@"NoDarkBgDesc"), @"noDarkBg", &kNoDarkBg, selfObject),
156-
createSwitchItem(LOC(@"NoEndScreenCards"), LOC(@"NoEndScreenCardsDesc"), @"noEndScreenCards", &kEndScreenCards, selfObject),
157+
createSwitchItem(LOC(@"NoEndScreenCards"), LOC(@"NoEndScreenCardsDesc"), @"endScreenCards", &kEndScreenCards, selfObject),
157158
createSwitchItem(LOC(@"NoFullscreenActions"), LOC(@"NoFullscreenActionsDesc"), @"noFullscreenActions", &kNoFullscreenActions, selfObject),
158159
createSwitchItem(LOC(@"NoRelatedVids"), LOC(@"NoRelatedVidsDesc"), @"noRelatedVids", &kNoRelatedVids, selfObject),
159160
createSwitchItem(LOC(@"NoPromotionCards"), LOC(@"NoPromotionCardsDesc"), @"noPromotionCards", &kNoPromotionCards, selfObject),
@@ -246,6 +247,23 @@ static YTSettingsSectionItem *createSwitchItem(NSString *title, NSString *titleD
246247
[sectionItems addObject:tabbar];
247248

248249
if (kAdvancedMode) {
250+
YTSettingsSectionItem *other = [YTSettingsSectionItemClass itemWithTitle:LOC(@"Other")
251+
accessibilityIdentifier:nil
252+
detailTextBlock:^NSString *() {
253+
return @"";
254+
}
255+
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
256+
NSArray <YTSettingsSectionItem *> *rows = @[
257+
createSwitchItem(LOC(@"RemovePlayNext"), LOC(@"RemovePlayNextDesc"), @"removePlayNext", &kRemovePlayNext, selfObject),
258+
createSwitchItem(LOC(@"NoContinueWatching"), LOC(@"NoContinueWatchingDesc"), @"noContinueWatching", &kNoContinueWatching, selfObject)
259+
];
260+
261+
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"Other") pickerSectionTitle:nil rows:rows selectedItemIndex:NSNotFound parentResponder:[self parentResponder]];
262+
[settingsViewController pushViewController:picker];
263+
return YES;
264+
}];
265+
[sectionItems addObject:other];
266+
249267
[sectionItems addObject:space];
250268

251269
YTSettingsSectionItem *startup = [YTSettingsSectionItemClass itemWithTitle:LOC(@"Startup")

YTLite.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#import "../YouTubeHeader/YTSettingsSectionItemManager.h"
1818
#import "../YouTubeHeader/YTSettingsPickerViewController.h"
1919
#import "../YouTubeHeader/YTUIUtils.h"
20+
#import "../YouTubeHeader/YTIMenuConditionalServiceItemRenderer.h"
2021

2122
extern NSBundle *YTLiteBundle();
2223

@@ -30,6 +31,7 @@ BOOL kBackgroundPlayback;
3031
BOOL kNoCast;
3132
BOOL kNoNotifsButton;
3233
BOOL kNoSearchButton;
34+
BOOL kNoVoiceSearchButton;
3335
BOOL kStickyNavbar;
3436
BOOL kNoSubbar;
3537
BOOL kNoYTLogo;
@@ -78,6 +80,8 @@ BOOL kRemoveShorts;
7880
BOOL kRemoveSubscriptions;
7981
BOOL kRemoveUploads;
8082
BOOL kRemoveLibrary;
83+
BOOL kRemovePlayNext;
84+
BOOL kNoContinueWatching;
8185
BOOL kAdvancedMode;
8286
int kPivotIndex;
8387

@@ -106,6 +110,9 @@ int kPivotIndex;
106110
@interface YTNavigationBarTitleView : UIView
107111
@end
108112

113+
@interface YTChipCloudCell : UICollectionViewCell
114+
@end
115+
109116
@interface YTSegmentableInlinePlayerBarView
110117
@property (nonatomic, assign, readwrite) BOOL enableSnapToChapter;
111118
@end
@@ -125,7 +132,7 @@ int kPivotIndex;
125132
@end
126133

127134
@interface YTAsyncCollectionView : UICollectionView
128-
- (void)removeShortsCellAtIndexPath:(NSIndexPath *)indexPath;
135+
- (void)removeCellsAtIndexPath:(NSIndexPath *)indexPath;
129136
@end
130137

131138
@interface YTReelWatchPlaybackOverlayView : UIView

YTLite.x

Lines changed: 65 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,19 @@
2828
- (void)decorateContext:(id)context { if (!kNoAds) %orig; }
2929
%end
3030

31-
BOOL isAd(YTIElementRenderer *self) {
32-
if (self == nil) return NO;
33-
if (self.hasCompatibilityOptions && self.compatibilityOptions.hasAdLoggingData) return YES;
31+
%hook YTIElementRenderer
32+
- (NSData *)elementData {
33+
if (self.hasCompatibilityOptions && self.compatibilityOptions.hasAdLoggingData)
34+
return nil;
3435
NSString *description = [self description];
3536
if (([description containsString:@"brand_promo"]
3637
|| [description containsString:@"product_carousel"]
3738
|| [description containsString:@"product_engagement_panel"]
3839
|| [description containsString:@"product_item"]) && kNoAds)
39-
return YES;
40-
return NO;
40+
return [NSData data];
41+
return %orig;
4142
}
43+
%end
4244

4345
%hook YTSectionListViewController
4446
- (void)loadWithModel:(YTISectionListRenderer *)model {
@@ -47,7 +49,7 @@ BOOL isAd(YTIElementRenderer *self) {
4749
NSIndexSet *removeIndexes = [contentsArray indexesOfObjectsPassingTest:^BOOL(YTISectionListSupportedRenderers *renderers, NSUInteger idx, BOOL *stop) {
4850
YTIItemSectionRenderer *sectionRenderer = renderers.itemSectionRenderer;
4951
YTIItemSectionSupportedRenderers *firstObject = [sectionRenderer.contentsArray firstObject];
50-
return firstObject.hasPromotedVideoRenderer || firstObject.hasCompactPromotedVideoRenderer || firstObject.hasPromotedVideoInlineMutedRenderer || isAd(firstObject.elementRenderer);
52+
return firstObject.hasPromotedVideoRenderer || firstObject.hasCompactPromotedVideoRenderer || firstObject.hasPromotedVideoInlineMutedRenderer;
5153
}];
5254
[contentsArray removeObjectsAtIndexes:removeIndexes];
5355
} %orig;
@@ -89,15 +91,6 @@ BOOL isAd(YTIElementRenderer *self) {
8991
- (void)showSurveyWithRenderer:(id)arg1 surveyParentResponder:(id)arg2 {}
9092
%end
9193

92-
// Statement banner
93-
%hook YTPremiumSeasonCardCellController
94-
- (void)setCell:(id)arg1 { arg1 = NULL; %orig; }
95-
%end
96-
97-
%hook YTPremiumSeasonCardView
98-
- (long long)accessibilityElementCount { return 0; }
99-
%end
100-
10194
// Navbar Stuff
10295
// Disable Cast
10396
%hook MDXPlaybackRouteButtonController
@@ -117,6 +110,7 @@ BOOL isAd(YTIElementRenderer *self) {
117110
if (kNoCast && self.subviews.count > 1 && [self.subviews[1].accessibilityIdentifier isEqualToString:@"id.mdx.playbackroute.button"]) self.subviews[1].hidden = YES; // Hide icon immediately
118111
if (kNoNotifsButton) self.notificationButton.hidden = YES;
119112
if (kNoSearchButton) self.searchButton.hidden = YES;
113+
if (kNoVoiceSearchButton && self.subviews.count >= 4 && [self.subviews[2].accessibilityIdentifier isEqualToString:@"id.settings.overflow.button"]) self.subviews[3].hidden = YES;
120114
}
121115
%end
122116

@@ -131,16 +125,21 @@ BOOL isAd(YTIElementRenderer *self) {
131125
%end
132126

133127
// Remove Subbar
134-
%hook YTMySubsFilterHeaderView
128+
%hook YTMySubsFilterHeaderView
135129
- (void)setChipFilterView:(id)arg1 { if (!kNoSubbar) %orig; }
136130
%end
137131

138132
%hook YTHeaderContentComboView
139133
- (void)enableSubheaderBarWithView:(id)arg1 { if (!kNoSubbar) %orig; }
134+
- (void)setFeedHeaderScrollMode:(int)arg1 { kNoSubbar ? %orig(0) : %orig; }
140135
%end
141136

142-
%hook YTHeaderContentComboView
143-
- (void)setFeedHeaderScrollMode:(int)arg1 { kNoSubbar ? %orig(0) : %orig; }
137+
%hook YTChipCloudCell
138+
- (void)layoutSubviews {
139+
if (self.superview && kNoSubbar) {
140+
[self removeFromSuperview];
141+
} %orig;
142+
}
144143
%end
145144

146145
// Hide Autoplay Switch and Subs Button
@@ -271,27 +270,55 @@ BOOL isAd(YTIElementRenderer *self) {
271270
- (void)enableDoubleTapToSeek:(BOOL)arg1 { kNoDoubleTapToSeek ? %orig(NO) : %orig; }
272271
%end
273272

274-
// Remove Shorts (https://github.com/MiRO92/YTNoShorts)
273+
// Fit 'Play All' Buttons Text For Localizations
274+
%hook YTQTMButton
275+
- (void)layoutSubviews {
276+
if ([self.accessibilityIdentifier isEqualToString:@"id.playlist.playall.button"]) {
277+
self.titleLabel.adjustsFontSizeToFitWidth = YES;
278+
} %orig;
279+
}
280+
%end
281+
282+
// Fix Playlist Mini-bar Height For Small Screens
283+
%hook YTPlaylistMiniBarView
284+
- (void)setFrame:(CGRect)frame {
285+
if (frame.size.height < 54.0) frame.size.height = 54.0;
286+
%orig(frame);
287+
}
288+
%end
289+
290+
// Remove "Play next in queue" from the menu @PoomSmart (https://github.com/qnblackcat/uYouPlus/issues/1138#issuecomment-1606415080)
291+
%hook YTMenuItemVisibilityHandler
292+
- (BOOL)shouldShowServiceItemRenderer:(YTIMenuConditionalServiceItemRenderer *)renderer {
293+
if (kRemovePlayNext && renderer.icon.iconType == 251) {
294+
return NO;
295+
} return %orig;
296+
}
297+
%end
298+
299+
// Remove Premium Pop-up, Horizontal Video Carousel and Shorts (https://github.com/MiRO92/YTNoShorts)
275300
%hook YTAsyncCollectionView
276301
- (id)cellForItemAtIndexPath:(NSIndexPath *)indexPath {
277-
if (kHideShorts) {
278-
UICollectionViewCell *cell = %orig;
279-
if ([cell isKindOfClass:NSClassFromString(@"_ASCollectionViewCell")]) {
280-
_ASCollectionViewCell *cell = %orig;
281-
if ([cell respondsToSelector:@selector(node)]) {
282-
if ([[[cell node] accessibilityIdentifier] isEqualToString:@"eml.shorts-shelf"]) {
283-
[self removeShortsCellAtIndexPath:indexPath];
284-
}
302+
UICollectionViewCell *cell = %orig;
303+
304+
if ([cell isKindOfClass:objc_lookUpClass("_ASCollectionViewCell")]) {
305+
_ASCollectionViewCell *cell = %orig;
306+
if ([cell respondsToSelector:@selector(node)]) {
307+
NSString *idToRemove = [[cell node] accessibilityIdentifier];
308+
if ([idToRemove isEqualToString:@"statement_banner.view"] ||
309+
(([idToRemove isEqualToString:@"eml.shorts-grid"] || [idToRemove isEqualToString:@"eml.shorts-shelf"]) && kHideShorts)) {
310+
[self removeCellsAtIndexPath:indexPath];
285311
}
286-
} else if ([cell isKindOfClass:NSClassFromString(@"YTReelShelfCell")]) {
287-
[self removeShortsCellAtIndexPath:indexPath];
288-
} return %orig;
312+
}
313+
} else if (([cell isKindOfClass:objc_lookUpClass("YTReelShelfCell")] && kHideShorts) ||
314+
([cell isKindOfClass:objc_lookUpClass("YTHorizontalCardListCell")] && kNoContinueWatching)) {
315+
[self removeCellsAtIndexPath:indexPath];
289316
} return %orig;
290317
}
291318

292319
%new
293-
- (void)removeShortsCellAtIndexPath:(NSIndexPath *)indexPath {
294-
[self deleteItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]];
320+
- (void)removeCellsAtIndexPath:(NSIndexPath *)indexPath {
321+
[self deleteItemsAtIndexPaths:@[indexPath]];
295322
}
296323
%end
297324

@@ -544,6 +571,7 @@ static void reloadPrefs() {
544571
kNoCast = [prefs[@"noCast"] boolValue] ?: NO;
545572
kNoNotifsButton = [prefs[@"removeNotifsButton"] boolValue] ?: NO;
546573
kNoSearchButton = [prefs[@"removeSearchButton"] boolValue] ?: NO;
574+
kNoVoiceSearchButton = [prefs[@"removeVoiceSearchButton"] boolValue] ?: NO;
547575
kStickyNavbar = [prefs[@"stickyNavbar"] boolValue] ?: NO;
548576
kNoSubbar = [prefs[@"noSubbar"] boolValue] ?: NO;
549577
kNoYTLogo = [prefs[@"noYTLogo"] boolValue] ?: NO;
@@ -592,6 +620,8 @@ static void reloadPrefs() {
592620
kRemoveSubscriptions = [prefs[@"removeSubscriptions"] boolValue] ?: NO;
593621
kRemoveUploads = (prefs[@"removeUploads"] != nil) ? [prefs[@"removeUploads"] boolValue] : YES;
594622
kRemoveLibrary = [prefs[@"removeLibrary"] boolValue] ?: NO;
623+
kRemovePlayNext = [prefs[@"removePlayNext"] boolValue] ?: NO;
624+
kNoContinueWatching = [prefs[@"noContinueWatching"] boolValue] ?: NO;
595625
kPivotIndex = (prefs[@"pivotIndex"] != nil) ? [prefs[@"pivotIndex"] intValue] : 0;
596626
kAdvancedMode = [prefs[@"advancedMode"] boolValue] ?: NO;
597627

@@ -601,6 +631,7 @@ static void reloadPrefs() {
601631
@"noCast" : @(kNoCast),
602632
@"removeNotifsButton" : @(kNoNotifsButton),
603633
@"removeSearchButton" : @(kNoSearchButton),
634+
@"removeVoiceSearchButton" : @(kNoVoiceSearchButton),
604635
@"stickyNavbar" : @(kStickyNavbar),
605636
@"noSubbar" : @(kNoSubbar),
606637
@"noYTLogo" : @(kNoYTLogo),
@@ -649,6 +680,8 @@ static void reloadPrefs() {
649680
@"removeSubscriptions" : @(kRemoveSubscriptions),
650681
@"removeUploads" : @(kRemoveUploads),
651682
@"removeLibrary" : @(kRemoveLibrary),
683+
@"removePlayNext" : @(kRemovePlayNext),
684+
@"noContinueWatching" : @(kNoContinueWatching),
652685
@"pivotIndex" : @(kPivotIndex),
653686
@"advancedMode" : @(kAdvancedMode)
654687
};

layout/Library/Application Support/YTLite.bundle/en.lproj/Localizable.strings

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"RemoveNotificationsDesc" = "Hides Notifications button from the Navigation bar.";
1212
"RemoveSearch" = "Hide Search button";
1313
"RemoveSearchDesc" = "Hides Search button from the Navigation bar.";
14+
"RemoveVoiceSearch" = "Hide Voice search button";
15+
"RemoveVoiceSearchDesc" = "Hides Voice search button from the Navigation bar.";
1416
"StickyNavbar" = "Sticky Navigation bar";
1517
"StickyNavbarDesc" = "Pins the Navigation bar so that it remains visible when scrolling down.";
1618
"NoSubbar" = "Hide Subbar";
@@ -116,6 +118,12 @@
116118
"HideShortsAudioTrack" = "Hide AudioTrack";
117119
"HideShortsAudioTrackDesc" = "Hides AudioTrack under Shorts description.";
118120

121+
"Other" = "Other";
122+
"RemovePlayNext" = "Remove \"Play next in queue\"";
123+
"RemovePlayNextDesc" = "Removes \"Play next in queue\" option from menu.";
124+
"NoContinueWatching" = "Remove \"Continue watching\"";
125+
"NoContinueWatchingDesc" = "Removes the \"Continue watching\" section containing unfinished videos from the Home page.";
126+
119127
"Startup" = "Startup page";
120128
"Home" = "Home";
121129
"Explore" = "Explore";

layout/Library/Application Support/YTLite.bundle/ru.lproj/Localizable.strings

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"RemoveNotifications" = "Скрыть «Уведомления»";
1111
"RemoveNotificationsDesc" = "Скрывает кнопку уведомлений с панели навигации.";
1212
"RemoveSearch" = "Скрыть «Поиск»";
13-
"RemoveSearchDesc" = "Скрвыает кнопку поиска с панели навигации.";
13+
"RemoveSearchDesc" = "Скрывает кнопку поиска с панели навигации.";
14+
"RemoveVoiceSearch" = "Скрыть «Голосовой поиск»";
15+
"RemoveVoiceSearchDesc" = "Скрывает кнопку голосового поиска с панели навигации.";
1416
"StickyNavbar" = "Закрепить панель навигации";
1517
"StickyNavbarDesc" = "Закрепляет панель навигации в верхней части экрана, запрещая ему скрываться во время скролла страницы вниз.";
1618
"NoSubbar" = "Скрыть наклейки";
@@ -116,6 +118,12 @@
116118
"HideShortsAudioTrack" = "Скрыть аудиодорожку";
117119
"HideShortsAudioTrackDesc" = "Скрывает информацию об аудиодорожке в нижней части плеера.";
118120

121+
"Other" = "Другие настройки";
122+
"RemovePlayNext" = "Убрать «Добавить в начало очереди»";
123+
"RemovePlayNextDesc" = "Убирает опцию «Добавить в начало очереди» из меню видео.";
124+
"NoContinueWatching" = "Отключить «Продолжить просмотр»";
125+
"NoContinueWatchingDesc" = "Удаляет блок «Продолжить просмотр» содержащий недосмотренные видео с Главной страницы.";
126+
119127
"Startup" = "Начальная страница";
120128
"Home" = "Главная";
121129
"Explore" = "Навигация";

0 commit comments

Comments
 (0)