|
|
|
|
|
|
|
|
%end
|
|
|
%end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%group Reddit_v4_ios10
|
|
|
%group Reddit_v4_ios10
|
|
|
|
|
|
|
|
|
%hook CommentsViewController
|
|
|
%hook CommentsViewController
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%new
|
|
|
%new
|
|
|
-(void) updatePostText{
|
|
|
-(void) updatePostText{
|
|
|
[self reloadPostSection:YES];
|
|
|
|
|
|
|
|
|
NSArray* appVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."];
|
|
|
|
|
|
|
|
|
|
|
|
if ([appVersion[1] integerValue] >= 2){
|
|
|
|
|
|
[self reloadPostSection:YES];
|
|
|
|
|
|
} else {
|
|
|
|
|
|
[self feedPostViewDidUpdatePost:[self postData] shouldReloadFeed:NO];
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
%end
|
|
|
%end
|
|
|
|
|
|
|
|
|
CGFloat scale = origImage.size.width / existingImageSize.width;
|
|
|
CGFloat scale = origImage.size.width / existingImageSize.width;
|
|
|
|
|
|
|
|
|
UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
|
|
|
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]];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
id undeleteItem;
|
|
|
|
|
|
|
|
|
|
|
|
NSArray* appVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."];
|
|
|
|
|
|
|
|
|
|
|
|
if ([appVersion[1] integerValue] >= 18) {
|
|
|
|
|
|
undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self comment]];
|
|
|
|
|
|
} else {
|
|
|
|
|
|
undeleteItem = [[%c(ActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self comment]];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
%orig([arg1 arrayByAddingObject:undeleteItem]);
|
|
|
%orig([arg1 arrayByAddingObject:undeleteItem]);
|
|
|
|
|
|
|
|
|
[undeleteItem release];
|
|
|
[undeleteItem release];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// >= 4.21
|
|
|
-(void) handleDidSelectActionSheetItem:(id) arg1{
|
|
|
-(void) handleDidSelectActionSheetItem:(id) arg1{
|
|
|
%orig;
|
|
|
%orig;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}];
|
|
|
}];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <= 4.20
|
|
|
|
|
|
-(void) actionSheetViewController:(id) arg1 didSelectItem:(id) arg2{
|
|
|
|
|
|
%orig;
|
|
|
|
|
|
|
|
|
|
|
|
if ([[arg2 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]";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NSArray* appVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."];
|
|
|
|
|
|
|
|
|
|
|
|
NSMutableAttributedString *bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
|
|
|
|
|
|
|
|
|
|
|
|
[comment setAuthor:author];
|
|
|
|
|
|
[comment setBodyText:body];
|
|
|
|
|
|
[comment setBodyAttributedText:bodyMutableAttributedText];
|
|
|
|
|
|
|
|
|
|
|
|
if ([appVersion[1] integerValue] >= 12) {
|
|
|
|
|
|
[comment setBodyRichTextAttributed:bodyMutableAttributedText];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[[self commentActionSheetDelegate] performSelectorOnMainThread:@selector(updateComments) withObject:nil waitUntilDone:NO];
|
|
|
|
|
|
|
|
|
|
|
|
[request release];
|
|
|
|
|
|
[queue release];
|
|
|
|
|
|
[bodyMutableAttributedText release];
|
|
|
|
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
%end
|
|
|
%end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CGFloat scale = origImage.size.width / existingImageSize.width;
|
|
|
CGFloat scale = origImage.size.width / existingImageSize.width;
|
|
|
|
|
|
|
|
|
UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
|
|
|
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]];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
id undeleteItem;
|
|
|
|
|
|
|
|
|
|
|
|
NSArray* appVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."];
|
|
|
|
|
|
|
|
|
|
|
|
if ([appVersion[1] integerValue] >= 18) {
|
|
|
|
|
|
undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self post]];
|
|
|
|
|
|
} else {
|
|
|
|
|
|
undeleteItem = [[%c(ActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self post]];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
arg1 = [arg1 arrayByAddingObject:undeleteItem];
|
|
|
arg1 = [arg1 arrayByAddingObject:undeleteItem];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%orig;
|
|
|
%orig;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// >= 4.21
|
|
|
-(void) handleDidSelectActionSheetItem:(id) arg1{
|
|
|
-(void) handleDidSelectActionSheetItem:(id) arg1{
|
|
|
%orig;
|
|
|
%orig;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
%end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// <= 4.20
|
|
|
|
|
|
-(void) actionSheetViewController:(id) arg1 didSelectItem:(id) arg2{
|
|
|
|
|
|
%orig;
|
|
|
|
|
|
|
|
|
|
|
|
if ([[arg2 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]";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NSArray* appVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."];
|
|
|
|
|
|
|
|
|
|
|
|
NSMutableAttributedString *bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
|
|
|
|
|
|
|
|
|
|
|
|
[post setAuthor:author];
|
|
|
|
|
|
[post setSelfText:body];
|
|
|
|
|
|
[post setSelfTextAttributed:bodyMutableAttributedText];
|
|
|
|
|
|
|
|
|
|
|
|
if ([appVersion[1] integerValue] >= 8) {
|
|
|
|
|
|
[post setSelfPostRichTextAttributed:bodyMutableAttributedText];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ([appVersion[1] integerValue] >= 15) {
|
|
|
|
|
|
[post setPreviewFeedPostTextString:bodyMutableAttributedText];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[[self postActionSheetDelegate] performSelectorOnMainThread:@selector(updatePostText) withObject:nil waitUntilDone:NO];
|
|
|
|
|
|
|
|
|
|
|
|
[request release];
|
|
|
|
|
|
[queue release];
|
|
|
|
|
|
[bodyMutableAttributedText release];
|
|
|
|
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
%end
|
|
|
%end
|
|
|
|
|
|
|
|
|
|
|
|
%end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//outdated and unchanged from first version of this tweak...
|
|
|
|
|
|
//TODO: move button to menu, add post support, make async requests once I feel like doing it
|
|
|
%group Reddit_v3
|
|
|
%group Reddit_v3
|
|
|
|
|
|
|
|
|
%hook CommentView
|
|
|
%hook CommentView
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|