diff --git a/tweak/AlienBlue.xm b/tweak/AlienBlue.xm index f3c68d7..df2348e 100644 --- a/tweak/AlienBlue.xm +++ b/tweak/AlienBlue.xm @@ -22,7 +22,7 @@ static CGFloat pushshiftRequestTimeoutValue; body = [[(CommentNode *)arg1 comment] body]; } - if ((isTFDeletedOnly && ([body isEqualToString:@"[deleted]"] || [body isEqualToString:@"[removed]"])) || !isTFDeletedOnly) { + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:body isDeletedOnly:isTFDeletedOnly]){ CGSize refSize = [[self buttons][0] frame].size; diff --git a/tweak/Antenna.xm b/tweak/Antenna.xm index c8c69a6..08c1f1a 100644 --- a/tweak/Antenna.xm +++ b/tweak/Antenna.xm @@ -35,7 +35,7 @@ id tfAntennaCommentCell; NSString *commentBody = [[[arg1 comment] commentText] body]; - if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){ + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){ tfAntennaController = self; tfAntennaCommentCell = arg1; shouldHaveAntennaUndeleteAction = YES; @@ -115,7 +115,7 @@ id tfAntennaCommentCell; NSString *postBody = [[post selfCommentText] body]; if ([post isSelfPost]){ - if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) { + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){ isAbleToUndeletePost = YES; NSMutableArray *barButtons = [self defaultHeaderButtons]; diff --git a/tweak/Apollo.xm b/tweak/Apollo.xm index aafe372..ee13cfc 100644 --- a/tweak/Apollo.xm +++ b/tweak/Apollo.xm @@ -44,7 +44,7 @@ NSDictionary* apolloBodyAttributes = nil; id commentBody = [MSHookIvar(self, "comment") body]; - if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) { + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){ CGFloat imageSize = 20.0f; @@ -126,7 +126,7 @@ NSDictionary* apolloBodyAttributes = nil; id postBody = [post selfText]; if ([post isSelfPost]){ - if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) { + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){ CGFloat imageSize = 20.0f; diff --git a/tweak/BaconReader.xm b/tweak/BaconReader.xm index ed78949..04d4f07 100644 --- a/tweak/BaconReader.xm +++ b/tweak/BaconReader.xm @@ -94,7 +94,7 @@ id tfStoryController; NSString *commentBody = [[arg1 comment] body]; - if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) { + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){ shouldHaveBRUndeleteAction = YES; tfCommentCellView = arg1; tfStoryController = self; @@ -111,7 +111,7 @@ id tfStoryController; if ([[self story] is_selfValue]){ NSString *postBody = [[self story] selftext]; - if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) { + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){ shouldHaveBRUndeleteAction = YES; tfCommentCellView = nil; tfStoryController = self; diff --git a/tweak/Beam.xm b/tweak/Beam.xm index 7737200..ac29be5 100644 --- a/tweak/Beam.xm +++ b/tweak/Beam.xm @@ -26,7 +26,7 @@ static CGFloat pushshiftRequestTimeoutValue; NSString *commentBody = [[self comment] content]; - if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){ + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){ CGFloat authorTextHeight = [[self authorButton] frame].size.height; @@ -114,7 +114,7 @@ static CGFloat pushshiftRequestTimeoutValue; NSString *postBody = [[self post] content]; - if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){ + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){ id moreButton = MSHookIvar(self, "moreButton"); diff --git a/tweak/Narwhal.xm b/tweak/Narwhal.xm index 4c59aa2..8277db6 100644 --- a/tweak/Narwhal.xm +++ b/tweak/Narwhal.xm @@ -49,7 +49,7 @@ void getUndeleteCommentData(id controller, id comment){ NSString *commentBody = MSHookIvar([arg1 comment], "_body"); - if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){ + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){ tfComment = [arg1 comment]; tfController = self; shouldHaveUndeleteAction = YES; @@ -68,7 +68,7 @@ void getUndeleteCommentData(id controller, id comment){ NSString *postBody = [[self link] selfText]; - if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){ + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){ tfController = self; tfComment = nil; shouldHaveUndeleteAction = YES; @@ -127,7 +127,7 @@ void getUndeleteCommentData(id controller, id comment){ NSString *commentBody = MSHookIvar([arg1 comment], "_body"); - if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){ + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){ tfComment = [arg1 comment]; tfController = self; shouldHaveUndeleteAction = YES; diff --git a/tweak/Reddit.xm b/tweak/Reddit.xm index 3210323..85d8797 100644 --- a/tweak/Reddit.xm +++ b/tweak/Reddit.xm @@ -66,7 +66,7 @@ int getRedditVersionPart(int index){ NSString *commentBody = [[self comment] bodyText]; - if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){ + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){ UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"]; @@ -193,7 +193,7 @@ int getRedditVersionPart(int index){ NSString *postBody = [post selfText]; if ([post isSelfPost]){ - if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){ + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){ UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"]; @@ -334,7 +334,7 @@ int getRedditVersionPart(int index){ NSString *commentBody = [[self comment] bodyText]; - if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){ + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){ UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"]; @@ -419,7 +419,7 @@ int getRedditVersionPart(int index){ NSString *postBody = [post selfText]; if ([post isSelfPost]){ - if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){ + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){ UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"]; diff --git a/tweak/Slide.xm b/tweak/Slide.xm index 817af33..efd2435 100644 --- a/tweak/Slide.xm +++ b/tweak/Slide.xm @@ -264,9 +264,9 @@ static UIButton *createUndeleteButton(){ %new -(void) addUndeleteButtonToMenu{ - NSString *body = [MSHookIvar(self, "comment") body]; - - if ((isTFDeletedOnly && ([body isEqualToString:@"[deleted]"] || [body isEqualToString:@"[removed]"])) || !isTFDeletedOnly){ + NSString *commentBody = [MSHookIvar(self, "comment") body]; + + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){ id controller = MSHookIvar(self, "parent"); @@ -465,7 +465,7 @@ static UIButton *createUndeleteButton(){ NSString *postBody = [post body]; - if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){ + if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){ return YES; } } diff --git a/tweak/assets/TFHelper.h b/tweak/assets/TFHelper.h index 7694e00..1b597dd 100644 --- a/tweak/assets/TFHelper.h +++ b/tweak/assets/TFHelper.h @@ -2,5 +2,6 @@ @interface TFHelper : NSObject +(void) getUndeleteDataWithID:(NSString *) ident isComment:(BOOL) isComment timeout:(CGFloat) timeout extraData:(NSDictionary *) extra completionTarget:(id) target completionSelector:(SEL) sel; ++(BOOL) shouldShowUndeleteButtonWithInfo:(NSString *) content isDeletedOnly:(BOOL) isDeletedOnly; @end diff --git a/tweak/assets/TFHelper.m b/tweak/assets/TFHelper.m index e2cffc2..fc2a51e 100644 --- a/tweak/assets/TFHelper.m +++ b/tweak/assets/TFHelper.m @@ -47,4 +47,19 @@ }]; } -@end \ No newline at end of file ++(BOOL) shouldShowUndeleteButtonWithInfo:(NSString *) content isDeletedOnly:(BOOL) isDeletedOnly{ + + if (!isDeletedOnly){ + return YES; + } else { + if ([content isEqualToString:@"[deleted]"] || [content isEqualToString:@"[removed]"]){ + return YES; + } else if ([content hasPrefix:@"[pushshift"] || [content hasPrefix:@"[an error occured"]){ + return YES; + } + } + + return NO; +} + +@end