This repository has been archived by the owner on Mar 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCategories.xm
59 lines (50 loc) · 1.52 KB
/
Categories.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
#import "Categories.h"
%hook IGFeedItem
%new
- (NSURL *)highestResolutionPhotoURL {
IGPostItem *post = [[self items] firstObject];
if (post.mediaType == 1) {
IGPhoto *photo = post.photo;
IGImageURL *imageURL = [[photo ascendingSizeImageURLs] lastObject];
return imageURL.url;
}
return nil;
}
%new
- (NSURL *)highestResolutionVideoURL {
IGPostItem *post = [[self items] firstObject];
if (post.mediaType == 2) {
IGVideo *video = post.video;
double winnerResolution = 0;
NSURL *winner = nil;
for (NSDictionary *dict in video.videoVersions) {
double width = [dict[@"width"] doubleValue];
double height = [dict[@"height"] doubleValue];
double resolution = width * height;
if (resolution > winnerResolution) {
winnerResolution = resolution;
winner = [NSURL URLWithString:dict[@"url"]];
}
}
return winner;
}
return nil;
}
%end
%hook IPSettingsViewController
- (void)viewDidLoad {
%orig;
if (%c(FLEXManager) != nil) {
UIBarButtonItem *flexBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle: @"FLEX"
style: UIBarButtonItemStylePlain
target: self
action:@selector(showFLEX)];
self.navigationItem.leftBarButtonItem = flexBarButtonItem;
}
}
%new
- (void)showFLEX {
[[%c(FLEXManager) sharedManager] showExplorer];
}
%end