forked from dado3212/SnapchatReloaded
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTweak.xm
179 lines (150 loc) · 4.6 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
#include "fishhook/fishhook.h"
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "substrate.h"
/* ============
Interfaces
============= */
@interface Manager
+(id) shared;
-(void) startTimer:(id)snap source:(int)source;
-(void) markSnapAsViewed:(id)snap;
@end
@interface SCSnapSaver
+(id) shared;
-(void) saveSnapImageToSnapAlbum:(id)image completionBlock:(id)block;
@end
@interface SCMediaView : UIView
-(id) imageView;
@end
/* ============
Variables
============= */
id currentSnap = nil;
int bounds = 40;
UIButton *saveSnapButton = nil;
/* ============
Overrides
============= */
// Screenshot Blocking
%hook SCChatViewController
-(void)userDidTakeScreenshot {
return;
}
%end
%hook SCViewingStoryViewController
-(void)userDidTakeScreenshot {
return;
}
%end
// Handles tap to progress
%hook SCFeedViewController
-(void)tapToSkip:(UIGestureRecognizer *)tap {
CGPoint coords = [tap locationInView:tap.view];
if (coords.x < [UIScreen mainScreen].bounds.size.width - bounds - 5 || coords.y < [UIScreen mainScreen].bounds.size.height - bounds - 5) {
@try {
if (currentSnap) {
[[%c(Manager) shared] markSnapAsViewed:currentSnap];
currentSnap = nil;
}
}
@catch(NSException *){}
}
%orig;
}
- (void)didFinishSnapPlaying:(id)snap {
currentSnap = nil;
%orig;
}
- (void)didSucceedSetUpSnapPlaying:(id)snap {
currentSnap = snap;
%orig;
}
-(void)userDidTakeScreenshot {
return;
}
%end
%hook SCMediaView
// Hides the timer from the display
-(id) snapTimer {
return nil;
}
-(void) setImageView:(id)imageView {
%orig;
// Add Save Snap Button
saveSnapButton = [UIButton buttonWithType:UIButtonTypeCustom];
[saveSnapButton addTarget:self action:@selector(saveImage:) forControlEvents:UIControlEventTouchUpInside];
[saveSnapButton setImage:[UIImage imageNamed:@"save_button.png"] forState:UIControlStateNormal];
saveSnapButton.frame = CGRectMake([UIScreen mainScreen].bounds.size.width - bounds - 5, [UIScreen mainScreen].bounds.size.height - bounds - 5, bounds, bounds);
[self addSubview:saveSnapButton];
[self bringSubviewToFront:saveSnapButton];
[self setUserInteractionEnabled:YES];
}
%new
-(void) saveImage:(id)sender {
if ([self.imageView image] != nil) {
// Empty block for callback method to prevent crash.
void (^fillerBlock)(void) = ^{};
[[%c(SCSnapSaver) shared] saveSnapImageToSnapAlbum:[self.imageView image] completionBlock:fillerBlock];
}
}
%end
/*%hook UIImageView
-(void) setImage:(id)image {
%orig;
if ([[self.superview performSelector:@selector(className)] isEqualToString:@"SCMediaView"] && !CGSizeEqualToSize(((UIImage *)image).size, CGSizeMake(0,0)) && saveSnapButton != nil && ![[[saveSnapButton actionsForTarget:self.superview forControlEvent:UIControlEventTouchUpInside] objectAtIndex:0] isEqualToString:@"saveImage:"]) {
NSLog(@"Converting to saveImage!");
// Remove the action.
[saveSnapButton removeTarget:nil action:NULL forControlEvents:UIControlEventTouchUpInside];
// Add the right action.
[saveSnapButton addTarget:self.superview action:@selector(saveImage:) forControlEvents:UIControlEventTouchUpInside];
}
}
%end
%hook AVPlayer
-(void) play {
if (saveSnapButton != nil && ![[[saveSnapButton actionsForTarget:self forControlEvent:UIControlEventTouchUpInside] objectAtIndex:0] isEqualToString:@"saveVideo:"]) {
NSLog(@"Converting to saveVideo!");
// Remove the action.
[saveSnapButton removeTarget:nil action:NULL forControlEvents:UIControlEventTouchUpInside];
// Add the right action.
[saveSnapButton addTarget:self action:@selector(saveVideo:) forControlEvents:UIControlEventTouchUpInside];
}
%orig;
}
%new
-(void) saveVideo:(id)sender {
if(UIVideoAtPathIsCompatibleWithSavedPhotosAlbum([[[[self performSelector:@selector(currentItem)] performSelector:@selector(asset)] performSelector:@selector(URL)] performSelector:@selector(path)]))
UISaveVideoAtPathToSavedPhotosAlbum([[[[self performSelector:@selector(currentItem)] performSelector:@selector(asset)] performSelector:@selector(URL)] performSelector:@selector(path)], nil, nil, nil);
}
%end*/
// Removes the caption text limit
%hook SCCaptionDefaultTextView
-(CGFloat) maxTextWidth {
return DBL_MAX;
}
%end
// Stops timer from progressing
%hook Manager
-(void)tick:(id)tick {
return;
}
-(void)startTimer:(id)snap source:(int)source {
currentSnap = snap;
%orig;
}
%end
// Breaks the daily replay limit
%hook User
/*-(void) updateCanReplaySnapsTimeWithCurrentDate:(id)rDate replayedDate:(id)cDate {
return %orig([NSDate dateWithTimeIntervalSinceNow: -(60.0f*60.0f*25.0f)], cDate);
}*/
- (_Bool)hasFreeReplaySnap {
return 1;
}
%end
%hook SCSnapPlayController
- (_Bool)canReplaySnap {
return 1;
}
%end