forked from arichornlover/YouTube-Reborn-v5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tweak.xm
2704 lines (2517 loc) · 99.5 KB
/
Tweak.xm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#import "Tweak.h"
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
#define YT_BUNDLE_ID @"com.google.ios.youtube"
#define YT_NAME @"YouTube"
static BOOL isDarkMode() {
return ([[NSUserDefaults standardUserDefaults] integerForKey:@"page_style"] == 1);
}
static BOOL hasDeviceNotch() {
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
return NO;
} else {
LAContext *context = [[LAContext alloc] init];
[context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil];
return [context biometryType] == LABiometryTypeFaceID;
}
}
UIColor *rebornHexColour;
UIColor *lcmHexColor;
YTLocalPlaybackController *playingVideoID;
%hook YTLocalPlaybackController
- (NSString *)currentVideoID {
playingVideoID = self;
return %orig;
}
%end
YTSingleVideo *shortsPlayingVideoID;
%hook YTSingleVideo
- (NSString *)videoId {
shortsPlayingVideoID = self;
return %orig;
}
%end
YTUserDefaults *ytThemeSettings;
%hook YTUserDefaults
- (long long)appThemeSetting {
ytThemeSettings = self;
return %orig;
}
%end
YTMainAppVideoPlayerOverlayViewController *resultOut;
YTMainAppVideoPlayerOverlayViewController *layoutOut;
YTMainAppVideoPlayerOverlayViewController *stateOut;
%hook YTMainAppVideoPlayerOverlayViewController
- (CGFloat)mediaTime {
resultOut = self;
return %orig;
}
- (int)playerViewLayout {
layoutOut = self;
return %orig;
}
- (NSInteger)playerState {
stateOut = self;
return %orig;
}
%end
// Keychain patching
static NSString *accessGroupID() {
NSDictionary *query = [NSDictionary dictionaryWithObjectsAndKeys:
(__bridge NSString *)kSecClassGenericPassword, (__bridge NSString *)kSecClass,
@"bundleSeedID", kSecAttrAccount,
@"", kSecAttrService,
(id)kCFBooleanTrue, kSecReturnAttributes,
nil];
CFDictionaryRef result = nil;
OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, (CFTypeRef *)&result);
if (status == errSecItemNotFound)
status = SecItemAdd((__bridge CFDictionaryRef)query, (CFTypeRef *)&result);
if (status != errSecSuccess)
return nil;
NSString *accessGroup = [(__bridge NSDictionary *)result objectForKey:(__bridge NSString *)kSecAttrAccessGroup];
return accessGroup;
}
// IAmYouTube - https://github.com/PoomSmart/IAmYouTube
%hook YTVersionUtils
+ (NSString *)appName { return YT_NAME; }
+ (NSString *)appID { return YT_BUNDLE_ID; }
%end
%hook GCKBUtils
+ (NSString *)appIdentifier { return YT_BUNDLE_ID; }
%end
%hook GPCDeviceInfo
+ (NSString *)bundleId { return YT_BUNDLE_ID; }
%end
%hook OGLBundle
+ (NSString *)shortAppName { return YT_NAME; }
%end
%hook GVROverlayView
+ (NSString *)appName { return YT_NAME; }
%end
%hook OGLPhenotypeFlagServiceImpl
- (NSString *)bundleId { return YT_BUNDLE_ID; }
%end
%hook APMAEU
+ (BOOL)isFAS { return YES; }
%end
%hook GULAppEnvironmentUtil
+ (BOOL)isFromAppStore { return YES; }
%end
%hook SSOConfiguration
- (id)initWithClientID:(id)clientID supportedAccountServices:(id)supportedAccountServices {
self = %orig;
[self setValue:YT_NAME forKey:@"_shortAppName"];
[self setValue:YT_BUNDLE_ID forKey:@"_applicationIdentifier"];
return self;
}
%end
%hook NSBundle
- (NSString *)bundleIdentifier {
NSArray *address = [NSThread callStackReturnAddresses];
Dl_info info = {0};
if (dladdr((void *)[address[2] longLongValue], &info) == 0)
return %orig;
NSString *path = [NSString stringWithUTF8String:info.dli_fname];
if ([path hasPrefix:NSBundle.mainBundle.bundlePath])
return YT_BUNDLE_ID;
return %orig;
}
- (id)objectForInfoDictionaryKey:(NSString *)key {
if ([key isEqualToString:@"CFBundleIdentifier"])
return YT_BUNDLE_ID;
if ([key isEqualToString:@"CFBundleDisplayName"] || [key isEqualToString:@"CFBundleName"])
return YT_NAME;
return %orig;
}
// Fix Google Sign in by @PoomSmart and @level3tjg (qnblackcat/uYouPlus#684)
- (NSDictionary *)infoDictionary {
NSMutableDictionary *info = %orig.mutableCopy;
NSString *altBundleIdentifier = info[@"ALTBundleIdentifier"];
if (altBundleIdentifier) info[@"CFBundleIdentifier"] = altBundleIdentifier;
return info;
}
%end
// Fix login for YouTube 18.13.2 and higher
%hook SSOKeychainHelper
+ (NSString *)accessGroup {
return accessGroupID();
}
+ (NSString *)sharedAccessGroup {
return accessGroupID();
}
%end
// Fix login for YouTube 17.33.2 and higher
%hook SSOKeychainCore
+ (NSString *)accessGroup {
return accessGroupID();
}
+ (NSString *)sharedAccessGroup {
return accessGroupID();
}
%end
// Fix App Group Directory by moving it to documents directory
%hook NSFileManager
- (NSURL *)containerURLForSecurityApplicationGroupIdentifier:(NSString *)groupIdentifier {
if (groupIdentifier != nil) {
NSArray *paths = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask];
NSURL *documentsURL = [paths lastObject];
return [documentsURL URLByAppendingPathComponent:@"AppGroup"];
}
return %orig(groupIdentifier);
}
%end
%group gPictureInPicture
%hook YTPlayerPIPController
- (BOOL)isPictureInPicturePossible {
return YES;
}
- (BOOL)canEnablePictureInPicture {
return YES;
}
- (BOOL)isPipSettingEnabled {
return YES;
}
- (BOOL)isPictureInPictureForceDisabled {
return NO;
}
- (void)setPictureInPictureForceDisabled:(BOOL)arg1 {
%orig(NO);
}
%end
%hook YTLocalPlaybackController
- (BOOL)isPictureInPicturePossible {
return YES;
}
%end
%hook YTBackgroundabilityPolicy
- (BOOL)isPlayableInPictureInPictureByUserSettings {
return YES;
}
%end
%hook YTLightweightPlayerViewController
- (BOOL)isPictureInPicturePossible {
return YES;
}
%end
%hook YTPlayerViewController
- (BOOL)isPictureInPicturePossible {
return YES;
}
%end
%hook YTPlayerResponse
- (BOOL)isPlayableInPictureInPicture {
return YES;
}
- (BOOL)isPipOffByDefault {
return NO;
}
%end
%hook MLPIPController
- (BOOL)pictureInPictureSupported {
return YES;
}
%end
%end
%hook YTRightNavigationButtons
%property (retain, nonatomic) YTQTMButton *youtubeRebornButton;
- (NSMutableArray *)buttons {
NSString *tweakBundlePath = [[NSBundle mainBundle] pathForResource:@"YouTubeReborn" ofType:@"bundle"];
NSString *youtubeRebornLightSettingsPath;
NSString *youtubeRebornDarkSettingsPath;
if (tweakBundlePath) {
NSBundle *tweakBundle = [NSBundle bundleWithPath:tweakBundlePath];
youtubeRebornLightSettingsPath = [tweakBundle pathForResource:@"ytrebornbuttonwhite" ofType:@"png"];
youtubeRebornDarkSettingsPath = [tweakBundle pathForResource:@"ytrebornbuttonblack" ofType:@"png"];
} else {
youtubeRebornLightSettingsPath = ROOT_PATH_NS(@"/Library/Application Support/YouTubeReborn.bundle/ytrebornbuttonwhite.png");
youtubeRebornDarkSettingsPath = ROOT_PATH_NS(@"/Library/Application Support/YouTubeReborn.bundle/ytrebornbuttonblack.png");
}
NSMutableArray *retVal = %orig.mutableCopy;
[self.youtubeRebornButton removeFromSuperview];
[self addSubview:self.youtubeRebornButton];
if (!self.youtubeRebornButton) {
self.youtubeRebornButton = [%c(YTQTMButton) iconButton];
self.youtubeRebornButton.frame = CGRectMake(0, 0, 24, 24);
if ([%c(YTPageStyleController) pageStyle] == 0) {
[self.youtubeRebornButton setImage:[UIImage imageWithContentsOfFile:youtubeRebornDarkSettingsPath] forState:UIControlStateNormal];
}
else if ([%c(YTPageStyleController) pageStyle] == 1) {
[self.youtubeRebornButton setImage:[UIImage imageWithContentsOfFile:youtubeRebornLightSettingsPath] forState:UIControlStateNormal];
}
[self.youtubeRebornButton addTarget:self action:@selector(rebornRootOptionsAction) forControlEvents:UIControlEventTouchUpInside];
[retVal insertObject:self.youtubeRebornButton atIndex:0];
}
return retVal;
}
- (NSMutableArray *)visibleButtons {
NSMutableArray *retVal = %orig.mutableCopy;
[self setLeadingPadding:+10];
if (self.youtubeRebornButton) {
[self.youtubeRebornButton removeFromSuperview];
[self addSubview:self.youtubeRebornButton];
[retVal insertObject:self.youtubeRebornButton atIndex:0];
}
return retVal;
}
%new;
- (void)rebornRootOptionsAction {
RootOptionsController *rootOptionsController = [[RootOptionsController alloc] initWithStyle:UITableViewStyleGrouped];
UINavigationController *rootOptionsControllerView = [[UINavigationController alloc] initWithRootViewController:rootOptionsController];
rootOptionsControllerView.modalPresentationStyle = UIModalPresentationFullScreen;
UIViewController *rootPrefsViewController = [self _viewControllerForAncestor];
[rootPrefsViewController presentViewController:rootOptionsControllerView animated:YES completion:nil];
}
%end
%hook YTMainAppControlsOverlayView
%property(retain, nonatomic) UIButton *rebornOverlayButton;
- (id)initWithDelegate:(id)delegate {
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"15.0") && [[NSUserDefaults standardUserDefaults] boolForKey:@"kRebornIHaveYouTubePremium"] == NO && [[NSUserDefaults standardUserDefaults] boolForKey:@"kEnablePictureInPictureVTwo"] == YES) {
%init(gPictureInPicture);
}
self = %orig;
if (self) {
self.rebornOverlayButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[self.rebornOverlayButton addTarget:self action:@selector(rebornOptionsAction) forControlEvents:UIControlEventTouchUpInside];
[self.rebornOverlayButton setTitle:@"DL" forState:UIControlStateNormal];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"kShowStatusBarInOverlay"] == YES) {
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"kEnableiPadStyleOniPhone"] == YES) {
self.rebornOverlayButton.frame = CGRectMake(40, 9, 40.0, 30.0);
} else {
self.rebornOverlayButton.frame = CGRectMake(40, 24, 40.0, 30.0);
}
} else {
self.rebornOverlayButton.frame = CGRectMake(40, 9, 40.0, 30.0);
}
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"kHideRebornOPButtonVTwo"] == YES) {
self.rebornOverlayButton.hidden = YES;
}
[self addSubview:self.rebornOverlayButton];
}
return self;
}
- (void)setTopOverlayVisible:(BOOL)visible isAutonavCanceledState:(BOOL)canceledState {
if (canceledState) {
if (!self.rebornOverlayButton.hidden) {
self.rebornOverlayButton.alpha = 0.0;
}
} else {
if (!self.rebornOverlayButton.hidden) {
int rotation = [layoutOut playerViewLayout];
if (rotation == 2) {
self.rebornOverlayButton.alpha = visible ? 1.0 : 0.0;
} else {
self.rebornOverlayButton.alpha = 0.0;
}
}
}
%orig;
}
%new;
- (void)rebornOptionsAction {
NSInteger videoStatus = [stateOut playerState];
if (videoStatus == 3) {
[self didPressPause:[self playPauseButton]];
}
NSString *videoIdentifier = [playingVideoID currentVideoID];
UIAlertController *alertMenu = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"kRebornIHaveYouTubePremium"] == NO) {
[alertMenu addAction:[UIAlertAction actionWithTitle:@"Download Audio" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self rebornAudioDownloader:videoIdentifier];
}]];
[alertMenu addAction:[UIAlertAction actionWithTitle:@"Download Video" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self rebornVideoDownloader:videoIdentifier];
}]];
}
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"14.0") && SYSTEM_VERSION_LESS_THAN(@"15.0")) {
[alertMenu addAction:[UIAlertAction actionWithTitle:@"Picture In Picture" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self rebornPictureInPicture:videoIdentifier];
}]];
}
[alertMenu addAction:[UIAlertAction actionWithTitle:@"Play In External App" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self rebornPlayInExternalApp:videoIdentifier];
}]];
[alertMenu addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
}]];
[alertMenu setModalPresentationStyle:UIModalPresentationPopover];
UIPopoverPresentationController *popPresenter = [alertMenu popoverPresentationController];
popPresenter.sourceView = self;
popPresenter.sourceRect = self.bounds;
UIViewController *menuViewController = [self _viewControllerForAncestor];
[menuViewController presentViewController:alertMenu animated:YES completion:nil];
}
%new;
- (void)rebornVideoDownloader :(NSString *)videoID {
NSDictionary *youtubePlayerRequest = [YouTubeExtractor youtubePlayerRequest:@"android":videoID];
NSString *videoTitle = [NSString stringWithFormat:@"%@", youtubePlayerRequest[@"videoDetails"][@"title"]];
NSArray *videoArtworkArray = youtubePlayerRequest[@"videoDetails"][@"thumbnail"][@"thumbnails"];
NSURL *videoArtwork = [NSURL URLWithString:[NSString stringWithFormat:@"%@", videoArtworkArray[([videoArtworkArray count] - 1)][@"url"]]];
NSDictionary *innertubeFormats = youtubePlayerRequest[@"streamingData"][@"formats"];
NSURL *video2160p;
NSURL *video1440p;
NSURL *video1080p;
NSURL *video720p;
NSURL *video480p;
NSURL *video360p;
NSURL *video240p;
for (NSDictionary *format in innertubeFormats) {
if ([[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"height"]] isEqual:@"2160"] || [[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"quality"]] isEqual:@"hd2160"]) {
if (video2160p == nil) {
video2160p = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
} else if ([[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"height"]] isEqual:@"1440"] || [[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"quality"]] isEqual:@"hd1440"]) {
if (video1440p == nil) {
video1440p = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
} else if ([[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"height"]] isEqual:@"1080"] || [[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"quality"]] isEqual:@"hd1080"]) {
if (video1080p == nil) {
video1080p = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
} else if ([[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"height"]] isEqual:@"720"] || [[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"quality"]] isEqual:@"hd720"]) {
if (video720p == nil) {
video720p = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
} else if ([[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"height"]] isEqual:@"480"] || [[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"qualityLabel"]] isEqual:@"480p"]) {
if (video480p == nil) {
video480p = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
} else if ([[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"height"]] isEqual:@"360"] || [[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"qualityLabel"]] isEqual:@"360p"]) {
if (video360p == nil) {
video360p = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
} else if ([[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"height"]] isEqual:@"240"] || [[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"qualityLabel"]] isEqual:@"240p"]) {
if (video240p == nil) {
video240p = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
}
}
NSURL *videoURL;
if (video2160p != nil) {
videoURL = video2160p;
} else if (video1440p != nil) {
videoURL = video1440p;
} else if (video1080p != nil) {
videoURL = video1080p;
} else if (video720p != nil) {
videoURL = video720p;
} else if (video480p != nil) {
videoURL = video480p;
} else if (video360p != nil) {
videoURL = video360p;
} else if (video240p != nil) {
videoURL = video240p;
}
YouTubeDownloadController *rebornYouTubeDownloadController = [[YouTubeDownloadController alloc] init];
rebornYouTubeDownloadController.downloadTitle = videoTitle;
rebornYouTubeDownloadController.videoURL = nil;
rebornYouTubeDownloadController.audioURL = nil;
rebornYouTubeDownloadController.dualURL = videoURL;
rebornYouTubeDownloadController.artworkURL = videoArtwork;
rebornYouTubeDownloadController.downloadOption = 2;
UIViewController *rebornYouTubeDownloadViewController = self._viewControllerForAncestor;
[rebornYouTubeDownloadViewController presentViewController:rebornYouTubeDownloadController animated:YES completion:nil];
}
%new;
- (void)rebornAudioDownloader :(NSString *)videoID {
NSDictionary *youtubePlayerRequest = [YouTubeExtractor youtubePlayerRequest:@"android":videoID];
NSString *videoTitle = [NSString stringWithFormat:@"%@", youtubePlayerRequest[@"videoDetails"][@"title"]];
NSArray *videoArtworkArray = youtubePlayerRequest[@"videoDetails"][@"thumbnail"][@"thumbnails"];
NSURL *videoArtwork = [NSURL URLWithString:[NSString stringWithFormat:@"%@", videoArtworkArray[([videoArtworkArray count] - 1)][@"url"]]];
NSDictionary *innertubeAdaptiveFormats = youtubePlayerRequest[@"streamingData"][@"adaptiveFormats"];
NSURL *audioHigh;
NSURL *audioMedium;
NSURL *audioLow;
for (NSDictionary *format in innertubeAdaptiveFormats) {
if ([[format objectForKey:@"mimeType"] containsString:@"audio/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"audioQuality"]] isEqual:@"AUDIO_QUALITY_HIGH"]) {
if (audioHigh == nil) {
audioHigh = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
} else if ([[format objectForKey:@"mimeType"] containsString:@"audio/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"audioQuality"]] isEqual:@"AUDIO_QUALITY_MEDIUM"]) {
if (audioMedium == nil) {
audioMedium = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
} else if ([[format objectForKey:@"mimeType"] containsString:@"audio/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"audioQuality"]] isEqual:@"AUDIO_QUALITY_LOW"]) {
if (audioLow == nil) {
audioLow = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
}
}
NSURL *audioURL;
if (audioHigh != nil) {
audioURL = audioHigh;
} else if (audioMedium != nil) {
audioURL = audioMedium;
} else if (audioLow != nil) {
audioURL = audioLow;
}
YouTubeDownloadController *rebornYouTubeDownloadController = [[YouTubeDownloadController alloc] init];
rebornYouTubeDownloadController.downloadTitle = videoTitle;
rebornYouTubeDownloadController.videoURL = nil;
rebornYouTubeDownloadController.audioURL = audioURL;
rebornYouTubeDownloadController.dualURL = nil;
rebornYouTubeDownloadController.artworkURL = videoArtwork;
rebornYouTubeDownloadController.downloadOption = 1;
UIViewController *rebornYouTubeDownloadViewController = self._viewControllerForAncestor;
[rebornYouTubeDownloadViewController presentViewController:rebornYouTubeDownloadController animated:YES completion:nil];
}
%new;
- (void)rebornPictureInPicture :(NSString *)videoID {
NSString *videoTime = [NSString stringWithFormat:@"%f", [resultOut mediaTime]];
NSDictionary *youtubePlayerRequest = [YouTubeExtractor youtubePlayerRequest:@"ios":videoID];
NSURL *videoPath = [NSURL URLWithString:[NSString stringWithFormat:@"%@", youtubePlayerRequest[@"streamingData"][@"hlsManifestUrl"]]];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"kEnableBackgroundPlayback"] == YES) {
PictureInPictureController *pictureInPictureController = [[PictureInPictureController alloc] init];
pictureInPictureController.videoTime = videoTime;
pictureInPictureController.videoPath = videoPath;
UINavigationController *pictureInPictureControllerView = [[UINavigationController alloc] initWithRootViewController:pictureInPictureController];
pictureInPictureControllerView.modalPresentationStyle = UIModalPresentationFullScreen;
UIViewController *pictureInPictureViewController = self._viewControllerForAncestor;
[pictureInPictureViewController presentViewController:pictureInPictureControllerView animated:YES completion:nil];
} else {
UIAlertController *alertPip = [UIAlertController alertControllerWithTitle:@"Notice" message:@"You must enable 'Background Playback' in YouTube Reborn settings to use Picture-In-Picture" preferredStyle:UIAlertControllerStyleAlert];
[alertPip addAction:[UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}]];
UIViewController *pipViewController = [self _viewControllerForAncestor];
[pipViewController presentViewController:alertPip animated:YES completion:nil];
}
}
%new;
- (void)rebornPlayInExternalApp :(NSString *)videoID {
NSDictionary *youtubePlayerRequest = [YouTubeExtractor youtubePlayerRequest:@"ios":videoID];
NSURL *videoPath = [NSURL URLWithString:[NSString stringWithFormat:@"%@", youtubePlayerRequest[@"streamingData"][@"hlsManifestUrl"]]];
UIAlertController *alertApp = [UIAlertController alertControllerWithTitle:@"Choose App" message:nil preferredStyle:UIAlertControllerStyleAlert];
[alertApp addAction:[UIAlertAction actionWithTitle:@"Play In Infuse" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"infuse://x-callback-url/play?url=%@", videoPath]] options:@{} completionHandler:nil];
}]];
[alertApp addAction:[UIAlertAction actionWithTitle:@"Play In VLC" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"vlc-x-callback://x-callback-url/stream?url=%@", videoPath]] options:@{} completionHandler:nil];
}]];
[alertApp addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}]];
UIViewController *alertAppViewController = [self _viewControllerForAncestor];
[alertAppViewController presentViewController:alertApp animated:YES completion:nil];
}
%end
%hook YTReelHeaderView
- (void)layoutSubviews {
%orig();
UIButton *rebornOverlayButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[rebornOverlayButton addTarget:self action:@selector(rebornOptionsAction) forControlEvents:UIControlEventTouchUpInside];
[rebornOverlayButton setTitle:@"OP" forState:UIControlStateNormal];
rebornOverlayButton.frame = CGRectMake(40, 5, 40.0, 30.0);
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"kHideRebornShortsOPButton"] == YES) {
rebornOverlayButton.hidden = YES;
}
[self addSubview:rebornOverlayButton];
}
%new;
- (void)rebornOptionsAction {
NSString *videoIdentifier = [shortsPlayingVideoID videoId];
UIAlertController *alertMenu = [UIAlertController alertControllerWithTitle:nil message:@"Please Pause The Video Before Continuing" preferredStyle:UIAlertControllerStyleActionSheet];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"kRebornIHaveYouTubePremium"] == NO) {
[alertMenu addAction:[UIAlertAction actionWithTitle:@"Download Audio" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self rebornAudioDownloader:videoIdentifier];
}]];
[alertMenu addAction:[UIAlertAction actionWithTitle:@"Download Video" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self rebornVideoDownloader:videoIdentifier];
}]];
}
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"14.0") && SYSTEM_VERSION_LESS_THAN(@"15.0")) {
[alertMenu addAction:[UIAlertAction actionWithTitle:@"Picture In Picture" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self rebornPictureInPicture:videoIdentifier];
}]];
}
[alertMenu addAction:[UIAlertAction actionWithTitle:@"Play In External App" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self rebornPlayInExternalApp:videoIdentifier];
}]];
[alertMenu addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
}]];
[alertMenu setModalPresentationStyle:UIModalPresentationPopover];
UIPopoverPresentationController *popPresenter = [alertMenu popoverPresentationController];
popPresenter.sourceView = self;
popPresenter.sourceRect = self.bounds;
UIViewController *menuViewController = [self _viewControllerForAncestor];
[menuViewController presentViewController:alertMenu animated:YES completion:nil];
}
%new;
- (void)rebornVideoDownloader :(NSString *)videoID {
NSDictionary *youtubePlayerRequest = [YouTubeExtractor youtubePlayerRequest:@"android":videoID];
NSString *videoTitle = [NSString stringWithFormat:@"%@", youtubePlayerRequest[@"videoDetails"][@"title"]];
NSArray *videoArtworkArray = youtubePlayerRequest[@"videoDetails"][@"thumbnail"][@"thumbnails"];
NSURL *videoArtwork = [NSURL URLWithString:[NSString stringWithFormat:@"%@", videoArtworkArray[([videoArtworkArray count] - 1)][@"url"]]];
NSDictionary *innertubeFormats = youtubePlayerRequest[@"streamingData"][@"formats"];
NSURL *video2160p;
NSURL *video1440p;
NSURL *video1080p;
NSURL *video720p;
NSURL *video480p;
NSURL *video360p;
NSURL *video240p;
for (NSDictionary *format in innertubeFormats) {
if ([[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"height"]] isEqual:@"2160"] || [[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"quality"]] isEqual:@"hd2160"]) {
if (video2160p == nil) {
video2160p = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
} else if ([[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"height"]] isEqual:@"1440"] || [[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"quality"]] isEqual:@"hd1440"]) {
if (video1440p == nil) {
video1440p = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
} else if ([[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"height"]] isEqual:@"1080"] || [[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"quality"]] isEqual:@"hd1080"]) {
if (video1080p == nil) {
video1080p = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
} else if ([[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"height"]] isEqual:@"720"] || [[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"quality"]] isEqual:@"hd720"]) {
if (video720p == nil) {
video720p = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
} else if ([[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"height"]] isEqual:@"480"] || [[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"qualityLabel"]] isEqual:@"480p"]) {
if (video480p == nil) {
video480p = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
} else if ([[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"height"]] isEqual:@"360"] || [[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"qualityLabel"]] isEqual:@"360p"]) {
if (video360p == nil) {
video360p = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
} else if ([[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"height"]] isEqual:@"240"] || [[format objectForKey:@"mimeType"] containsString:@"video/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"qualityLabel"]] isEqual:@"240p"]) {
if (video240p == nil) {
video240p = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
}
}
NSURL *videoURL;
if (video2160p != nil) {
videoURL = video2160p;
} else if (video1440p != nil) {
videoURL = video1440p;
} else if (video1080p != nil) {
videoURL = video1080p;
} else if (video720p != nil) {
videoURL = video720p;
} else if (video480p != nil) {
videoURL = video480p;
} else if (video360p != nil) {
videoURL = video360p;
} else if (video240p != nil) {
videoURL = video240p;
}
YouTubeDownloadController *rebornYouTubeDownloadController = [[YouTubeDownloadController alloc] init];
rebornYouTubeDownloadController.downloadTitle = videoTitle;
rebornYouTubeDownloadController.videoURL = nil;
rebornYouTubeDownloadController.audioURL = nil;
rebornYouTubeDownloadController.dualURL = videoURL;
rebornYouTubeDownloadController.artworkURL = videoArtwork;
rebornYouTubeDownloadController.downloadOption = 2;
UIViewController *rebornYouTubeDownloadViewController = self._viewControllerForAncestor;
[rebornYouTubeDownloadViewController presentViewController:rebornYouTubeDownloadController animated:YES completion:nil];
}
%new;
- (void)rebornAudioDownloader :(NSString *)videoID {
NSDictionary *youtubePlayerRequest = [YouTubeExtractor youtubePlayerRequest:@"android":videoID];
NSString *videoTitle = [NSString stringWithFormat:@"%@", youtubePlayerRequest[@"videoDetails"][@"title"]];
NSArray *videoArtworkArray = youtubePlayerRequest[@"videoDetails"][@"thumbnail"][@"thumbnails"];
NSURL *videoArtwork = [NSURL URLWithString:[NSString stringWithFormat:@"%@", videoArtworkArray[([videoArtworkArray count] - 1)][@"url"]]];
NSDictionary *innertubeAdaptiveFormats = youtubePlayerRequest[@"streamingData"][@"adaptiveFormats"];
NSURL *audioHigh;
NSURL *audioMedium;
NSURL *audioLow;
for (NSDictionary *format in innertubeAdaptiveFormats) {
if ([[format objectForKey:@"mimeType"] containsString:@"audio/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"audioQuality"]] isEqual:@"AUDIO_QUALITY_HIGH"]) {
if (audioHigh == nil) {
audioHigh = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
} else if ([[format objectForKey:@"mimeType"] containsString:@"audio/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"audioQuality"]] isEqual:@"AUDIO_QUALITY_MEDIUM"]) {
if (audioMedium == nil) {
audioMedium = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
} else if ([[format objectForKey:@"mimeType"] containsString:@"audio/mp4"] & [[NSString stringWithFormat:@"%@", [format objectForKey:@"audioQuality"]] isEqual:@"AUDIO_QUALITY_LOW"]) {
if (audioLow == nil) {
audioLow = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [format objectForKey:@"url"]]];
}
}
}
NSURL *audioURL;
if (audioHigh != nil) {
audioURL = audioHigh;
} else if (audioMedium != nil) {
audioURL = audioMedium;
} else if (audioLow != nil) {
audioURL = audioLow;
}
YouTubeDownloadController *rebornYouTubeDownloadController = [[YouTubeDownloadController alloc] init];
rebornYouTubeDownloadController.downloadTitle = videoTitle;
rebornYouTubeDownloadController.videoURL = nil;
rebornYouTubeDownloadController.audioURL = audioURL;
rebornYouTubeDownloadController.dualURL = nil;
rebornYouTubeDownloadController.artworkURL = videoArtwork;
rebornYouTubeDownloadController.downloadOption = 1;
UIViewController *rebornYouTubeDownloadViewController = self._viewControllerForAncestor;
[rebornYouTubeDownloadViewController presentViewController:rebornYouTubeDownloadController animated:YES completion:nil];
}
%new;
- (void)rebornPictureInPicture :(NSString *)videoID {
NSDictionary *youtubePlayerRequest = [YouTubeExtractor youtubePlayerRequest:@"ios":videoID];
NSURL *videoPath = [NSURL URLWithString:[NSString stringWithFormat:@"%@", youtubePlayerRequest[@"streamingData"][@"hlsManifestUrl"]]];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"kEnableBackgroundPlayback"] == YES) {
PictureInPictureController *pictureInPictureController = [[PictureInPictureController alloc] init];
pictureInPictureController.videoTime = nil;
pictureInPictureController.videoPath = videoPath;
UINavigationController *pictureInPictureControllerView = [[UINavigationController alloc] initWithRootViewController:pictureInPictureController];
pictureInPictureControllerView.modalPresentationStyle = UIModalPresentationFullScreen;
UIViewController *pictureInPictureViewController = self._viewControllerForAncestor;
[pictureInPictureViewController presentViewController:pictureInPictureControllerView animated:YES completion:nil];
} else {
UIAlertController *alertPip = [UIAlertController alertControllerWithTitle:@"Notice" message:@"You must enable 'Background Playback' in YouTube Reborn settings to use Picture-In-Picture" preferredStyle:UIAlertControllerStyleAlert];
[alertPip addAction:[UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}]];
UIViewController *pipViewController = [self _viewControllerForAncestor];
[pipViewController presentViewController:alertPip animated:YES completion:nil];
}
}
%new;
- (void)rebornPlayInExternalApp :(NSString *)videoID {
NSDictionary *youtubePlayerRequest = [YouTubeExtractor youtubePlayerRequest:@"ios":videoID];
NSURL *videoPath = [NSURL URLWithString:[NSString stringWithFormat:@"%@", youtubePlayerRequest[@"streamingData"][@"hlsManifestUrl"]]];
UIAlertController *alertApp = [UIAlertController alertControllerWithTitle:@"Choose App" message:nil preferredStyle:UIAlertControllerStyleAlert];
[alertApp addAction:[UIAlertAction actionWithTitle:@"Play In Infuse" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"infuse://x-callback-url/play?url=%@", videoPath]] options:@{} completionHandler:nil];
}]];
[alertApp addAction:[UIAlertAction actionWithTitle:@"Play In VLC" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"vlc-x-callback://x-callback-url/stream?url=%@", videoPath]] options:@{} completionHandler:nil];
}]];
[alertApp addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}]];
UIViewController *alertAppViewController = [self _viewControllerForAncestor];
[alertAppViewController presentViewController:alertApp animated:YES completion:nil];
}
%end
// No YouTube Ads
%group gNoVideoAds
%hook YTHotConfig
- (BOOL)disableAfmaIdfaCollection { return NO; }
%end
%hook YTIPlayerResponse
- (BOOL)isMonetized { return NO; }
%end
%hook YTDataUtils
+ (id)spamSignalsDictionary { return @{}; }
+ (id)spamSignalsDictionaryWithoutIDFA { return @{}; }
%end
%hook YTAdsInnerTubeContextDecorator
- (void)decorateContext:(id)context { %orig(nil); }
%end
%hook YTAccountScopedAdsInnerTubeContextDecorator
- (void)decorateContext:(id)context { %orig(nil); }
%end
%hook YTReelInfinitePlaybackDataSource
- (void)setReels:(NSMutableOrderedSet <YTReelModel *> *)reels {
[reels removeObjectsAtIndexes:[reels indexesOfObjectsPassingTest:^BOOL(YTReelModel *obj, NSUInteger idx, BOOL *stop) {
return [obj respondsToSelector:@selector(videoType)] ? obj.videoType == 3 : NO;
}]];
%orig;
}
%end
BOOL isAdString(NSString *description) {
if ([description containsString:@"brand_promo"]
|| [description containsString:@"carousel_footered_layout"]
|| [description containsString:@"carousel_headered_layout"]
|| [description containsString:@"feed_ad_metadata"]
|| [description containsString:@"full_width_portrait_image_layout"]
|| [description containsString:@"full_width_square_image_layout"]
|| [description containsString:@"home_video_with_context"]
|| [description containsString:@"landscape_image_wide_button_layout"]
|| [description containsString:@"product_engagement_panel"]
|| [description containsString:@"product_item"]
|| [description containsString:@"shelf_header"]
|| [description containsString:@"square_image_layout"]
|| [description containsString:@"text_image_button_layout"]
|| [description containsString:@"text_search_ad"]
|| [description containsString:@"expandable_list"]
|| [description containsString:@"expandable_metadata"]
|| [description containsString:@"video_display_full_buttoned_layout"])
return YES;
return NO;
}
NSData *cellDividerData;
%hook YTIElementRenderer
- (NSData *)elementData {
NSString *description = [self description];
if ([description containsString:@"cell_divider"]) {
if (!cellDividerData) cellDividerData = %orig;
return cellDividerData;
}
if ([self respondsToSelector:@selector(hasCompatibilityOptions)] && self.hasCompatibilityOptions && self.compatibilityOptions.hasAdLoggingData) return cellDividerData;
return %orig;
}
%end
%hook YTInnerTubeCollectionViewController
- (void)loadWithModel:(YTISectionListRenderer *)model {
if ([model isKindOfClass:%c(YTISectionListRenderer)]) {
NSMutableArray <YTISectionListSupportedRenderers *> *contentsArray = model.contentsArray;
NSIndexSet *removeIndexes = [contentsArray indexesOfObjectsPassingTest:^BOOL(YTISectionListSupportedRenderers *renderers, NSUInteger idx, BOOL *stop) {
if (![renderers isKindOfClass:%c(YTISectionListSupportedRenderers)])
return NO;
YTIItemSectionRenderer *sectionRenderer = renderers.itemSectionRenderer;
YTIItemSectionSupportedRenderers *firstObject = [sectionRenderer.contentsArray firstObject];
YTIElementRenderer *elementRenderer = firstObject.elementRenderer;
NSString *description = [elementRenderer description];
return isAdString(description)
|| [description containsString:@"post_shelf"]
|| [description containsString:@"product_carousel"]
|| [description containsString:@"statement_banner"];
}];
[contentsArray removeObjectsAtIndexes:removeIndexes];
}
%orig;
}
%end
%hook YTWatchNextResultsViewController
- (void)loadWithModel:(YTISectionListRenderer *)watchNextResults {
if ([watchNextResults isKindOfClass:%c(YTISectionListRenderer)]) {
NSMutableArray <YTISectionListSupportedRenderers *> *contentsArray = watchNextResults.contentsArray;
NSIndexSet *removeIndexes = [contentsArray indexesOfObjectsPassingTest:^BOOL(YTISectionListSupportedRenderers *renderers, NSUInteger idx, BOOL *stop) {
if (![renderers isKindOfClass:%c(YTISectionListSupportedRenderers)])
return NO;
YTIItemSectionRenderer *sectionRenderer = renderers.itemSectionRenderer;
YTIItemSectionSupportedRenderers *firstObject = [sectionRenderer.contentsArray firstObject];
YTIElementRenderer *elementRenderer = firstObject.elementRenderer;
NSString *description = [elementRenderer description];
return isAdString(description);
}];
[contentsArray removeObjectsAtIndexes:removeIndexes];
}
%orig;
}
%end
%hook _ASDisplayView
- (void)didMoveToWindow {
%orig();
if ([self.accessibilityIdentifier isEqualToString:@"id.products_in_video_with_preview_overlay_badge.view"]) self.hidden = YES;
}
%end
%end
// Remove “Play next in queue” from the menu by @PoomSmart
%group gHidePlayNextInQueue
%hook YTMenuItemVisibilityHandler
- (BOOL)shouldShowServiceItemRenderer:(YTIMenuConditionalServiceItemRenderer *)renderer {
return renderer.icon.iconType == 251 ? NO : %orig;
}
%end
%end
// Hide Upgrade Dialog by @arichorn
%hook YTGlobalConfig
- (BOOL)shouldBlockUpgradeDialog { return YES;}
- (BOOL)shouldForceUpgrade { return NO;}
- (BOOL)shouldShowUpgrade { return NO;}
- (BOOL)shouldShowUpgradeDialog { return NO;}
%end
%group gBackgroundPlayback
%hook YTIPlayerResponse
- (BOOL)isPlayableInBackground {
return YES;
}
%end
%hook YTSingleVideo
- (BOOL)isPlayableInBackground {
return YES;
}
%end
%hook YTSingleVideoMediaData
- (BOOL)isPlayableInBackground {
return YES;
}
%end
%hook YTPlaybackData
- (BOOL)isPlayableInBackground {
return YES;
}
%end
%hook YTIPlayabilityStatus
- (BOOL)isPlayableInBackground {
return YES;
}
%end
%hook YTPlaybackBackgroundTaskController
- (BOOL)isContentPlayableInBackground {
return YES;
}
- (void)setContentPlayableInBackground:(BOOL)arg1 {
%orig(YES);
}
%end
%hook YTBackgroundabilityPolicy
- (BOOL)isBackgroundableByUserSettings {
return YES;
}
%end
%end
%group gExtraSpeedOptions
%hook YTVarispeedSwitchController
- (void *)init {
void *ret = (void *)%orig;
NSMutableArray *ytSpeedOptions = [NSMutableArray new];
[ytSpeedOptions addObject:[[NSClassFromString(@"YTVarispeedSwitchControllerOption") alloc] initWithTitle:@"0.1x" rate:0.1]];
[ytSpeedOptions addObject:[[NSClassFromString(@"YTVarispeedSwitchControllerOption") alloc] initWithTitle:@"0.25x" rate:0.25]];
[ytSpeedOptions addObject:[[NSClassFromString(@"YTVarispeedSwitchControllerOption") alloc] initWithTitle:@"0.5x" rate:0.5]];
[ytSpeedOptions addObject:[[NSClassFromString(@"YTVarispeedSwitchControllerOption") alloc] initWithTitle:@"0.75x" rate:0.75]];
[ytSpeedOptions addObject:[[NSClassFromString(@"YTVarispeedSwitchControllerOption") alloc] initWithTitle:@"Normal" rate:1]];
[ytSpeedOptions addObject:[[NSClassFromString(@"YTVarispeedSwitchControllerOption") alloc] initWithTitle:@"1.25x" rate:1.25]];
[ytSpeedOptions addObject:[[NSClassFromString(@"YTVarispeedSwitchControllerOption") alloc] initWithTitle:@"1.5x" rate:1.5]];
[ytSpeedOptions addObject:[[NSClassFromString(@"YTVarispeedSwitchControllerOption") alloc] initWithTitle:@"1.75x" rate:1.75]];
[ytSpeedOptions addObject:[[NSClassFromString(@"YTVarispeedSwitchControllerOption") alloc] initWithTitle:@"2x" rate:2]];
[ytSpeedOptions addObject:[[NSClassFromString(@"YTVarispeedSwitchControllerOption") alloc] initWithTitle:@"2.5x" rate:2.5]];
[ytSpeedOptions addObject:[[NSClassFromString(@"YTVarispeedSwitchControllerOption") alloc] initWithTitle:@"3x" rate:3]];
[ytSpeedOptions addObject:[[NSClassFromString(@"YTVarispeedSwitchControllerOption") alloc] initWithTitle:@"3.5x" rate:3.5]];
[ytSpeedOptions addObject:[[NSClassFromString(@"YTVarispeedSwitchControllerOption") alloc] initWithTitle:@"4x" rate:4]];
[ytSpeedOptions addObject:[[NSClassFromString(@"YTVarispeedSwitchControllerOption") alloc] initWithTitle:@"5x" rate:5]];
MSHookIvar<NSArray *>(self, "_options") = [ytSpeedOptions copy];
return ret;
}
%end
%hook MLHAMQueuePlayer
- (void)setRate:(float)rate {
MSHookIvar<float>(self, "_rate") = rate;
id ytPlayer = MSHookIvar<HAMPlayerInternal *>(self, "_player");
[ytPlayer setRate:rate];
[self.playerEventCenter broadcastRateChange:rate];
}
%end
%end
%group gLowContrastMode // Low Contrast Mode v1.4.2 (Compatible with only YouTube v16.05.7-v17.38.10)
%hook UIColor
+ (UIColor *)whiteColor { // Dark Theme Color
if (lcmHexColor) {
return lcmHexColor;
}
return [UIColor colorWithRed: 0.56 green: 0.56 blue: 0.56 alpha: 1.00];
}
+ (UIColor *)lightTextColor {
if (lcmHexColor) {
return lcmHexColor;
}
return [UIColor colorWithRed: 0.56 green: 0.56 blue: 0.56 alpha: 1.00];
}
+ (UIColor *)placeholderTextColor {