|
|
|
|
|
|
|
|
|
|
|
|
|
|
#import "Reddit.h"
|
|
|
#import "Reddit.h"
|
|
|
|
|
|
|
|
|
%group Redditv4
|
|
|
|
|
|
|
|
|
%group Reddit_v4_current
|
|
|
|
|
|
|
|
|
%hook CommentTreeNode
|
|
|
%hook CommentTreeNode
|
|
|
%property(assign,nonatomic)id commentTreeHeaderNode;
|
|
|
%property(assign,nonatomic)id commentTreeHeaderNode;
|
|
|
%property(assign,nonatomic)id commentTreeCommandBarNode;
|
|
|
%property(assign,nonatomic)id commentTreeCommandBarNode;
|
|
|
%end
|
|
|
%end
|
|
|
|
|
|
|
|
|
|
|
|
%hook CommentTreeHeaderView
|
|
|
|
|
|
|
|
|
|
|
|
-(void) layoutSubviews{
|
|
|
|
|
|
%orig;
|
|
|
|
|
|
|
|
|
|
|
|
[[self commentTreeNode] setCommentTreeHeaderNode:self];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
%end
|
|
|
|
|
|
|
|
|
%hook CommentTreeHeaderNode
|
|
|
%hook CommentTreeHeaderNode
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%hook CommentTreeCommandBarNode
|
|
|
%hook CommentTreeCommandBarNode
|
|
|
%property(assign,nonatomic) id activityIndicator;
|
|
|
|
|
|
%property(assign,nonatomic) id undeleteButton;
|
|
|
|
|
|
|
|
|
|
|
|
-(void) didLoad{
|
|
|
-(void) didLoad{
|
|
|
%orig;
|
|
|
%orig;
|
|
|
|
|
|
|
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
|
|
|
|
|
id commentTreeNode = [self commentTreeNode];
|
|
|
id commentTreeNode = [self commentTreeNode];
|
|
|
id comment = [commentTreeNode comment];
|
|
|
|
|
|
|
|
|
Comment *comment = [commentTreeNode comment];
|
|
|
|
|
|
|
|
|
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
|
|
|
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
|
|
|
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
|
|
|
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
|
|
|
|
|
|
|
|
|
} else if (error != nil || data == nil){
|
|
|
} else if (error != nil || data == nil){
|
|
|
body = @"[an error occured]";
|
|
|
body = @"[an error occured]";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSArray* appVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."];
|
|
|
NSArray* appVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."];
|
|
|
|
|
|
|
|
|
|
|
|
NSMutableAttributedString *bodyMutableAttributedText;
|
|
|
|
|
|
|
|
|
id themeManager;
|
|
|
id themeManager;
|
|
|
id isNightMode;
|
|
|
id isNightMode;
|
|
|
id textColor;
|
|
|
id textColor;
|
|
|
|
|
|
|
|
|
textColor = [[themeManager lightTheme] bodyTextColor];
|
|
|
textColor = [[themeManager lightTheme] bodyTextColor];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
[themeManager release];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if ([appVersion[1] integerValue] >= 37){
|
|
|
themeManager = [[%c(ThemeManager) alloc] initWithTraitCollection:nil appSettings:[%c(AppSettings) sharedSettings]];
|
|
|
themeManager = [[%c(ThemeManager) alloc] initWithTraitCollection:nil appSettings:[%c(AppSettings) sharedSettings]];
|
|
|
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
|
|
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else{
|
|
|
} else{
|
|
|
textColor = [[themeManager dayTheme] bodyTextColor];
|
|
|
textColor = [[themeManager dayTheme] bodyTextColor];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NSMutableAttributedString *bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[themeManager release];
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
themeManager = [%c(ThemeManager) sharedManager];
|
|
|
|
|
|
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
|
|
|
|
|
|
|
|
|
|
|
if (isNightMode) {
|
|
|
|
|
|
textColor = [[themeManager nightTheme] bodyTextColor];
|
|
|
|
|
|
} else{
|
|
|
|
|
|
textColor = [[themeManager dayTheme] bodyTextColor];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
|
|
|
|
|
|
|
|
|
[bodyMutableAttributedText beginEditing];
|
|
|
[bodyMutableAttributedText beginEditing];
|
|
|
[bodyMutableAttributedText enumerateAttribute:NSForegroundColorAttributeName inRange:NSMakeRange(0, bodyMutableAttributedText.length) options:0 usingBlock:^(id _Nullable value, NSRange range, BOOL * _Nonnull stop) {
|
|
|
[bodyMutableAttributedText enumerateAttribute:NSForegroundColorAttributeName inRange:NSMakeRange(0, bodyMutableAttributedText.length) options:0 usingBlock:^(id _Nullable value, NSRange range, BOOL * _Nonnull stop) {
|
|
|
|
|
|
|
|
|
}];
|
|
|
}];
|
|
|
[bodyMutableAttributedText endEditing];
|
|
|
[bodyMutableAttributedText endEditing];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[comment setValue:bodyMutableAttributedText forKey:@"bodyRichTextAttributed"];
|
|
|
|
|
|
|
|
|
|
|
|
[comment setValue:author forKey:@"author"];
|
|
|
|
|
|
[comment setValue:body forKey:@"bodyText"];
|
|
|
|
|
|
|
|
|
|
|
|
[comment setValue:bodyMutableAttributedText forKey:@"bodyAttributedText"];
|
|
|
|
|
|
|
|
|
[comment setAuthor:author];
|
|
|
|
|
|
[comment setBodyText:body];
|
|
|
|
|
|
[comment setBodyRichTextAttributed:bodyMutableAttributedText];
|
|
|
|
|
|
[comment setBodyAttributedText:bodyMutableAttributedText];
|
|
|
|
|
|
|
|
|
[[commentTreeNode commentTreeHeaderNode] updateContentViewsForData:comment];
|
|
|
|
|
|
|
|
|
[[commentTreeNode commentTreeHeaderNode] performSelectorOnMainThread:@selector(updateContentViewsForData:) withObject:comment waitUntilDone:NO];
|
|
|
|
|
|
|
|
|
[request release];
|
|
|
[request release];
|
|
|
[queue release];
|
|
|
[queue release];
|
|
|
[bodyMutableAttributedText release];
|
|
|
[bodyMutableAttributedText release];
|
|
|
[themeManager release];
|
|
|
|
|
|
|
|
|
|
|
|
}];
|
|
|
}];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%hook PostDetailViewController
|
|
|
%hook PostDetailViewController
|
|
|
%property(assign,nonatomic) id feedPostTextWithThumbnailNode;
|
|
|
|
|
|
%property(assign,nonatomic) id feedPostDetailCellNode;
|
|
|
|
|
|
|
|
|
%property(strong,nonatomic) id feedPostTextWithThumbnailNode;
|
|
|
|
|
|
%property(strong,nonatomic) id feedPostDetailCellNode;
|
|
|
%end
|
|
|
%end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%hook FeedPostDetailCellNode
|
|
|
%hook FeedPostDetailCellNode
|
|
|
|
|
|
|
|
|
-(void) didLoad{
|
|
|
-(void) didLoad{
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
%end
|
|
|
%end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%hook PostActionSheetViewController
|
|
|
%hook PostActionSheetViewController
|
|
|
|
|
|
|
|
|
-(void) setItems:(id) arg1{
|
|
|
-(void) setItems:(id) arg1{
|
|
|
|
|
|
|
|
|
id post = [self post];
|
|
|
|
|
|
|
|
|
Post *post = [self post];
|
|
|
|
|
|
|
|
|
if ([post isSelfPost]){
|
|
|
if ([post isSelfPost]){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
|
|
|
|
|
id post = [self post];
|
|
|
|
|
|
|
|
|
Post *post = [self post];
|
|
|
|
|
|
|
|
|
if ([post isSelfPost]){
|
|
|
if ([post isSelfPost]){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
textColor = [[themeManager lightTheme] bodyTextColor];
|
|
|
textColor = [[themeManager lightTheme] bodyTextColor];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
[themeManager release];
|
|
|
|
|
|
|
|
|
|
|
|
} else if ([appVersion[1] integerValue] >= 37){
|
|
|
themeManager = [[%c(ThemeManager) alloc] initWithTraitCollection:nil appSettings:[%c(AppSettings) sharedSettings]];
|
|
|
themeManager = [[%c(ThemeManager) alloc] initWithTraitCollection:nil appSettings:[%c(AppSettings) sharedSettings]];
|
|
|
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
|
|
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else{
|
|
|
} else{
|
|
|
textColor = [[themeManager dayTheme] bodyTextColor];
|
|
|
textColor = [[themeManager dayTheme] bodyTextColor];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[themeManager release];
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
themeManager = [%c(ThemeManager) sharedManager];
|
|
|
|
|
|
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
|
|
|
|
|
|
|
|
|
|
|
if (isNightMode) {
|
|
|
|
|
|
textColor = [[themeManager nightTheme] bodyTextColor];
|
|
|
|
|
|
} else{
|
|
|
|
|
|
textColor = [[themeManager dayTheme] bodyTextColor];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
NSMutableAttributedString *bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
|
|
|
NSMutableAttributedString *bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}];
|
|
|
}];
|
|
|
[bodyMutableAttributedText endEditing];
|
|
|
[bodyMutableAttributedText endEditing];
|
|
|
|
|
|
|
|
|
[post setValue:bodyMutableAttributedText forKey:@"selfPostRichTextAttributed"];
|
|
|
|
|
|
[post setValue:bodyMutableAttributedText forKey:@"previewFeedPostTextString"];
|
|
|
|
|
|
|
|
|
[post setSelfText:body];
|
|
|
[post setAuthor:author];
|
|
|
[post setAuthor:author];
|
|
|
[post setValue:body forKey:@"selfText"];
|
|
|
|
|
|
|
|
|
[post setSelfPostRichTextAttributed:bodyMutableAttributedText];
|
|
|
|
|
|
[post setPreviewFeedPostTextString:bodyMutableAttributedText];
|
|
|
|
|
|
|
|
|
if ([appVersion[1] integerValue] >= 44){
|
|
|
if ([appVersion[1] integerValue] >= 44){
|
|
|
[[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] configureSelfTextNode];
|
|
|
[[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] configureSelfTextNode];
|
|
|
|
|
|
} else if ([appVersion[1] integerValue] >= 38) {
|
|
|
|
|
|
[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] configureSelfTextNode];
|
|
|
} else {
|
|
|
} else {
|
|
|
[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] configureSelfTextNode];
|
|
|
[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] configureSelfTextNode];
|
|
|
|
|
|
[[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] titleNode] configureNodes];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
[request release];
|
|
|
[request release];
|
|
|
[queue release];
|
|
|
[queue release];
|
|
|
[bodyMutableAttributedText release];
|
|
|
[bodyMutableAttributedText release];
|
|
|
[themeManager release];
|
|
|
|
|
|
}];
|
|
|
}];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%group Redditv3
|
|
|
|
|
|
|
|
|
%group Reddit_v4_ios10
|
|
|
|
|
|
|
|
|
|
|
|
%hook CommentsViewController
|
|
|
|
|
|
|
|
|
|
|
|
%new
|
|
|
|
|
|
-(void) updateComments{
|
|
|
|
|
|
[self reloadCommentsWithNewCommentsHighlight:NO autoScroll:NO animated:NO];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
%new
|
|
|
|
|
|
-(void) updatePostText{
|
|
|
|
|
|
[self reloadPostSection:YES];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
%end
|
|
|
|
|
|
|
|
|
|
|
|
%hook CommentActionSheetViewController
|
|
|
|
|
|
|
|
|
|
|
|
-(void) setItems:(id) arg1{
|
|
|
|
|
|
|
|
|
|
|
|
UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
|
|
|
|
|
|
|
|
|
|
|
|
CGSize existingImageSize = [[arg1[0] leftIconImage] size];
|
|
|
|
|
|
CGFloat scale = origImage.size.width / existingImageSize.width;
|
|
|
|
|
|
|
|
|
|
|
|
UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
|
|
|
|
|
|
|
|
|
|
|
|
id undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self comment]];
|
|
|
|
|
|
|
|
|
|
|
|
%orig([arg1 arrayByAddingObject:undeleteItem]);
|
|
|
|
|
|
|
|
|
|
|
|
[undeleteItem release];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-(void) handleDidSelectActionSheetItem:(id) arg1{
|
|
|
|
|
|
%orig;
|
|
|
|
|
|
|
|
|
|
|
|
if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]){
|
|
|
|
|
|
|
|
|
|
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
|
|
|
|
|
|
|
|
Comment *comment = [self comment];
|
|
|
|
|
|
|
|
|
|
|
|
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
|
|
|
|
|
|
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
|
|
|
|
|
|
|
|
|
|
|
|
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/comment/?ids=%@&fields=author,body",[[comment pk] componentsSeparatedByString:@"_"][1]]]];
|
|
|
|
|
|
[request setHTTPMethod:@"GET"];
|
|
|
|
|
|
|
|
|
|
|
|
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
|
|
|
|
|
|
|
|
|
|
|
|
NSString *author = @"[author]";
|
|
|
|
|
|
NSString *body = @"[body]";
|
|
|
|
|
|
|
|
|
|
|
|
if (data != nil && error == nil){
|
|
|
|
|
|
id jsonData = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
|
|
|
|
|
|
if ([[jsonData objectForKey:@"data"] count] != 0){
|
|
|
|
|
|
author = [[jsonData objectForKey:@"data"][0] objectForKey:@"author"];
|
|
|
|
|
|
body = [[jsonData objectForKey:@"data"][0] objectForKey:@"body"];
|
|
|
|
|
|
if ([body isEqualToString:@"[deleted]"] || [body isEqualToString:@"[removed]"]){
|
|
|
|
|
|
body = @"[pushshift was unable to archive this]";
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
body = @"[pushshift has not archived this yet]";
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (error != nil || data == nil){
|
|
|
|
|
|
body = @"[an error occured]";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NSMutableAttributedString *bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
|
|
|
|
|
|
|
|
|
|
|
|
[comment setAuthor:author];
|
|
|
|
|
|
[comment setBodyText:body];
|
|
|
|
|
|
[comment setBodyRichTextAttributed:bodyMutableAttributedText];
|
|
|
|
|
|
[comment setBodyAttributedText:bodyMutableAttributedText];
|
|
|
|
|
|
|
|
|
|
|
|
[[self commentActionSheetDelegate] performSelectorOnMainThread:@selector(updateComments) withObject:nil waitUntilDone:NO];
|
|
|
|
|
|
|
|
|
|
|
|
[request release];
|
|
|
|
|
|
[queue release];
|
|
|
|
|
|
[bodyMutableAttributedText release];
|
|
|
|
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
%end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%hook PostActionSheetViewController
|
|
|
|
|
|
|
|
|
|
|
|
-(void) setItems:(id) arg1{
|
|
|
|
|
|
|
|
|
|
|
|
Post *post = [self post];
|
|
|
|
|
|
|
|
|
|
|
|
if ([post isSelfPost]){
|
|
|
|
|
|
|
|
|
|
|
|
UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
|
|
|
|
|
|
|
|
|
|
|
|
CGSize existingImageSize = [[arg1[0] leftIconImage] size];
|
|
|
|
|
|
CGFloat scale = origImage.size.width / existingImageSize.width;
|
|
|
|
|
|
|
|
|
|
|
|
UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
|
|
|
|
|
|
|
|
|
|
|
|
id undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self post]];
|
|
|
|
|
|
|
|
|
|
|
|
arg1 = [arg1 arrayByAddingObject:undeleteItem];
|
|
|
|
|
|
|
|
|
|
|
|
[undeleteItem release];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
%orig;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-(void) handleDidSelectActionSheetItem:(id) arg1{
|
|
|
|
|
|
%orig;
|
|
|
|
|
|
|
|
|
|
|
|
if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]){
|
|
|
|
|
|
|
|
|
|
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
|
|
|
|
|
|
|
|
Post *post = [self post];
|
|
|
|
|
|
|
|
|
|
|
|
if ([post isSelfPost]){
|
|
|
|
|
|
|
|
|
|
|
|
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
|
|
|
|
|
|
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
|
|
|
|
|
|
|
|
|
|
|
|
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/submission/?ids=%@&fields=author,selftext",[[post pk] componentsSeparatedByString:@"_"][1]]]];
|
|
|
|
|
|
[request setHTTPMethod:@"GET"];
|
|
|
|
|
|
|
|
|
|
|
|
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
|
|
|
|
|
|
|
|
|
|
|
|
NSString *author = @"[author]";
|
|
|
|
|
|
NSString *body = @"[body]";
|
|
|
|
|
|
|
|
|
|
|
|
if (data != nil && error == nil){
|
|
|
|
|
|
id jsonData = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
|
|
|
|
|
|
if ([[jsonData objectForKey:@"data"] count] != 0){
|
|
|
|
|
|
author = [[jsonData objectForKey:@"data"][0] objectForKey:@"author"];
|
|
|
|
|
|
body = [[jsonData objectForKey:@"data"][0] objectForKey:@"selftext"];
|
|
|
|
|
|
if ([body isEqualToString:@"[deleted]"] || [body isEqualToString:@"[removed]"]){
|
|
|
|
|
|
body = @"[pushshift was unable to archive this]";
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
body = @"[pushshift has not archived this yet]";
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (error != nil || data == nil){
|
|
|
|
|
|
body = @"[an error occured]";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NSMutableAttributedString *bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
|
|
|
|
|
|
|
|
|
|
|
|
[post setSelfText:body];
|
|
|
|
|
|
[post setAuthor:author];
|
|
|
|
|
|
[post setSelfPostRichTextAttributed:bodyMutableAttributedText];
|
|
|
|
|
|
[post setPreviewFeedPostTextString:bodyMutableAttributedText];
|
|
|
|
|
|
|
|
|
|
|
|
[[self postActionSheetDelegate] performSelectorOnMainThread:@selector(updatePostText) withObject:nil waitUntilDone:NO];
|
|
|
|
|
|
|
|
|
|
|
|
[request release];
|
|
|
|
|
|
[queue release];
|
|
|
|
|
|
[bodyMutableAttributedText release];
|
|
|
|
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
%end
|
|
|
|
|
|
|
|
|
|
|
|
%end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%group Reddit_v3
|
|
|
|
|
|
|
|
|
%hook CommentView
|
|
|
%hook CommentView
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[comment setValue:body forKey:@"bodyText"];
|
|
|
[comment setValue:body forKey:@"bodyText"];
|
|
|
|
|
|
|
|
|
[commentsViewController reloadCommentsWithNewCommentsHighlight:NO autoScroll:NO animated:NO];
|
|
|
[commentsViewController reloadCommentsWithNewCommentsHighlight:NO autoScroll:NO animated:NO];
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIButton *button = [self undeleteButton];
|
|
|
UIButton *button = [self undeleteButton];
|
|
|
|
|
|
|
|
|
button.frame = CGRectMake([[self overflowButton ] frame].origin.x - 32, 0, 32, 32);
|
|
|
button.frame = CGRectMake([[self overflowButton ] frame].origin.x - 32, 0, 32, 32);
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
%end
|
|
|
%end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%ctor{
|
|
|
%ctor{
|
|
|
|
|
|
|
|
|
NSString* processName = [[NSProcessInfo processInfo] processName];
|
|
|
NSString* processName = [[NSProcessInfo processInfo] processName];
|
|
|
NSString* version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
|
|
|
|
|
NSArray* versionArray = [version componentsSeparatedByString:@"."];
|
|
|
|
|
|
|
|
|
NSArray* appVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."];
|
|
|
|
|
|
|
|
|
if ([processName isEqualToString:@"Reddit"]){
|
|
|
if ([processName isEqualToString:@"Reddit"]){
|
|
|
if ([versionArray[0] isEqualToString:@"4"]){
|
|
|
|
|
|
%init(Redditv4);
|
|
|
|
|
|
} else if ([versionArray[0] isEqualToString:@"3"]) {
|
|
|
|
|
|
%init(Redditv3);
|
|
|
|
|
|
|
|
|
if ([appVersion[0] isEqualToString:@"4"]){
|
|
|
|
|
|
if ([appVersion[1] integerValue] <= 32){
|
|
|
|
|
|
%init(Reddit_v4_ios10);
|
|
|
|
|
|
} else{
|
|
|
|
|
|
%init(Reddit_v4_current);
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if ([appVersion[0] isEqualToString:@"3"]) {
|
|
|
|
|
|
%init(Reddit_v3);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|