-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTweak.x
108 lines (91 loc) · 3.89 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <RemoteLog.h>
@interface UNPushNotificationRequestBuilder
-(id)initWithIdentifier:(id)arg1 payload:(id)arg2 bundleIdentifier:(id)arg3;
@end
int formatSpeciferType;
%hook UNPushNotificationRequestBuilder
-(id)initWithIdentifier:(id)arg1 payload:(id)arg2 bundleIdentifier:(id)arg3 {
if([arg3 isEqualToString:@"com.toyopagroup.picaboo"]){
NSLog(@"STREAK METADATA: %@", arg2);
//NSDictionary *prefs = [[NSDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.galacticdev.streaknotificationsprefs.plist"];
//NSLog(@"prefs = %@", prefs);
__block NSString *streakMetadata = [arg2 objectForKey:@"snapstreak_metadata"];
//NSLog(@"streakMetadata = %@", streakMetadata);
NSError *error;
if (streakMetadata !=nil) {
NSMutableDictionary *payload = [[NSMutableDictionary alloc] initWithDictionary:arg2];
NSMutableDictionary *aps = [[NSMutableDictionary alloc] initWithDictionary:[arg2 objectForKey:@"aps"]];
NSMutableDictionary *alert = [[NSMutableDictionary alloc] initWithDictionary:[[arg2 objectForKey:@"aps"] objectForKey:@"alert"]];
NSMutableDictionary *streakMetadataDict = [NSJSONSerialization JSONObjectWithData:[streakMetadata dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&error];
int streakLength = [[streakMetadataDict objectForKey:@"snapstreak_count"] intValue];
NSTimeInterval seconds = [[streakMetadataDict objectForKey:@"snapstreak_expiry_time"] doubleValue] / 1000;
NSDate *snapchatExpiryDate = [NSDate dateWithTimeIntervalSince1970:seconds];
NSTimeInterval timeInterval = [snapchatExpiryDate timeIntervalSinceDate:[NSDate date]];
int days = timeInterval / (60 * 60 * 24);
timeInterval -= days * (60 * 60 * 24);
int hours = timeInterval / (60 * 60);
timeInterval -= hours * (60 * 60);
int minutes = timeInterval / 60;
NSString *bodyString;
if(streakLength > 0){
NSString *streakLengthString;
if(streakLength == 100){
streakLengthString = @"💯";
}
else {
streakLengthString = [NSString stringWithFormat:@"%d", streakLength];
}
switch (formatSpeciferType){
case 0: {
bodyString = [NSString stringWithFormat:@"%d day long streak will expire in %dd %dh %dm", streakLength, days, hours, minutes];
break;
}
case 1: {
bodyString = [NSString stringWithFormat:@"🔥%@ ⏰%dd %dh %dm", streakLengthString, days, hours, minutes];
break;
}
case 2: {
bodyString = [NSString stringWithFormat:@"⏰%dd %dh %dm", days, hours, minutes];
break;
}
case 3: {
bodyString = [NSString stringWithFormat:@"🔥%@", streakLengthString];
break;
}
}
}
else {
bodyString = @"";
}
alert[@"subtitle"] = [alert objectForKey:@"body"];
aps[@"alert"] = alert;
payload[@"aps"] = aps;
payload[@"local_message"] = bodyString;
arg2 = payload;
}
}
return %orig;
}
%end
static void loadPrefs(){
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.galacticdev.streaknotificationsprefs.plist"];
if ([prefs objectForKey:@"formatSpecifer"] != nil){
if([[prefs objectForKey:@"formatSpecifer"] intValue] == 0){
formatSpeciferType = 0;
}
else if([[prefs objectForKey:@"formatSpecifer"] intValue] == 1){
formatSpeciferType = 1;
}
else if([[prefs objectForKey:@"formatSpecifer"] intValue] == 2){
formatSpeciferType = 2;
}
else if([[prefs objectForKey:@"formatSpecifer"] intValue] == 3){
formatSpeciferType = 3;
}
} else {
formatSpeciferType = 0;
}
}
%ctor {
loadPrefs();
}