Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Source/SelectableLyrics.xm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ static BOOL YTMU(NSString *key) {
return [YTMUltimateDict[key] boolValue];
}

static BOOL selectableLyrics = YTMU(@"YTMUltimateIsEnabled") && YTMU(@"selectableLyrics");
static BOOL shouldShowSelectableLyrics() {
return YTMU(@"YTMUltimateIsEnabled") && YTMU(@"selectableLyrics");
}

@interface YTFormattedStringLabel : UILabel
@end
Expand All @@ -16,11 +18,9 @@ static BOOL selectableLyrics = YTMU(@"YTMUltimateIsEnabled") && YTMU(@"selectabl

%hook YTMLightweightMusicDescriptionShelfCell

%property (retain, nonatomic) UITextView *lyrics;

- (id)initWithFrame:(CGRect)frame {
self = %orig;
if (self && selectableLyrics) {
if (self && shouldShowSelectableLyrics()) {
UIView *container = [self valueForKey:@"_descriptionContainer"];
self.lyrics = [[UITextView alloc] init];
self.lyrics.backgroundColor = [UIColor clearColor];
Expand All @@ -35,7 +35,7 @@ static BOOL selectableLyrics = YTMU(@"YTMUltimateIsEnabled") && YTMU(@"selectabl
- (void)setRenderer:(id)renderer {
%orig;

if (selectableLyrics) {
if (shouldShowSelectableLyrics()) {
YTFormattedStringLabel *lyrics = [self valueForKey:@"_descriptionLabel"];
lyrics.userInteractionEnabled = YES;
lyrics.hidden = YES;
Expand All @@ -48,7 +48,7 @@ static BOOL selectableLyrics = YTMU(@"YTMUltimateIsEnabled") && YTMU(@"selectabl
- (void)layoutSubviews {
%orig;

if (selectableLyrics) {
if (shouldShowSelectableLyrics()) {
YTFormattedStringLabel *lyrics = [self valueForKey:@"_descriptionLabel"];
self.lyrics.frame = lyrics.frame;
}
Expand Down
15 changes: 7 additions & 8 deletions Source/SponsorBlock.xm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#define ytmuInt(key) [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"YTMUltimate"][key] integerValue]

%hook YTPlayerViewController
%property (nonatomic, strong) NSMutableDictionary *sponsorBlockValues;

- (void)playbackController:(id)arg1 didActivateVideo:(id)arg2 withPlaybackData:(id)arg3 {
%orig;
Expand All @@ -17,7 +16,7 @@

self.sponsorBlockValues = [NSMutableDictionary dictionary];

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://sponsor.ajay.app/api/skipSegments?videoID=%@&categories=%@", self.currentVideoID, @"%5B%22music_offtopic%22%5D"]]];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://sponsor.ajay.app/api/skipSegments?videoID=%@&categories=%@", [self currentVideoID], @"%5B%22music_offtopic%22%5D"]]];

[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (!error) {
Expand All @@ -29,7 +28,7 @@
[segments setObject:@(1) forKey:uuid];
}

[self.sponsorBlockValues setObject:jsonResponse forKey:self.currentVideoID];
[self.sponsorBlockValues setObject:jsonResponse forKey:[self currentVideoID]];
[self.sponsorBlockValues setObject:segments forKey:@"segments"];
}
}
Expand All @@ -50,8 +49,8 @@

%new
- (void)skipSegment {
if (ytmuBool(@"sponsorBlock") && [NSJSONSerialization isValidJSONObject:self.sponsorBlockValues]) {
NSDictionary *sponsorBlockValues = [self.sponsorBlockValues objectForKey:self.currentVideoID];
if (ytmuBool(@"sponsorBlock") && self.sponsorBlockValues && [self.sponsorBlockValues count] > 0) {
NSDictionary *sponsorBlockValues = [self.sponsorBlockValues objectForKey:[self currentVideoID]];
NSMutableDictionary *segmentSkipValues = [self.sponsorBlockValues objectForKey:@"segments"];

for (NSDictionary *jsonDictionary in sponsorBlockValues) {
Expand All @@ -60,8 +59,8 @@

if (segmentSkipValue && [segmentSkipValue isEqual:@(1)]
&& [[jsonDictionary objectForKey:@"category"] isEqual:@"music_offtopic"]
&& self.currentVideoMediaTime >= [[jsonDictionary objectForKey:@"segment"][0] floatValue]
&& self.currentVideoMediaTime <= ([[jsonDictionary objectForKey:@"segment"][1] floatValue] - 1)) {
&& [self currentVideoMediaTime] >= [[jsonDictionary objectForKey:@"segment"][0] floatValue]
&& [self currentVideoMediaTime] <= ([[jsonDictionary objectForKey:@"segment"][1] floatValue] - 1)) {

[segmentSkipValues setObject:@(0) forKey:uuid];
[self.sponsorBlockValues setObject:segmentSkipValues forKey:@"segments"];
Expand Down Expand Up @@ -107,4 +106,4 @@
}

[[NSUserDefaults standardUserDefaults] setObject:mutableDict forKey:@"YTMUltimate"];
}
}
17 changes: 9 additions & 8 deletions Source/VolumeBar/VolumeBar.xm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ static BOOL YTMU(NSString *key) {
return [YTMUltimateDict[key] boolValue];
}

static BOOL volumeBar = YTMU(@"YTMUltimateIsEnabled") && YTMU(@"volBar");
static BOOL shouldShowVolumeBar() {
return YTMU(@"YTMUltimateIsEnabled") && YTMU(@"volBar");
}

@interface YTMWatchView: UIView
@property (readonly, nonatomic) BOOL isExpanded;
Expand All @@ -17,12 +19,11 @@ static BOOL volumeBar = YTMU(@"YTMUltimateIsEnabled") && YTMU(@"volBar");
@end

%hook YTMWatchView
%property (nonatomic, strong) GSVolBar *volumeBar;

- (instancetype)initWithColorScheme:(id)scheme {
self = %orig;

if (self && volumeBar) {
if (self && shouldShowVolumeBar()) {
self.volumeBar = [[GSVolBar alloc] initWithFrame:CGRectMake(self.frame.size.width / 2 - (self.frame.size.width / 2) / 2, 0, self.frame.size.width / 2, 25)];

[self addSubview:self.volumeBar];
Expand All @@ -34,34 +35,34 @@ static BOOL volumeBar = YTMU(@"YTMUltimateIsEnabled") && YTMU(@"volBar");
- (void)layoutSubviews {
%orig;

if (volumeBar) {
if (shouldShowVolumeBar()) {
self.volumeBar.frame = CGRectMake(self.frame.size.width / 2 - (self.frame.size.width / 2) / 2, CGRectGetMinY(self.tabView.frame) - 25, self.frame.size.width / 2, 25);
}
}

- (void)updateColorsAfterLayoutChangeTo:(long long)arg1 {
%orig;

if (volumeBar) {
if (shouldShowVolumeBar()) {
[self updateVolBarVisibility];
}
}

- (void)updateColorsBeforeLayoutChangeTo:(long long)arg1 {
%orig;

if (volumeBar) {
if (shouldShowVolumeBar()) {
self.volumeBar.hidden = YES;
}
}

%new
- (void)updateVolBarVisibility {
if (volumeBar) {
if (shouldShowVolumeBar()) {
dispatch_async(dispatch_get_main_queue(), ^(void){
self.volumeBar.hidden = !(self.isExpanded && self.currentLayout == 2);
});
}
}

%end
%end