<dict> | <dict> | ||||
<key>items</key> | <key>items</key> | ||||
<array> | <array> | ||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSGroupCell</string> | |||||
<key>label</key> | |||||
<string>Enabled</string> | |||||
</dict> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSSwitchCell</string> | |||||
<key>default</key> | |||||
<true/> | |||||
<key>defaults</key> | |||||
<string>com.lint.undelete.prefs</string> | |||||
<key>key</key> | |||||
<string>isRedditEnabled</string> | |||||
<key>label</key> | |||||
<string>Enable Reddit</string> | |||||
</dict> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSSwitchCell</string> | |||||
<key>default</key> | |||||
<true/> | |||||
<key>defaults</key> | |||||
<string>com.lint.undelete.prefs</string> | |||||
<key>key</key> | |||||
<string>isApolloEnabled</string> | |||||
<key>label</key> | |||||
<string>Enable Apollo</string> | |||||
</dict> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSSwitchCell</string> | |||||
<key>default</key> | |||||
<true/> | |||||
<key>defaults</key> | |||||
<string>com.lint.undelete.prefs</string> | |||||
<key>key</key> | |||||
<string>isNarwhalEnabled</string> | |||||
<key>label</key> | |||||
<string>Enable Narwhal</string> | |||||
</dict> | |||||
<dict> | <dict> | ||||
<key>cell</key> | <key>cell</key> | ||||
<string>PSGroupCell</string> | <string>PSGroupCell</string> | ||||
<key>showValue</key> | <key>showValue</key> | ||||
<true/> | <true/> | ||||
</dict> | </dict> | ||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSGroupCell</string> | |||||
<key>footerText</key> | |||||
<string>In order to apply preferences, restart the app. If changes do not immediately take effect, wait a few seconds and try again.</string> | |||||
</dict> | |||||
</array> | </array> | ||||
<key>title</key> | <key>title</key> | ||||
<string>TFDidThatSay?</string> | <string>TFDidThatSay?</string> |
#import <Cephei/HBPreferences.h> | |||||
#import "Apollo.h" | #import "Apollo.h" | ||||
HBPreferences *apolloPrefs; | |||||
BOOL isApolloDeletedCommentsOnly; | |||||
CGFloat apolloRequestTimeoutValue; | |||||
static BOOL isApolloDeletedCommentsOnly; | |||||
static BOOL isApolloEnabled; | |||||
static CGFloat pushshiftRequestTimeoutValue; | |||||
%group Apollo | %group Apollo | ||||
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/comment/?ids=%@&fields=author,body",[[comment fullName] componentsSeparatedByString:@"_"][1]]]]; | [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/comment/?ids=%@&fields=author,body",[[comment fullName] componentsSeparatedByString:@"_"][1]]]]; | ||||
[request setHTTPMethod:@"GET"]; | [request setHTTPMethod:@"GET"]; | ||||
[request setTimeoutInterval:[apolloPrefs doubleForKey:@"requestTimeoutValue" default:10]]; | |||||
[request setTimeoutInterval:pushshiftRequestTimeoutValue]; | |||||
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | ||||
id commentBody = [MSHookIvar<id>(self, "comment") body]; | id commentBody = [MSHookIvar<id>(self, "comment") body]; | ||||
BOOL isDeletedOnly = [apolloPrefs boolForKey:@"isApolloDeletedCommentsOnly"]; | |||||
if ((isDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isDeletedOnly) { | |||||
if ((isApolloDeletedCommentsOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isApolloDeletedCommentsOnly) { | |||||
CGFloat imageSize = 20.0f; | CGFloat imageSize = 20.0f; | ||||
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/submission/?ids=%@&fields=author,selftext",[[post fullName] componentsSeparatedByString:@"_"][1]]]]; | [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/submission/?ids=%@&fields=author,selftext",[[post fullName] componentsSeparatedByString:@"_"][1]]]]; | ||||
[request setHTTPMethod:@"GET"]; | [request setHTTPMethod:@"GET"]; | ||||
[request setTimeoutInterval:[apolloPrefs doubleForKey:@"requestTimeoutValue" default:10]]; | |||||
[request setTimeoutInterval:pushshiftRequestTimeoutValue]; | |||||
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | ||||
%end | %end | ||||
%ctor { | |||||
static void loadPrefs(){ | |||||
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"]; | |||||
if (prefs){ | |||||
if ([prefs objectForKey:@"isApolloEnabled"] != nil) { | |||||
isApolloEnabled = [[prefs objectForKey:@"isApolloEnabled"] boolValue]; | |||||
} else { | |||||
isApolloEnabled = YES; | |||||
} | |||||
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){ | |||||
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue]; | |||||
} else { | |||||
pushshiftRequestTimeoutValue = 10; | |||||
} | |||||
if ([prefs objectForKey:@"isApolloDeletedCommentsOnly"] != nil) { | |||||
isApolloDeletedCommentsOnly = [[prefs objectForKey:@"isApolloDeletedCommentsOnly"] boolValue]; | |||||
} else { | |||||
isApolloDeletedCommentsOnly = YES; | |||||
} | |||||
apolloPrefs = [[HBPreferences alloc] initWithIdentifier:@"com.lint.undelete.prefs"]; | |||||
[apolloPrefs registerBool:&isApolloDeletedCommentsOnly default:YES forKey:@"isApolloDeletedCommentsOnly"]; | |||||
[apolloPrefs registerDouble:&apolloRequestTimeoutValue default:10 forKey:@"requestTimeoutValue"]; | |||||
} else { | |||||
isApolloEnabled = YES; | |||||
pushshiftRequestTimeoutValue = 10; | |||||
isApolloDeletedCommentsOnly = YES; | |||||
} | |||||
} | |||||
%ctor { | |||||
loadPrefs(); | |||||
NSString* processName = [[NSProcessInfo processInfo] processName]; | NSString* processName = [[NSProcessInfo processInfo] processName]; | ||||
if ([processName isEqualToString:@"Apollo"]){ | if ([processName isEqualToString:@"Apollo"]){ | ||||
%init(Apollo, ApolloCommentsHeaderCellNode = objc_getClass("Apollo.CommentsHeaderCellNode"), ApolloCommentCellNode = objc_getClass("Apollo.CommentCellNode"), ApolloApolloButtonNode = objc_getClass("Apollo.ApolloButtonNode")); | |||||
if (isApolloEnabled){ | |||||
%init(Apollo, ApolloCommentsHeaderCellNode = objc_getClass("Apollo.CommentsHeaderCellNode"), ApolloCommentCellNode = objc_getClass("Apollo.CommentCellNode"), ApolloApolloButtonNode = objc_getClass("Apollo.ApolloButtonNode")); | |||||
} | |||||
} | } | ||||
} | } |
#import <Cephei/HBPreferences.h> | |||||
#import "Narwhal.h" | #import "Narwhal.h" | ||||
HBPreferences *narwhalPrefs; | |||||
CGFloat narwhalRequestTimeoutValue; | |||||
static BOOL isNarwhalEnabled; | |||||
static CGFloat pushshiftRequestTimeoutValue; | |||||
%group Narwhal | %group Narwhal | ||||
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/comment/?ids=%@&fields=author,body",[[comment fullName] componentsSeparatedByString:@"_"][1]]]]; | [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/comment/?ids=%@&fields=author,body",[[comment fullName] componentsSeparatedByString:@"_"][1]]]]; | ||||
[request setHTTPMethod:@"GET"]; | [request setHTTPMethod:@"GET"]; | ||||
[request setTimeoutInterval:[narwhalPrefs doubleForKey:@"requestTimeoutValue" default:10]]; | |||||
[request setTimeoutInterval:pushshiftRequestTimeoutValue]; | |||||
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | ||||
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/submission/?ids=%@&fields=author,selftext",[[post fullName] componentsSeparatedByString:@"_"][1]]]]; | [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/submission/?ids=%@&fields=author,selftext",[[post fullName] componentsSeparatedByString:@"_"][1]]]]; | ||||
[request setHTTPMethod:@"GET"]; | [request setHTTPMethod:@"GET"]; | ||||
[request setTimeoutInterval:[narwhalPrefs doubleForKey:@"requestTimeoutValue" default:10]]; | |||||
[request setTimeoutInterval:pushshiftRequestTimeoutValue]; | |||||
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | ||||
%end | %end | ||||
%ctor { | |||||
static void loadPrefs(){ | |||||
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"]; | |||||
narwhalPrefs = [[HBPreferences alloc] initWithIdentifier:@"com.lint.undelete.prefs"]; | |||||
[narwhalPrefs registerDouble:&narwhalRequestTimeoutValue default:10 forKey:@"requestTimeoutValue"]; | |||||
if (prefs){ | |||||
if ([prefs objectForKey:@"isNarwhalEnabled"] != nil){ | |||||
isNarwhalEnabled = [[prefs objectForKey:@"isNarwhalEnabled"] boolValue]; | |||||
} else { | |||||
isNarwhalEnabled = YES; | |||||
} | |||||
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){ | |||||
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue]; | |||||
} else { | |||||
pushshiftRequestTimeoutValue = 10; | |||||
} | |||||
} else { | |||||
isNarwhalEnabled = YES; | |||||
pushshiftRequestTimeoutValue = 10; | |||||
} | |||||
} | |||||
%ctor { | |||||
loadPrefs(); | |||||
NSString* processName = [[NSProcessInfo processInfo] processName]; | NSString* processName = [[NSProcessInfo processInfo] processName]; | ||||
if ([processName isEqualToString:@"narwhal"]){ | |||||
%init(Narwhal); | |||||
if ([processName isEqualToString:@"narwhal"]){ | |||||
if (isNarwhalEnabled){ | |||||
%init(Narwhal); | |||||
} | |||||
} | } | ||||
} | } | ||||
#import <Cephei/HBPreferences.h> | |||||
#import "Reddit.h" | #import "Reddit.h" | ||||
HBPreferences *redditPrefs; | |||||
CGFloat redditRequestTimeoutValue; | |||||
static CGFloat pushshiftRequestTimeoutValue; | |||||
static BOOL isRedditEnabled; | |||||
NSArray *redditVersion; | NSArray *redditVersion; | ||||
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/comment/?ids=%@&fields=author,body",[[comment pk] componentsSeparatedByString:@"_"][1]]]]; | [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/comment/?ids=%@&fields=author,body",[[comment pk] componentsSeparatedByString:@"_"][1]]]]; | ||||
[request setHTTPMethod:@"GET"]; | [request setHTTPMethod:@"GET"]; | ||||
[request setTimeoutInterval:[redditPrefs doubleForKey:@"requestTimeoutValue" default:10]]; | |||||
[request setTimeoutInterval:pushshiftRequestTimeoutValue]; | |||||
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | ||||
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/submission/?ids=%@&fields=author,selftext",[[post pk] componentsSeparatedByString:@"_"][1]]]]; | [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/submission/?ids=%@&fields=author,selftext",[[post pk] componentsSeparatedByString:@"_"][1]]]]; | ||||
[request setHTTPMethod:@"GET"]; | [request setHTTPMethod:@"GET"]; | ||||
[request setTimeoutInterval:[redditPrefs doubleForKey:@"requestTimeoutValue" default:10]]; | |||||
[request setTimeoutInterval:pushshiftRequestTimeoutValue]; | |||||
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | ||||
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/comment/?ids=%@&fields=author,body",[[comment pk] componentsSeparatedByString:@"_"][1]]]]; | [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/comment/?ids=%@&fields=author,body",[[comment pk] componentsSeparatedByString:@"_"][1]]]]; | ||||
[request setHTTPMethod:@"GET"]; | [request setHTTPMethod:@"GET"]; | ||||
[request setTimeoutInterval:[redditPrefs doubleForKey:@"requestTimeoutValue" default:10]]; | |||||
[request setTimeoutInterval:pushshiftRequestTimeoutValue]; | |||||
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | ||||
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/comment/?ids=%@&fields=author,body",[[comment pk] componentsSeparatedByString:@"_"][1]]]]; | [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/comment/?ids=%@&fields=author,body",[[comment pk] componentsSeparatedByString:@"_"][1]]]]; | ||||
[request setHTTPMethod:@"GET"]; | [request setHTTPMethod:@"GET"]; | ||||
[request setTimeoutInterval:[redditPrefs doubleForKey:@"requestTimeoutValue" default:10]]; | |||||
[request setTimeoutInterval:pushshiftRequestTimeoutValue]; | |||||
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | ||||
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/submission/?ids=%@&fields=author,selftext",[[post pk] componentsSeparatedByString:@"_"][1]]]]; | [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/submission/?ids=%@&fields=author,selftext",[[post pk] componentsSeparatedByString:@"_"][1]]]]; | ||||
[request setHTTPMethod:@"GET"]; | [request setHTTPMethod:@"GET"]; | ||||
[request setTimeoutInterval:[redditPrefs doubleForKey:@"requestTimeoutValue" default:10]]; | |||||
[request setTimeoutInterval:pushshiftRequestTimeoutValue]; | |||||
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | ||||
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/submission/?ids=%@&fields=author,selftext",[[post pk] componentsSeparatedByString:@"_"][1]]]]; | [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/submission/?ids=%@&fields=author,selftext",[[post pk] componentsSeparatedByString:@"_"][1]]]]; | ||||
[request setHTTPMethod:@"GET"]; | [request setHTTPMethod:@"GET"]; | ||||
[request setTimeoutInterval:[redditPrefs doubleForKey:@"requestTimeoutValue" default:10]]; | |||||
[request setTimeoutInterval:pushshiftRequestTimeoutValue]; | |||||
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | ||||
%end | %end | ||||
static void loadPrefs(){ | |||||
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"]; | |||||
if (prefs){ | |||||
if ([prefs objectForKey:@"isRedditEnabled"] != nil){ | |||||
isRedditEnabled = [[prefs objectForKey:@"isRedditEnabled"] boolValue]; | |||||
} else { | |||||
isRedditEnabled = YES; | |||||
} | |||||
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){ | |||||
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue]; | |||||
} else { | |||||
pushshiftRequestTimeoutValue = 10; | |||||
} | |||||
} else { | |||||
isRedditEnabled = YES; | |||||
pushshiftRequestTimeoutValue = 10; | |||||
} | |||||
} | |||||
%ctor{ | %ctor{ | ||||
redditPrefs = [[HBPreferences alloc] initWithIdentifier:@"com.lint.undelete.prefs"]; | |||||
[redditPrefs registerDouble:&redditRequestTimeoutValue default:10 forKey:@"requestTimeoutValue"]; | |||||
loadPrefs(); | |||||
NSString* processName = [[NSProcessInfo processInfo] processName]; | NSString* processName = [[NSProcessInfo processInfo] processName]; | ||||
redditVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."]; | redditVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."]; | ||||
if ([processName isEqualToString:@"Reddit"]){ | |||||
if ([redditVersion[0] isEqualToString:@"4"]){ | |||||
if ([redditVersion[1] integerValue] <= 32){ | |||||
%init(Reddit_v4_ios10); | |||||
} else{ | |||||
%init(Reddit_v4_current); | |||||
} | |||||
} else if ([redditVersion[0] isEqualToString:@"3"]) { | |||||
%init(Reddit_v3); | |||||
if ([processName isEqualToString:@"Reddit"]){ | |||||
if (isRedditEnabled) { | |||||
if ([redditVersion[0] isEqualToString:@"4"]){ | |||||
if ([redditVersion[1] integerValue] <= 32){ | |||||
%init(Reddit_v4_ios10); | |||||
} else{ | |||||
%init(Reddit_v4_current); | |||||
} | |||||
} else if ([redditVersion[0] isEqualToString:@"3"]) { | |||||
%init(Reddit_v3); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } |