Browse Source

Add helper method

master
lint 4 years ago
parent
commit
bb0d0d9e95
10 changed files with 37 additions and 21 deletions
  1. +1
    -1
      tweak/AlienBlue.xm
  2. +2
    -2
      tweak/Antenna.xm
  3. +2
    -2
      tweak/Apollo.xm
  4. +2
    -2
      tweak/BaconReader.xm
  5. +2
    -2
      tweak/Beam.xm
  6. +3
    -3
      tweak/Narwhal.xm
  7. +4
    -4
      tweak/Reddit.xm
  8. +4
    -4
      tweak/Slide.xm
  9. +1
    -0
      tweak/assets/TFHelper.h
  10. +16
    -1
      tweak/assets/TFHelper.m

+ 1
- 1
tweak/AlienBlue.xm View File

body = [[(CommentNode *)arg1 comment] body]; 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; CGSize refSize = [[self buttons][0] frame].size;



+ 2
- 2
tweak/Antenna.xm View File

NSString *commentBody = [[[arg1 comment] commentText] body]; NSString *commentBody = [[[arg1 comment] commentText] body];
if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
tfAntennaController = self; tfAntennaController = self;
tfAntennaCommentCell = arg1; tfAntennaCommentCell = arg1;
shouldHaveAntennaUndeleteAction = YES; shouldHaveAntennaUndeleteAction = YES;
NSString *postBody = [[post selfCommentText] body]; NSString *postBody = [[post selfCommentText] body];
if ([post isSelfPost]){ if ([post isSelfPost]){
if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) {
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
isAbleToUndeletePost = YES; isAbleToUndeletePost = YES;
NSMutableArray *barButtons = [self defaultHeaderButtons]; NSMutableArray *barButtons = [self defaultHeaderButtons];

+ 2
- 2
tweak/Apollo.xm View File

id commentBody = [MSHookIvar<id>(self, "comment") body]; id commentBody = [MSHookIvar<id>(self, "comment") body];
if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) {
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
CGFloat imageSize = 20.0f; CGFloat imageSize = 20.0f;
id postBody = [post selfText]; id postBody = [post selfText];
if ([post isSelfPost]){ if ([post isSelfPost]){
if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) {
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
CGFloat imageSize = 20.0f; CGFloat imageSize = 20.0f;

+ 2
- 2
tweak/BaconReader.xm View File

NSString *commentBody = [[arg1 comment] body]; NSString *commentBody = [[arg1 comment] body];
if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) {
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
shouldHaveBRUndeleteAction = YES; shouldHaveBRUndeleteAction = YES;
tfCommentCellView = arg1; tfCommentCellView = arg1;
tfStoryController = self; tfStoryController = self;
if ([[self story] is_selfValue]){ if ([[self story] is_selfValue]){
NSString *postBody = [[self story] selftext]; NSString *postBody = [[self story] selftext];
if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) {
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
shouldHaveBRUndeleteAction = YES; shouldHaveBRUndeleteAction = YES;
tfCommentCellView = nil; tfCommentCellView = nil;
tfStoryController = self; tfStoryController = self;

+ 2
- 2
tweak/Beam.xm View File

NSString *commentBody = [[self comment] content]; 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; CGFloat authorTextHeight = [[self authorButton] frame].size.height;
NSString *postBody = [[self post] content]; NSString *postBody = [[self post] content];
if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
id moreButton = MSHookIvar<id>(self, "moreButton"); id moreButton = MSHookIvar<id>(self, "moreButton");

+ 3
- 3
tweak/Narwhal.xm View File

NSString *commentBody = MSHookIvar<NSString*>([arg1 comment], "_body"); NSString *commentBody = MSHookIvar<NSString*>([arg1 comment], "_body");
if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
tfComment = [arg1 comment]; tfComment = [arg1 comment];
tfController = self; tfController = self;
shouldHaveUndeleteAction = YES; shouldHaveUndeleteAction = YES;
NSString *postBody = [[self link] selfText]; NSString *postBody = [[self link] selfText];
if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
tfController = self; tfController = self;
tfComment = nil; tfComment = nil;
shouldHaveUndeleteAction = YES; shouldHaveUndeleteAction = YES;
NSString *commentBody = MSHookIvar<NSString*>([arg1 comment], "_body"); NSString *commentBody = MSHookIvar<NSString*>([arg1 comment], "_body");
if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
tfComment = [arg1 comment]; tfComment = [arg1 comment];
tfController = self; tfController = self;
shouldHaveUndeleteAction = YES; shouldHaveUndeleteAction = YES;

+ 4
- 4
tweak/Reddit.xm View File

NSString *commentBody = [[self comment] bodyText]; 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"]; UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
NSString *postBody = [post selfText]; NSString *postBody = [post selfText];
if ([post isSelfPost]){ 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"]; UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
NSString *commentBody = [[self comment] bodyText]; 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"]; UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
NSString *postBody = [post selfText]; NSString *postBody = [post selfText];
if ([post isSelfPost]){ 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"]; UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];

+ 4
- 4
tweak/Slide.xm View File

%new %new
-(void) addUndeleteButtonToMenu{ -(void) addUndeleteButtonToMenu{
NSString *body = [MSHookIvar<id>(self, "comment") body];
if ((isTFDeletedOnly && ([body isEqualToString:@"[deleted]"] || [body isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
NSString *commentBody = [MSHookIvar<id>(self, "comment") body];
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
id controller = MSHookIvar<id>(self, "parent"); id controller = MSHookIvar<id>(self, "parent");
NSString *postBody = [post body]; NSString *postBody = [post body];
if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
return YES; return YES;
} }
} }

+ 1
- 0
tweak/assets/TFHelper.h View File

@interface TFHelper : NSObject @interface TFHelper : NSObject
+(void) getUndeleteDataWithID:(NSString *) ident isComment:(BOOL) isComment timeout:(CGFloat) timeout extraData:(NSDictionary *) extra completionTarget:(id) target completionSelector:(SEL) sel; +(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 @end

+ 16
- 1
tweak/assets/TFHelper.m View File

}]; }];
} }
@end
+(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

Loading…
Cancel
Save