-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBuildCode
More file actions
167 lines (110 loc) · 5.57 KB
/
BuildCode
File metadata and controls
167 lines (110 loc) · 5.57 KB
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
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <objc/runtime.h>
#import "MBProgressHUD.h"
@interface PTHTweetbotStatus
@property(retain, nonatomic) NSURL *expandedURL;
@property(readonly, nonatomic) NSURL *twitterURL;
@end
@interface PTHTweetbotStatusView : UIViewController
-(void)Download:(NSString*)arg1;
-(void)Links:(NSURL*)arg1;
@end
%hook PTHTweetbotStatusView
%new
-(void)Download:(NSString*)arg1{
UIWindow* mainWindow = [[UIApplication sharedApplication] keyWindow];
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:mainWindow animated:YES];
hud.mode = MBProgressHUDModeIndeterminate;
hud.labelText = @"Downloading";
[hud removeFromSuperview];
UIWindow *window = [UIApplication sharedApplication].windows.lastObject;
[window addSubview:hud];
[window bringSubviewToFront:hud];
dispatch_async(dispatch_get_main_queue(), ^{
NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"temp.mp4"];
NSData *urlData = [NSData dataWithContentsOfURL:[NSURL URLWithString:arg1]];
//saving is done on main thread
[urlData writeToFile:filePath atomically:YES];
[hud hide:YES];
UISaveVideoAtPathToSavedPhotosAlbum(filePath,nil,nil,nil);
[[[UIAlertView alloc] initWithTitle:nil message:@"Saved :)" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];});
}
%new
-(void)Links:(NSURL*)arg1 {
UIWindow* mainWindow = [[UIApplication sharedApplication] keyWindow];
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:mainWindow animated:YES];
hud.mode = MBProgressHUDModeIndeterminate;
hud.labelText = @"Loading";
[hud removeFromSuperview];
UIWindow *window = [UIApplication sharedApplication].windows.lastObject;
[window addSubview:hud];
[window bringSubviewToFront:hud];
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController * alert = [UIAlertController
alertControllerWithTitle:@"🤔"
message:nil
preferredStyle:UIAlertControllerStyleAlert];
// Create the request.
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://hex-lab./Api.php"]];
// Specify that it will be a POST request
request.HTTPMethod = @"POST";
// This is how we set header fields
//[request setValue:@"application/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
// Convert your data and set your request's HTTPBody property
NSString *stringData = [NSString stringWithFormat:@"url=%@", arg1];
NSData *requestBodyData = [stringData dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody: requestBodyData];
// Create url connection and fire request
//NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
NSData *response = [NSURLConnection sendSynchronousRequest:request
returningResponse:nil error:nil];
NSString *string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
if(string != nil) {
NSArray *arr = [string componentsSeparatedByString:@"#"];
for (size_t i = 0; i < [arr count]-1; i++) {
NSArray *arr2 = [[NSString stringWithFormat:@"%@",[arr objectAtIndex:i]] componentsSeparatedByString:@"^"];
UIAlertAction* yesButton = [UIAlertAction
actionWithTitle:[arr2 objectAtIndex:0]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[self Download:[arr2 objectAtIndex:1]];
}];
[alert addAction:yesButton];
}
UIAlertAction* CButton = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
}];
[alert addAction:CButton];
#define ROOTVIEW [[[UIApplication sharedApplication] keyWindow] rootViewController]
[ROOTVIEW presentViewController:alert animated:YES completion:nil];
}
[hud hide:YES];
});
}
- (void)statusMediaView:(id)arg1 didLongPress:(id)arg2{
PTHTweetbotStatus *st= MSHookIvar<PTHTweetbotStatus*>(self,"_status");
UIAlertController * alert = [UIAlertController
alertControllerWithTitle:@"🤔"
message:nil
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* yesButton = [UIAlertAction
actionWithTitle:@"Share"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
%orig;
}];
UIAlertAction* noButton = [UIAlertAction
actionWithTitle:@"Save"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[self Links:st.twitterURL];
}];
[alert addAction:yesButton];
[alert addAction:noButton];
#define ROOTVIEW [[[UIApplication sharedApplication] keyWindow] rootViewController]
[ROOTVIEW presentViewController:alert animated:YES completion:nil];
}
%end