forked from HearseDev/3developer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTweak.x
More file actions
150 lines (136 loc) · 6.53 KB
/
Tweak.x
File metadata and controls
150 lines (136 loc) · 6.53 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
#include "Tweak.h"
%hook SBIconView
- (void)setApplicationShortcutItems:(NSArray *)arg1 {
NSMutableArray *originalItems = [[NSMutableArray alloc] init];
for (SBSApplicationShortcutItem *item in arg1) {
[originalItems addObject:item];
}
//decrypt
NSData *flexData = UIImagePNGRepresentation(
[[[UIImage systemImageNamed:@"chevron.left.slash.chevron.right"]
imageWithTintColor:[UIColor whiteColor]]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]);
SBSApplicationShortcutItem *flexItem =
[%c(SBSApplicationShortcutItem) alloc];
flexItem.localizedTitle = @"Flexdecrypt";
SBSApplicationShortcutCustomImageIcon *flexIcon =
[[SBSApplicationShortcutCustomImageIcon alloc]
initWithImagePNGData:flexData];
[flexItem setIcon:flexIcon];
flexItem.type = @"com.hearse.3developer.flex";
[originalItems addObject:flexItem];
//copy bundle id
NSData *copyBundleData = UIImagePNGRepresentation([[[UIImage
systemImageNamed:@"app.badge"] imageWithTintColor:[UIColor whiteColor]]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]);
SBSApplicationShortcutItem *copyBundleItem =
[%c(SBSApplicationShortcutItem) alloc];
copyBundleItem.localizedTitle = @"Copy Bundle ID";
copyBundleItem.localizedSubtitle = self.applicationBundleIdentifierForShortcuts;
SBSApplicationShortcutCustomImageIcon *copyBundleIcon =
[[SBSApplicationShortcutCustomImageIcon alloc]
initWithImagePNGData:copyBundleData];
[copyBundleItem setIcon:copyBundleIcon];
copyBundleItem.type = @"com.hearse.3developer.bundle";
[originalItems addObject:copyBundleItem];
//open bundle
NSData *openBundleData = UIImagePNGRepresentation([[[UIImage
systemImageNamed:@"doc.fill"] imageWithTintColor:[UIColor whiteColor]]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]);
SBSApplicationShortcutItem *openBundleItem =
[%c(SBSApplicationShortcutItem) alloc];
openBundleItem.localizedTitle = @"Open Bundle In Filza";
SBSApplicationShortcutCustomImageIcon *openBundleIcon =
[[SBSApplicationShortcutCustomImageIcon alloc]
initWithImagePNGData:openBundleData];
[openBundleItem setIcon:openBundleIcon];
openBundleItem.type = @"com.hearse.3developer.openBundleInFilza";
[originalItems addObject:openBundleItem];
%orig(originalItems);
}
+ (void)activateShortcut:(SBSApplicationShortcutItem *)item
withBundleIdentifier:(NSString *)bundleID
forIconView:(SBIconView *)iconView {
if ([[item type] isEqualToString:@"com.hearse.3developer.flex"]) {
FBApplicationInfo *app =
(FBApplicationInfo *)[[NSClassFromString(@"SBApplicationController")
sharedInstance]
applicationWithBundleIdentifier:bundleID]
.info;
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/bin/flexdecrypt"];
[task setArguments:@[ app.executableURL.path ]];
NSPipe *out = [NSPipe pipe];
[task setStandardOutput:out];
[task setTerminationHandler:^(NSTask *task) {
dispatch_async(dispatch_get_main_queue(), ^{
NSFileHandle *read = [out fileHandleForReading];
NSData *dataRead = [read readDataToEndOfFile];
NSString *stringRead =
[[NSString alloc] initWithData:dataRead
encoding:NSUTF8StringEncoding];
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:@"Flexdecrypt"
message:stringRead
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *dismissAction = [UIAlertAction
actionWithTitle:@"Dismiss"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
}];
UIAlertAction *filzaAction = [UIAlertAction
actionWithTitle:@"Open in Filza"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
NSString *decryptedPath = [[NSString alloc]
initWithFormat:
@"%@",
[stringRead
stringByReplacingOccurrencesOfString:
@"Wrote decrypted image to "
withString:@""]];
NSString *pathInFilza = [@"filza://view"
stringByAppendingString:decryptedPath];
NSString* trimmedUrlString = [pathInFilza stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSURL *url = [NSURL
URLWithString:
[trimmedUrlString
stringByAddingPercentEncodingWithAllowedCharacters:
[NSCharacterSet
URLQueryAllowedCharacterSet]]];
NSLog(@"NSLogify |%@|", url);
[[%c(SpringBoard) sharedApplication]
applicationOpenURL:url];
}];
[alert addAction:dismissAction];
[alert addAction:filzaAction];
[iconView.window.rootViewController presentViewController:alert
animated:YES
completion:nil];
});
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
[task launch];
});
} else if ([[item type] isEqualToString:@"com.hearse.3developer.bundle"]) {
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = bundleID;
} else if ([[item type]
isEqualToString:@"com.hearse.3developer.openBundleInFilza"]) {
FBApplicationInfo *app =
(FBApplicationInfo *)[[NSClassFromString(@"SBApplicationController")
sharedInstance]
applicationWithBundleIdentifier:bundleID]
.info;
NSString *pathInFilza =
[@"filza://view" stringByAppendingString:app.bundleURL.path];
NSURL *url = [NSURL
URLWithString:[pathInFilza
stringByAddingPercentEncodingWithAllowedCharacters:
[NSCharacterSet URLQueryAllowedCharacterSet]]];
[[%c(SpringBoard) sharedApplication] applicationOpenURL:url];
} else {
%orig;
}
}
%end