-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathTweak.x
85 lines (65 loc) · 2.55 KB
/
Tweak.x
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
#import "../YTVideoOverlay/Header.h"
#import "../YTVideoOverlay/Init.x"
#import <YouTubeHeader/QTMIcon.h>
#import <YouTubeHeader/YTColor.h>
#import <YouTubeHeader/YTMainAppVideoPlayerOverlayViewController.h>
#import <YouTubeHeader/YTSingleVideoController.h>
#define TweakKey @"YouMute"
@interface YTMainAppControlsOverlayView (YouMute)
- (void)didPressMute:(id)arg;
@end
@interface YTInlinePlayerBarContainerView (YouMute)
- (void)didPressMute:(id)arg;
@end
static BOOL isMutedTop(YTMainAppControlsOverlayView *self) {
YTMainAppVideoPlayerOverlayViewController *c = [self valueForKey:@"_eventsDelegate"];
YTSingleVideoController *video = [c valueForKey:@"_currentSingleVideoObservable"];
return [video isMuted];
}
static BOOL isMutedBottom(YTInlinePlayerBarContainerView *self) {
YTSingleVideoController *video = [self.delegate valueForKey:@"_currentSingleVideo"];
return [video isMuted];
}
static NSBundle *YTEditResourcesBundle() {
NSBundle *editBundle = [NSBundle bundleForClass:%c(YTEditBundleIdentifier)];
return [NSBundle bundleWithPath:[[editBundle bundlePath] stringByAppendingPathComponent:@"Edit_Resources.bundle"]];
}
static UIImage *muteImage(BOOL muted) {
return [%c(QTMIcon) tintImage:[UIImage imageNamed:muted ? @"ic_volume_off" : @"ic_volume_up" inBundle:YTEditResourcesBundle() compatibleWithTraitCollection:nil] color:[%c(YTColor) white1]];
}
%group Top
%hook YTMainAppControlsOverlayView
- (UIImage *)buttonImage:(NSString *)tweakId {
return [tweakId isEqualToString:TweakKey] ? muteImage(isMutedTop(self)) : %orig;
}
%new(v@:@)
- (void)didPressMute:(id)arg {
YTMainAppVideoPlayerOverlayViewController *c = [self valueForKey:@"_eventsDelegate"];
YTSingleVideoController *video = [c valueForKey:@"_currentSingleVideoObservable"];
[video setMuted:![video isMuted]];
[self.overlayButtons[TweakKey] setImage:muteImage([video isMuted]) forState:0];
}
%end
%end
%group Bottom
%hook YTInlinePlayerBarContainerView
- (UIImage *)buttonImage:(NSString *)tweakId {
return [tweakId isEqualToString:TweakKey] ? muteImage(isMutedBottom(self)) : %orig;
}
%new(v@:@)
- (void)didPressMute:(id)arg {
YTSingleVideoController *video = [self.delegate valueForKey:@"_currentSingleVideo"];
[video setMuted:![video isMuted]];
[self.overlayButtons[TweakKey] setImage:muteImage([video isMuted]) forState:0];
}
%end
%end
%ctor {
initYTVideoOverlay(TweakKey, @{
AccessibilityLabelKey: @"Mute",
SelectorKey: @"didPressMute:",
UpdateImageOnVisibleKey: @YES
});
%init(Top);
%init(Bottom);
}