1
0
mirror of https://github.com/lint/TFDidThatSay synced 2025-07-01 23:46:47 +00:00

Style and prefs loading improvements

This commit is contained in:
lint
2020-06-02 16:37:49 -04:00
parent 942ec27c11
commit a7b11813d0
18 changed files with 915 additions and 1025 deletions

View File

@ -29,7 +29,7 @@
@end @end
@interface CommentsViewController @interface CommentsViewController
-(void) respondToStyleChange; - (void)respondToStyleChange;
@end @end
@interface CommentPostHeaderNode @interface CommentPostHeaderNode
@ -47,15 +47,15 @@
@property(assign, nonatomic) BOOL isPostHeader; @property(assign, nonatomic) BOOL isPostHeader;
@property(strong, nonatomic) id delegate; @property(strong, nonatomic) id delegate;
@property(strong, nonatomic) id node; @property(strong, nonatomic) id node;
-(void) addButton:(id) arg1; - (void)addButton:(id)arg1;
@end @end
/* -- Other Interfaces -- */ /* -- Other Interfaces -- */
@interface MarkupEngine @interface MarkupEngine
+(id) markDownHTML:(id) arg1 forSubreddit:(id) arg2; + (id)markDownHTML:(id)arg1 forSubreddit:(id)arg2;
@end @end
@interface Resources @interface Resources
+(BOOL) isNight; + (BOOL)isNight;
@end @end

View File

@ -3,6 +3,7 @@
#import "assets/TFHelper.h" #import "assets/TFHelper.h"
#import "assets/MMMarkdown/MMMarkdown.h" #import "assets/MMMarkdown/MMMarkdown.h"
static BOOL isEnabled;
static BOOL isAlienBlueEnabled; static BOOL isAlienBlueEnabled;
static BOOL isTFDeletedOnly; static BOOL isTFDeletedOnly;
static CGFloat pushshiftRequestTimeoutValue; static CGFloat pushshiftRequestTimeoutValue;
@ -11,7 +12,7 @@ static CGFloat pushshiftRequestTimeoutValue;
%hook CommentOptionsDrawerView %hook CommentOptionsDrawerView
-(id) initWithNode:(id) arg1 { - (id)initWithNode:(id)arg1 {
id orig = %orig; id orig = %orig;
NSString *body; NSString *body;
@ -51,7 +52,7 @@ static CGFloat pushshiftRequestTimeoutValue;
} }
%new %new
-(void) didTapCommentUndeleteButton:(id) sender { - (void)didTapCommentUndeleteButton:(id)sender {
[sender setEnabled:NO]; [sender setEnabled:NO];
@ -61,7 +62,7 @@ static CGFloat pushshiftRequestTimeoutValue;
} }
%new %new
-(void) completeUndeleteCommentAction:(NSDictionary *) data{ - (void)completeUndeleteCommentAction:(NSDictionary *)data {
id comment = [[self node] comment]; id comment = [[self node] comment];
@ -79,7 +80,7 @@ static CGFloat pushshiftRequestTimeoutValue;
} }
%new %new
-(void) didTapPostUndeleteButton:(id) sender { - (void)didTapPostUndeleteButton:(id)sender {
[sender setEnabled:NO]; [sender setEnabled:NO];
@ -89,7 +90,7 @@ static CGFloat pushshiftRequestTimeoutValue;
} }
%new %new
-(void) completeUndeletePostAction:(NSDictionary *) data{ - (void)completeUndeletePostAction:(NSDictionary *)data {
id post = [[self node] post]; id post = [[self node] post];
id postComment = [[self node] comment]; //Don't know why he used a comment to store info about a post, but it exists id postComment = [[self node] comment]; //Don't know why he used a comment to store info about a post, but it exists
@ -116,26 +117,12 @@ static void loadPrefs(){
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"]; NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
if (prefs){ if (prefs){
isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES;
if ([prefs objectForKey:@"isAlienBlueEnabled"] != nil){ isAlienBlueEnabled = [prefs objectForKey:@"isAlienBlueEnabled"] ? [[prefs objectForKey:@"isAlienBlueEnabled"] boolValue] : YES;
isAlienBlueEnabled = [[prefs objectForKey:@"isAlienBlueEnabled"] boolValue]; isTFDeletedOnly = [prefs objectForKey:@"isTFDeletedOnly"] ? [[prefs objectForKey:@"isTFDeletedOnly"] boolValue] : YES;
} else { pushshiftRequestTimeoutValue = [prefs objectForKey:@"requestTimeoutValue"] ? [[prefs objectForKey:@"requestTimeoutValue"] doubleValue] : 10;
isAlienBlueEnabled = YES;
}
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil){
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
} else {
isTFDeletedOnly = YES;
}
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
} else {
pushshiftRequestTimeoutValue = 10;
}
} else { } else {
isEnabled = YES;
isAlienBlueEnabled = YES; isAlienBlueEnabled = YES;
isTFDeletedOnly = YES; isTFDeletedOnly = YES;
pushshiftRequestTimeoutValue = 10; pushshiftRequestTimeoutValue = 10;
@ -153,9 +140,9 @@ static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStrin
NSString* processName = [[NSProcessInfo processInfo] processName]; NSString* processName = [[NSProcessInfo processInfo] processName];
if ([processName isEqualToString:@"AlienBlue"]){ if ([processName isEqualToString:@"AlienBlue"]){
if (isAlienBlueEnabled){ if (isAlienBlueEnabled && isEnabled){
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
%init(AlienBlue); %init(AlienBlue);
} }

View File

@ -18,24 +18,24 @@
@interface RCCommentCell : NSObject @interface RCCommentCell : NSObject
@property(strong, nonatomic) id comment; @property(strong, nonatomic) id comment;
-(void) updateWithModelObject:(id) arg1; - (void)updateWithModelObject:(id)arg1;
@end @end
@interface RCPostCommentsController @interface RCPostCommentsController
@property(strong, nonatomic) id postCommentsCollector; @property(strong, nonatomic) id postCommentsCollector;
@property(strong, nonatomic) id delegate; @property(strong, nonatomic) id delegate;
@property(strong, nonatomic) NSMutableDictionary *commentHeightCache; @property(strong, nonatomic) NSMutableDictionary *commentHeightCache;
-(void) controllerWillChangeContent:(id) arg1; - (void)controllerWillChangeContent:(id)arg1;
-(void) controllerDidChangeContent:(id) arg1; - (void)controllerDidChangeContent:(id)arg1;
-(void) controller:(id) arg1 didChange:(id) arg2 at:(id) arg3 for:(long long) arg4 newIndexPath:(id) arg5; - (void)controller:(id)arg1 didChange:(id)arg2 at:(id)arg3 for:(long long)arg4 newIndexPath:(id)arg5;
//custom elements //custom elements
-(void)handleUndeleteCommentAction; - (void)handleUndeleteCommentAction;
@end @end
@interface AHKActionSheet @interface AHKActionSheet
@property(strong, nonatomic) NSMutableArray *items; @property(strong, nonatomic) NSMutableArray *items;
-(void) addButtonWithTitle:(id) arg1 image:(id) arg2 type:(long long) arg3 handler:(id) arg4; - (void)addButtonWithTitle:(id)arg1 image:(id)arg2 type:(long long)arg3 handler:(id)arg4;
@end @end
@interface AHKActionSheetItem @interface AHKActionSheetItem
@ -49,7 +49,7 @@
@property(strong, nonatomic) NSNumber *isSelf; @property(strong, nonatomic) NSNumber *isSelf;
@property(strong, nonatomic) NSString *itemId; @property(strong, nonatomic) NSString *itemId;
@property(strong, nonatomic) id selfCommentText; @property(strong, nonatomic) id selfCommentText;
-(BOOL) isSelfPost; - (BOOL)isSelfPost;
@end @end
@interface RCPostActionsSectionHeader : UIView @interface RCPostActionsSectionHeader : UIView
@ -73,8 +73,8 @@
@interface RCPostHeaderCellController : NSObject @interface RCPostHeaderCellController : NSObject
@property(strong, nonatomic) id post; @property(strong, nonatomic) id post;
@property(strong, nonatomic) UITableView *tableView; @property(strong, nonatomic) UITableView *tableView;
-(void) loadView; - (void)loadView;
//custom elements //custom elements
-(void) handleUndeletePostAction:(id) arg1; - (void)handleUndeletePostAction:(id)arg1;
@end @end

View File

@ -3,6 +3,7 @@
#import "assets/TFHelper.h" #import "assets/TFHelper.h"
#import "assets/MMMarkdown/MMMarkdown.h" #import "assets/MMMarkdown/MMMarkdown.h"
static BOOL isEnabled;
static BOOL isAntennaEnabled; static BOOL isAntennaEnabled;
static BOOL isTFDeletedOnly; static BOOL isTFDeletedOnly;
static CGFloat pushshiftRequestTimeoutValue; static CGFloat pushshiftRequestTimeoutValue;
@ -22,7 +23,7 @@ id tfAntennaCommentCell;
%hook RCCommentSwift %hook RCCommentSwift
-(BOOL) isCommentDeleted{ - (BOOL)isCommentDeleted{
return NO; return NO;
} }
@ -31,7 +32,7 @@ id tfAntennaCommentCell;
%hook RCPostCommentsController %hook RCPostCommentsController
-(void) didLongPressCell:(id) arg1 gesture:(id) arg2 { - (void)didLongPressCell:(id)arg1 gesture:(id)arg2 {
NSString *commentBody = [[[arg1 comment] commentText] body]; NSString *commentBody = [[[arg1 comment] commentText] body];
@ -47,13 +48,13 @@ id tfAntennaCommentCell;
} }
%new %new
-(void) handleUndeleteCommentAction{ - (void)handleUndeleteCommentAction{
[%c(TFHelper) getUndeleteDataWithID:[[tfAntennaCommentCell comment] itemId] isComment:YES timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeleteCommentAction:)]; [%c(TFHelper) getUndeleteDataWithID:[[tfAntennaCommentCell comment] itemId] isComment:YES timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeleteCommentAction:)];
} }
%new %new
-(void) completeUndeleteCommentAction:(NSDictionary *) data{ - (void)completeUndeleteCommentAction:(NSDictionary *)data {
id comment = [tfAntennaCommentCell comment]; id comment = [tfAntennaCommentCell comment];
id commentText = [comment commentText]; id commentText = [comment commentText];
@ -78,9 +79,9 @@ id tfAntennaCommentCell;
%hook AHKActionSheet %hook AHKActionSheet
-(void)show{ - (void)show {
if (shouldHaveAntennaUndeleteAction){ if (shouldHaveAntennaUndeleteAction) {
UIImage *undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"]; UIImage *undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
@ -107,7 +108,7 @@ id tfAntennaCommentCell;
%hook RCPostActionsSectionHeader %hook RCPostActionsSectionHeader
%property(strong, nonatomic) UIButton *undeleteButton; %property(strong, nonatomic) UIButton *undeleteButton;
-(void) layoutSubviews{ - (void)layoutSubviews {
BOOL isAbleToUndeletePost = NO; BOOL isAbleToUndeletePost = NO;
@ -155,7 +156,7 @@ id tfAntennaCommentCell;
%hook RCPostHeaderCellController %hook RCPostHeaderCellController
%new %new
-(void) handleUndeletePostAction:(id) sender{ - (void)handleUndeletePostAction:(id)sender {
[sender setEnabled:NO]; [sender setEnabled:NO];
@ -163,7 +164,7 @@ id tfAntennaCommentCell;
} }
%new %new
-(void) completeUndeletePostAction:(NSDictionary *) data{ - (void)completeUndeletePostAction:(NSDictionary *)data {
id post = [self post]; id post = [self post];
id postText = [post selfCommentText]; id postText = [post selfCommentText];
@ -193,26 +194,12 @@ static void loadPrefs(){
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"]; NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
if (prefs){ if (prefs){
isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES;
if ([prefs objectForKey:@"isAntennaEnabled"] != nil){ isAntennaEnabled = [prefs objectForKey:@"isAntennaEnabled"] ? [[prefs objectForKey:@"isAntennaEnabled"] boolValue] : YES;
isAntennaEnabled = [[prefs objectForKey:@"isAntennaEnabled"] boolValue]; isTFDeletedOnly = [prefs objectForKey:@"isTFDeletedOnly"] ? [[prefs objectForKey:@"isTFDeletedOnly"] boolValue] : YES;
} else { pushshiftRequestTimeoutValue = [prefs objectForKey:@"requestTimeoutValue"] ? [[prefs objectForKey:@"requestTimeoutValue"] doubleValue] : 10;
isAntennaEnabled = YES;
}
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil){
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
} else {
isTFDeletedOnly = YES;
}
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
} else {
pushshiftRequestTimeoutValue = 10;
}
} else { } else {
isEnabled = YES;
isAntennaEnabled = YES; isAntennaEnabled = YES;
isTFDeletedOnly = YES; isTFDeletedOnly = YES;
pushshiftRequestTimeoutValue = 10; pushshiftRequestTimeoutValue = 10;
@ -230,9 +217,9 @@ static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStrin
NSString* processName = [[NSProcessInfo processInfo] processName]; NSString* processName = [[NSProcessInfo processInfo] processName];
if ([processName isEqualToString:@"amrc"]){ if ([processName isEqualToString:@"amrc"]){
if (isAntennaEnabled){ if (isAntennaEnabled && isEnabled){
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
%init(Antenna, RCCommentSwift = objc_getClass("amrc.RCCommentSwift"), RCPostSwift = objc_getClass("amrc.RCPostSwift"), RCCommentTextSwift = objc_getClass("amrc.RCCommentTextSwift")); %init(Antenna, RCCommentSwift = objc_getClass("amrc.RCCommentSwift"), RCPostSwift = objc_getClass("amrc.RCPostSwift"), RCCommentTextSwift = objc_getClass("amrc.RCCommentTextSwift"));
} }

View File

@ -17,14 +17,14 @@
@interface CommentCellNode @interface CommentCellNode
@property(assign,nonatomic)id view; @property(assign,nonatomic)id view;
-(BOOL) isSelected; - (BOOL)isSelected;
-(void) _layoutSublayouts; - (void)_layoutSublayouts;
-(void) didLoad; - (void)didLoad;
-(void) calculatedLayoutDidChange; - (void)calculatedLayoutDidChange;
//custom elements //custom elements
@property(strong,nonatomic) UIButton *undeleteButton; @property(strong,nonatomic) UIButton *undeleteButton;
-(void) undeleteCellWasSelected; - (void)undeleteCellWasSelected;
@end @end
/* -- Post Interfaces -- */ /* -- Post Interfaces -- */
@ -33,7 +33,7 @@
@property(assign,nonatomic) NSString *selfText; @property(assign,nonatomic) NSString *selfText;
@property(assign,nonatomic) NSString *author; @property(assign,nonatomic) NSString *author;
@property(assign,nonatomic) NSString *fullName; @property(assign,nonatomic) NSString *fullName;
-(BOOL) isSelfPost; - (BOOL)isSelfPost;
//custom elements //custom elements
@property(strong, nonatomic) NSString *undeleteAuthor; @property(strong, nonatomic) NSString *undeleteAuthor;
@ -43,7 +43,7 @@
@property(assign,nonatomic) NSString *selfText; @property(assign,nonatomic) NSString *selfText;
@property(assign,nonatomic) NSString *author; @property(assign,nonatomic) NSString *author;
@property(assign,nonatomic) NSString *fullName; @property(assign,nonatomic) NSString *fullName;
-(BOOL) isSelfPost; - (BOOL)isSelfPost;
//custom elements //custom elements
@property(strong, nonatomic) NSString *undeleteAuthor; @property(strong, nonatomic) NSString *undeleteAuthor;
@ -58,18 +58,18 @@
//custom elements //custom elements
@property(strong, nonatomic) id headerCellNode; @property(strong, nonatomic) id headerCellNode;
-(void) undeleteCellWasSelected; - (void)undeleteCellWasSelected;
@end @end
/* -- Other Interfaces -- */ /* -- Other Interfaces -- */
@interface MarkdownRenderer @interface MarkdownRenderer
+(id) attributedStringFromMarkdown:(id) arg1 withAttributes:(id) arg2; + (id)attributedStringFromMarkdown:(id)arg1 withAttributes:(id)arg2;
@end @end
@interface ActionController @interface ActionController
-(id) tableView:(id) arg1 cellForRowAtIndexPath:(NSIndexPath *)arg2; - (id)tableView:(id)arg1 cellForRowAtIndexPath:(NSIndexPath *)arg2;
-(NSInteger) tableView:(id) arg1 numberOfRowsInSection:(NSInteger) arg2; - (NSInteger)tableView:(id)arg1 numberOfRowsInSection:(NSInteger)arg2;
@end @end
@interface UIImage (ios13) @interface UIImage (ios13)
@ -88,7 +88,7 @@
@property(assign,nonatomic)id image; @property(assign,nonatomic)id image;
@property(assign,nonatomic) CGRect frame; @property(assign,nonatomic) CGRect frame;
@property(assign,nonatomic) id view; @property(assign,nonatomic) id view;
-(CGRect)_frameInWindow; - (CGRect)_frameInWindow;
@end @end
@interface ASTextNode @interface ASTextNode
@ -99,6 +99,6 @@
@interface ApolloButtonNode @interface ApolloButtonNode
@property(assign,nonatomic) ASTextNode *titleNode; @property(assign,nonatomic) ASTextNode *titleNode;
-(void) setAttributedTitle:(id) arg1 forState:(NSInteger) arg2; - (void) setAttributedTitle:(id)arg1 forState:(NSInteger)arg2;
-(id) attributedTitleForState:(NSInteger) arg1; - (id) attributedTitleForState:(NSInteger)arg1;
@end @end

View File

@ -2,8 +2,9 @@
#import "Apollo.h" #import "Apollo.h"
#import "assets/TFHelper.h" #import "assets/TFHelper.h"
static BOOL isTFDeletedOnly; static BOOL isEnabled;
static BOOL isApolloEnabled; static BOOL isApolloEnabled;
static BOOL isTFDeletedOnly;
static CGFloat pushshiftRequestTimeoutValue; static CGFloat pushshiftRequestTimeoutValue;
static BOOL shouldApolloHaveButton; static BOOL shouldApolloHaveButton;
@ -69,7 +70,7 @@ id apolloCommentController;
%hook MarkdownRenderer %hook MarkdownRenderer
+(id) attributedStringFromHTML:(id)arg1 attributes:(id) arg2 compact:(BOOL) arg3{ + (id)attributedStringFromHTML:(id)arg1 attributes:(id)arg2 compact:(BOOL)arg3 {
apolloBodyAttributes = [arg2 copy]; apolloBodyAttributes = [arg2 copy];
@ -81,9 +82,9 @@ id apolloCommentController;
%hook ActionController %hook ActionController
-(id) tableView:(id) arg1 cellForRowAtIndexPath:(NSIndexPath *) arg2{ - (id) tableView:(id)arg1 cellForRowAtIndexPath:(NSIndexPath *)arg2 {
if (shouldAddUndeleteCell){ if (shouldAddUndeleteCell) {
if ([arg2 row] == [self tableView:arg1 numberOfRowsInSection:0] - 1){ if ([arg2 row] == [self tableView:arg1 numberOfRowsInSection:0] - 1){
id undeleteCell = [arg1 dequeueReusableCellWithIdentifier:@"IconActionCell" forIndexPath:arg2]; id undeleteCell = [arg1 dequeueReusableCellWithIdentifier:@"IconActionCell" forIndexPath:arg2];
@ -94,12 +95,20 @@ id apolloCommentController;
UIImage *undeleteImage; UIImage *undeleteImage;
if (@available(iOS 13.0, *)){ //if (@available(iOS 13.0, *)){
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"13.0")) {
undeleteImage = [UIImage systemImageNamed:@"eye"]; undeleteImage = [UIImage systemImageNamed:@"eye"];
if (!undeleteImage){ if (!undeleteImage){
undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"]; undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
} else {
CGSize squareSize = CGSizeMake(undeleteImage.size.width, undeleteImage.size.width);
UIGraphicsBeginImageContextWithOptions(squareSize, NO, 0);
[undeleteImage drawInRect:CGRectMake(0, (squareSize.height - undeleteImage.size.height) / 2, squareSize.width, undeleteImage.size.height)];
undeleteImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
} }
} else { } else {
undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"]; undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
@ -107,7 +116,7 @@ id apolloCommentController;
CGFloat undeleteImageSizeValue = prevImageSize.width > prevImageSize.height ? prevImageSize.width : prevImageSize.height; CGFloat undeleteImageSizeValue = prevImageSize.width > prevImageSize.height ? prevImageSize.width : prevImageSize.height;
if (undeleteImageSizeValue == 0){ if (undeleteImageSizeValue == 0) {
undeleteImageSizeValue = 25; undeleteImageSizeValue = 25;
} }
@ -129,12 +138,12 @@ id apolloCommentController;
return %orig; return %orig;
} }
-(void) tableView:(id) arg1 didSelectRowAtIndexPath:(NSIndexPath *)arg2{ - (void)tableView:(id)arg1 didSelectRowAtIndexPath:(NSIndexPath *)arg2 {
if (shouldAddUndeleteCell){ if (shouldAddUndeleteCell) {
if ([arg2 row] == [self tableView:arg1 numberOfRowsInSection:0] - 1){ if ([arg2 row] == [self tableView:arg1 numberOfRowsInSection:0] - 1){
if (apolloCommentCell){ if (apolloCommentCell) {
[apolloCommentCell undeleteCellWasSelected]; [apolloCommentCell undeleteCellWasSelected];
} else { } else {
[apolloCommentController undeleteCellWasSelected]; [apolloCommentController undeleteCellWasSelected];
@ -145,7 +154,7 @@ id apolloCommentController;
%orig; %orig;
} }
-(NSInteger) tableView:(id) arg1 numberOfRowsInSection:(NSInteger) arg2{ - (NSInteger) tableView:(id)arg1 numberOfRowsInSection:(NSInteger)arg2 {
if (shouldAddUndeleteCell){ if (shouldAddUndeleteCell){
return %orig + 1; return %orig + 1;
@ -154,7 +163,7 @@ id apolloCommentController;
} }
} }
-(id) animationControllerForDismissedController:(id) arg1{ - (id) animationControllerForDismissedController:(id)arg1 {
shouldAddUndeleteCell = NO; shouldAddUndeleteCell = NO;
@ -167,7 +176,7 @@ id apolloCommentController;
%hook CommentCellNode %hook CommentCellNode
%property(strong,nonatomic) UIButton *undeleteButton; %property(strong,nonatomic) UIButton *undeleteButton;
-(void) moreOptionsTappedWithSender:(id) arg1{ - (void)moreOptionsTappedWithSender:(id)arg1 {
if (!shouldApolloHaveButton){ if (!shouldApolloHaveButton){
@ -183,7 +192,7 @@ id apolloCommentController;
%orig; %orig;
} }
-(void) longPressedWithGestureRecognizer:(id) arg1{ - (void)longPressedWithGestureRecognizer:(id)arg1 {
if (!shouldApolloHaveButton){ if (!shouldApolloHaveButton){
@ -199,7 +208,7 @@ id apolloCommentController;
%orig; %orig;
} }
-(void) didLoad { - (void)didLoad {
%orig; %orig;
if (shouldApolloHaveButton){ if (shouldApolloHaveButton){
@ -223,7 +232,7 @@ id apolloCommentController;
} }
} }
-(void) _layoutSublayouts{ - (void)_layoutSublayouts {
%orig; %orig;
if (shouldApolloHaveButton){ if (shouldApolloHaveButton){
@ -244,7 +253,7 @@ id apolloCommentController;
} }
%new %new
-(void) didTapUndeleteButton:(id) sender{ - (void)didTapUndeleteButton:(id)sender {
[sender setEnabled:NO]; [sender setEnabled:NO];
@ -254,7 +263,7 @@ id apolloCommentController;
} }
%new %new
-(void) undeleteCellWasSelected{ - (void)undeleteCellWasSelected {
RKComment *comment = MSHookIvar<RKComment *>(self, "comment"); RKComment *comment = MSHookIvar<RKComment *>(self, "comment");
@ -262,7 +271,7 @@ id apolloCommentController;
} }
%new %new
-(void) completeUndeleteCommentAction:(NSDictionary *) data{ - (void)completeUndeleteCommentAction:(NSDictionary *)data {
RKComment *comment = MSHookIvar<RKComment *>(self, "comment"); RKComment *comment = MSHookIvar<RKComment *>(self, "comment");
id bodyNode = MSHookIvar<id>(self, "bodyNode"); id bodyNode = MSHookIvar<id>(self, "bodyNode");
@ -292,7 +301,7 @@ id apolloCommentController;
%hook CommentsViewController %hook CommentsViewController
%property(strong, nonatomic) id headerCellNode; %property(strong, nonatomic) id headerCellNode;
-(void) moreOptionsBarButtonItemTappedWithSender:(id) arg1{ - (void)moreOptionsBarButtonItemTappedWithSender:(id)arg1 {
RKLink *post = MSHookIvar<RKLink *>(self, "link"); RKLink *post = MSHookIvar<RKLink *>(self, "link");
NSString *postBody = [post selfText]; NSString *postBody = [post selfText];
@ -309,7 +318,7 @@ id apolloCommentController;
} }
%new %new
-(void) undeleteCellWasSelected{ - (void)undeleteCellWasSelected {
RKLink *post = MSHookIvar<RKLink *>(self, "link"); RKLink *post = MSHookIvar<RKLink *>(self, "link");
@ -317,7 +326,7 @@ id apolloCommentController;
} }
%new %new
-(void) completeUndeletePostAction:(NSDictionary *) data{ - (void)completeUndeletePostAction:(NSDictionary *)data {
RKLink *post = MSHookIvar<RKLink *>(self, "link"); RKLink *post = MSHookIvar<RKLink *>(self, "link");
@ -346,24 +355,24 @@ id apolloCommentController;
%hook CommentsHeaderCellNode %hook CommentsHeaderCellNode
-(void) didLoad{ - (void)didLoad {
%orig; %orig;
[[self closestViewController] setHeaderCellNode:self]; [[self closestViewController] setHeaderCellNode:self];
} }
-(void) _layoutSublayouts{ - (void)_layoutSublayouts {
%orig; %orig;
[[self closestViewController] setHeaderCellNode:self]; [[self closestViewController] setHeaderCellNode:self];
} }
-(void) longPressedWithGestureRecognizer:(id) arg1{ - (void)longPressedWithGestureRecognizer:(id)arg1 {
RKLink *post = MSHookIvar<RKLink *>(self, "link"); RKLink *post = MSHookIvar<RKLink *>(self, "link");
NSString *postBody = [post selfText]; NSString *postBody = [post selfText];
if ([post isSelfPost]){ if ([post isSelfPost]) {
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){ if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
shouldAddUndeleteCell = YES; shouldAddUndeleteCell = YES;
apolloCommentCell = nil; apolloCommentCell = nil;
@ -383,32 +392,13 @@ static void loadPrefs(){
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"]; NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
if (prefs){ if (prefs){
isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES;
if ([prefs objectForKey:@"isApolloEnabled"] != nil) { isApolloEnabled = [prefs objectForKey:@"isApolloEnabled"] ? [[prefs objectForKey:@"isApolloEnabled"] boolValue] : YES;
isApolloEnabled = [[prefs objectForKey:@"isApolloEnabled"] boolValue]; isTFDeletedOnly = [prefs objectForKey:@"isTFDeletedOnly"] ? [[prefs objectForKey:@"isTFDeletedOnly"] boolValue] : YES;
} else { pushshiftRequestTimeoutValue = [prefs objectForKey:@"requestTimeoutValue"] ? [[prefs objectForKey:@"requestTimeoutValue"] doubleValue] : 10;
isApolloEnabled = YES; shouldApolloHaveButton = [prefs objectForKey:@"shouldApolloHaveButton"] ? [[prefs objectForKey:@"shouldApolloHaveButton"] boolValue] : NO;
}
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil) {
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
} else {
isTFDeletedOnly = YES;
}
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
} else {
pushshiftRequestTimeoutValue = 10;
}
if ([prefs objectForKey:@"shouldApolloHaveButton"] != nil){
shouldApolloHaveButton = [[prefs objectForKey:@"shouldApolloHaveButton"] boolValue];
} else {
shouldApolloHaveButton = NO;
}
} else { } else {
isEnabled = YES;
isApolloEnabled = YES; isApolloEnabled = YES;
isTFDeletedOnly = YES; isTFDeletedOnly = YES;
pushshiftRequestTimeoutValue = 10; pushshiftRequestTimeoutValue = 10;
@ -427,9 +417,9 @@ static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStrin
NSString* processName = [[NSProcessInfo processInfo] processName]; NSString* processName = [[NSProcessInfo processInfo] processName];
if ([processName isEqualToString:@"Apollo"]){ if ([processName isEqualToString:@"Apollo"]){
if (isApolloEnabled){ if (isApolloEnabled && isEnabled){
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
%init(Apollo, CommentsHeaderCellNode = objc_getClass("Apollo.CommentsHeaderCellNode"), CommentCellNode = objc_getClass("Apollo.CommentCellNode"), ApolloButtonNode = objc_getClass("Apollo.ApolloButtonNode"), ActionController = objc_getClass("Apollo.ActionController"), IconActionTableViewCell = objc_getClass("Apollo.IconActionTableViewCell"), CommentsViewController = objc_getClass("Apollo.CommentsViewController")); %init(Apollo, CommentsHeaderCellNode = objc_getClass("Apollo.CommentsHeaderCellNode"), CommentCellNode = objc_getClass("Apollo.CommentCellNode"), ApolloButtonNode = objc_getClass("Apollo.ApolloButtonNode"), ActionController = objc_getClass("Apollo.ActionController"), IconActionTableViewCell = objc_getClass("Apollo.IconActionTableViewCell"), CommentsViewController = objc_getClass("Apollo.CommentsViewController"));
} }

View File

@ -39,7 +39,7 @@
@interface StoryDetailView @interface StoryDetailView
@property(strong, nonatomic) UITableView *tableView; @property(strong, nonatomic) UITableView *tableView;
-(void) refreshTouched; - (void)refreshTouched;
@end @end
@interface StoryDetailViewController @interface StoryDetailViewController
@ -47,13 +47,13 @@
@property(strong, nonatomic) id detailPage; @property(strong, nonatomic) id detailPage;
//custom elements //custom elements
-(void) handleUndeleteCommentAction; - (void)handleUndeleteCommentAction;
-(void) handleUndeletePostAction; - (void)handleUndeletePostAction;
@end @end
/* -- Other Interfaces -- */ /* -- Other Interfaces -- */
@interface BRUtils @interface BRUtils
+(id) attributedDescriptionForComment:(id) arg1; + (id)attributedDescriptionForComment:(id)arg1;
+(id) createAttributedStringFromHTML:(id) arg1 options:(id) arg2; + (id)createAttributedStringFromHTML:(id)arg1 options:(id)arg2;
@end @end

View File

@ -3,6 +3,7 @@
#import "assets/TFHelper.h" #import "assets/TFHelper.h"
#import "assets/MMMarkdown/MMMarkdown.h" #import "assets/MMMarkdown/MMMarkdown.h"
static BOOL isEnabled;
static BOOL isBaconReaderEnabled; static BOOL isBaconReaderEnabled;
static BOOL isTFDeletedOnly; static BOOL isTFDeletedOnly;
static CGFloat pushshiftRequestTimeoutValue; static CGFloat pushshiftRequestTimeoutValue;
@ -28,19 +29,19 @@ id tfStoryController;
%hook BRComment %hook BRComment
-(BOOL) contains_htmlValue{ - (BOOL)contains_htmlValue {
return YES; return YES;
} }
-(BOOL) primitiveContains_htmlValue{ - (BOOL)primitiveContains_htmlValue {
return YES; return YES;
} }
-(BOOL) is_deletedValue{ - (BOOL)is_deletedValue {
return NO; return NO;
} }
-(BOOL) primitiveIs_deletedValue{ - (BOOL)primitiveIs_deletedValue {
return NO; return NO;
} }
@ -49,10 +50,10 @@ id tfStoryController;
%hook BRStory %hook BRStory
+(id) storyWithDictionary:(id) arg1 inContext:(id) arg2 { + (id)storyWithDictionary:(id)arg1 inContext:(id)arg2 {
id orig = %orig; id orig = %orig;
if (tfPostSelftext){ if (tfPostSelftext) {
[orig setSelftext_html:tfPostSelftext]; [orig setSelftext_html:tfPostSelftext];
[orig setAuthor:tfPostAuthor]; [orig setAuthor:tfPostAuthor];
tfPostSelftext = nil; tfPostSelftext = nil;
@ -67,13 +68,13 @@ id tfStoryController;
%hook UIViewController %hook UIViewController
-(void) presentViewController:(id) arg1 animated:(BOOL) arg2 completion:(id) arg3 { - (void)presentViewController:(id)arg1 animated:(BOOL)arg2 completion:(id)arg3 {
if ([arg1 isKindOfClass:[UIAlertController class]] && shouldHaveBRUndeleteAction){ if ([arg1 isKindOfClass:[UIAlertController class]] && shouldHaveBRUndeleteAction) {
UIAlertAction *undeleteAction; UIAlertAction *undeleteAction;
if (tfCommentCellView){ if (tfCommentCellView) {
undeleteAction = [UIAlertAction actionWithTitle:@"TF Did That Say?" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){[tfStoryController handleUndeleteCommentAction];}]; undeleteAction = [UIAlertAction actionWithTitle:@"TF Did That Say?" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){[tfStoryController handleUndeleteCommentAction];}];
} else { } else {
undeleteAction = [UIAlertAction actionWithTitle:@"TF Did That Say?" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){[tfStoryController handleUndeletePostAction];}]; undeleteAction = [UIAlertAction actionWithTitle:@"TF Did That Say?" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){[tfStoryController handleUndeletePostAction];}];
@ -90,11 +91,11 @@ id tfStoryController;
%hook StoryDetailViewController %hook StoryDetailViewController
-(void) showMoreCommentActions:(id) arg1 showAll:(BOOL) arg2 { - (void)showMoreCommentActions:(id)arg1 showAll:(BOOL)arg2 {
NSString *commentBody = [[arg1 comment] body]; NSString *commentBody = [[arg1 comment] body];
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){ if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]) {
shouldHaveBRUndeleteAction = YES; shouldHaveBRUndeleteAction = YES;
tfCommentCellView = arg1; tfCommentCellView = arg1;
tfStoryController = self; tfStoryController = self;
@ -106,12 +107,12 @@ id tfStoryController;
shouldHaveBRUndeleteAction = NO; shouldHaveBRUndeleteAction = NO;
} }
-(void) menuTouchedWithSender:(id) arg1 { - (void)menuTouchedWithSender:(id)arg1 {
if ([[self story] is_selfValue]){ if ([[self story] is_selfValue]) {
NSString *postBody = [[self story] selftext]; NSString *postBody = [[self story] selftext];
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){ if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]) {
shouldHaveBRUndeleteAction = YES; shouldHaveBRUndeleteAction = YES;
tfCommentCellView = nil; tfCommentCellView = nil;
tfStoryController = self; tfStoryController = self;
@ -125,13 +126,13 @@ id tfStoryController;
} }
%new %new
-(void) handleUndeleteCommentAction{ - (void)handleUndeleteCommentAction {
[%c(TFHelper) getUndeleteDataWithID:[[tfCommentCellView comment] serverID] isComment:YES timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeleteCommentAction:)]; [%c(TFHelper) getUndeleteDataWithID:[[tfCommentCellView comment] serverID] isComment:YES timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeleteCommentAction:)];
} }
%new %new
-(void) completeUndeleteCommentAction:(NSDictionary *) data{ - (void)completeUndeleteCommentAction:(NSDictionary *)data {
id comment = [tfCommentCellView comment]; id comment = [tfCommentCellView comment];
@ -149,13 +150,13 @@ id tfStoryController;
} }
%new %new
-(void) handleUndeletePostAction{ - (void)handleUndeletePostAction {
[%c(TFHelper) getUndeleteDataWithID:[[self story] serverID] isComment:NO timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeletePostAction:)]; [%c(TFHelper) getUndeleteDataWithID:[[self story] serverID] isComment:NO timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeletePostAction:)];
} }
%new %new
-(void) completeUndeletePostAction:(NSDictionary *) data{ - (void)completeUndeletePostAction:(NSDictionary *)data {
tfPostAuthor = data[@"author"]; tfPostAuthor = data[@"author"];
tfPostSelftext = [%c(MMMarkdown) HTMLStringWithMarkdown:data[@"body"] extensions:MMMarkdownExtensionsGitHubFlavored error:nil]; tfPostSelftext = [%c(MMMarkdown) HTMLStringWithMarkdown:data[@"body"] extensions:MMMarkdownExtensionsGitHubFlavored error:nil];
@ -172,26 +173,12 @@ static void loadPrefs(){
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"]; NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
if (prefs){ if (prefs){
isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES;
if ([prefs objectForKey:@"isBaconReaderEnabled"] != nil){ isBaconReaderEnabled = [prefs objectForKey:@"isBaconReaderEnabled"] ? [[prefs objectForKey:@"isBaconReaderEnabled"] boolValue] : YES;
isBaconReaderEnabled = [[prefs objectForKey:@"isBaconReaderEnabled"] boolValue]; isTFDeletedOnly = [prefs objectForKey:@"isTFDeletedOnly"] ? [[prefs objectForKey:@"isTFDeletedOnly"] boolValue] : YES;
} else { pushshiftRequestTimeoutValue = [prefs objectForKey:@"requestTimeoutValue"] ? [[prefs objectForKey:@"requestTimeoutValue"] doubleValue] : 10;
isBaconReaderEnabled = YES;
}
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil) {
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
} else {
isTFDeletedOnly = YES;
}
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
} else {
pushshiftRequestTimeoutValue = 10;
}
} else { } else {
isEnabled = YES;
isBaconReaderEnabled = YES; isBaconReaderEnabled = YES;
isTFDeletedOnly = YES; isTFDeletedOnly = YES;
pushshiftRequestTimeoutValue = 10; pushshiftRequestTimeoutValue = 10;
@ -209,9 +196,9 @@ static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStrin
NSString* processName = [[NSProcessInfo processInfo] processName]; NSString* processName = [[NSProcessInfo processInfo] processName];
if ([processName isEqualToString:@"BaconReader"]){ if ([processName isEqualToString:@"BaconReader"]){
if (isBaconReaderEnabled){ if (isBaconReaderEnabled && isEnabled){
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
%init(BaconReader, StoryDetailView = objc_getClass("BaconReader.StoryDetailView"), StoryDetailViewController = objc_getClass("BaconReader.StoryDetailViewController"), CommentCellView = objc_getClass("BaconReader.CommentCellView"), CommentCell = objc_getClass("BaconReader.CommentCell")); %init(BaconReader, StoryDetailView = objc_getClass("BaconReader.StoryDetailView"), StoryDetailViewController = objc_getClass("BaconReader.StoryDetailViewController"), CommentCellView = objc_getClass("BaconReader.CommentCellView"), CommentCell = objc_getClass("BaconReader.CommentCell"));
} }

View File

@ -14,7 +14,7 @@
@property(strong, nonatomic) id authorButton; @property(strong, nonatomic) id authorButton;
@property(assign, nonatomic) BOOL isCollapsed; @property(assign, nonatomic) BOOL isCollapsed;
@property(assign, nonatomic) BOOL commentDidChange; @property(assign, nonatomic) BOOL commentDidChange;
-(void) reloadContents; - (void)reloadContents;
//custom elements //custom elements
@property(strong, nonatomic) UIButton *undeleteButton; @property(strong, nonatomic) UIButton *undeleteButton;
@ -48,7 +48,7 @@
@end @end
@interface PostSelfTextPartCell @interface PostSelfTextPartCell
-(id) _viewControllerForAncestor; - (id)_viewControllerForAncestor;
@end @end
@interface PostMetadataView @interface PostMetadataView

View File

@ -2,6 +2,7 @@
#import "Beam.h" #import "Beam.h"
#import "assets/TFHelper.h" #import "assets/TFHelper.h"
static BOOL isEnabled;
static BOOL isBeamEnabled; static BOOL isBeamEnabled;
static BOOL isTFDeletedOnly; static BOOL isTFDeletedOnly;
static CGFloat pushshiftRequestTimeoutValue; static CGFloat pushshiftRequestTimeoutValue;
@ -11,13 +12,13 @@ static CGFloat pushshiftRequestTimeoutValue;
%hook CommentCell %hook CommentCell
%property(strong, nonatomic) UIButton *undeleteButton; %property(strong, nonatomic) UIButton *undeleteButton;
-(void) layoutSubviews{ - (void)layoutSubviews {
%orig; %orig;
UIButton *undeleteButton = [self undeleteButton]; UIButton *undeleteButton = [self undeleteButton];
if (undeleteButton){ if (undeleteButton) {
if ([self isCollapsed]){ if ([self isCollapsed]) {
[undeleteButton setHidden:YES]; [undeleteButton setHidden:YES];
} else { } else {
[undeleteButton setHidden:NO]; [undeleteButton setHidden:NO];
@ -26,7 +27,7 @@ static CGFloat pushshiftRequestTimeoutValue;
NSString *commentBody = [[self comment] content]; NSString *commentBody = [[self comment] content];
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){ if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]) {
CGFloat authorTextHeight = [[self authorButton] frame].size.height; CGFloat authorTextHeight = [[self authorButton] frame].size.height;
@ -46,7 +47,7 @@ static CGFloat pushshiftRequestTimeoutValue;
} }
%new %new
-(void) handleUndeleteCommentAction:(id) sender{ - (void)handleUndeleteCommentAction:(id)sender {
[sender setEnabled:NO]; [sender setEnabled:NO];
@ -54,7 +55,7 @@ static CGFloat pushshiftRequestTimeoutValue;
} }
%new %new
-(void) completeUndeleteCommentAction:(NSDictionary *) data{ - (void)completeUndeleteCommentAction:(NSDictionary *)data {
id comment = [self comment]; id comment = [self comment];
@ -74,12 +75,12 @@ static CGFloat pushshiftRequestTimeoutValue;
%hook PostSelfTextPartCell %hook PostSelfTextPartCell
-(void) setSelected:(BOOL) arg1 animated:(BOOL) arg2{ - (void)setSelected:(BOOL)arg1 animated:(BOOL)arg2{
%orig; %orig;
id postViewController = [self _viewControllerForAncestor]; id postViewController = [self _viewControllerForAncestor];
if ([postViewController isMemberOfClass:objc_getClass("beam.PostDetailEmbeddedViewController")]){ if ([postViewController isMemberOfClass:objc_getClass("beam.PostDetailEmbeddedViewController")]) {
[postViewController setSelfTextView:self]; [postViewController setSelfTextView:self];
[postViewController setPost:[self post]]; [postViewController setPost:[self post]];
@ -91,12 +92,12 @@ static CGFloat pushshiftRequestTimeoutValue;
%hook PostMetadataView %hook PostMetadataView
-(void) layoutSubviews{ - (void)layoutSubviews {
%orig; %orig;
id postViewController = MSHookIvar<id>(self, "delegate"); id postViewController = MSHookIvar<id>(self, "delegate");
if ([postViewController isMemberOfClass:objc_getClass("beam.PostDetailEmbeddedViewController")]){ if ([postViewController isMemberOfClass:objc_getClass("beam.PostDetailEmbeddedViewController")]) {
[postViewController setMetadataView:self]; [postViewController setMetadataView:self];
} }
} }
@ -107,14 +108,14 @@ static CGFloat pushshiftRequestTimeoutValue;
%hook PostToolbarView %hook PostToolbarView
%property(strong, nonatomic) UIButton *undeleteButton; %property(strong, nonatomic) UIButton *undeleteButton;
-(void) layoutSubviews{ - (void)layoutSubviews {
%orig; %orig;
if (![self undeleteButton] && [[[self post] isSelfText] boolValue] && [MSHookIvar<id>(self, "delegate") isMemberOfClass:objc_getClass("beam.PostDetailEmbeddedViewController")]){ if (![self undeleteButton] && [[[self post] isSelfText] boolValue] && [MSHookIvar<id>(self, "delegate") isMemberOfClass:objc_getClass("beam.PostDetailEmbeddedViewController")]) {
NSString *postBody = [[self post] content]; NSString *postBody = [[self post] content];
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){ if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]) {
id moreButton = MSHookIvar<id>(self, "moreButton"); id moreButton = MSHookIvar<id>(self, "moreButton");
@ -143,7 +144,7 @@ static CGFloat pushshiftRequestTimeoutValue;
%property(strong, nonatomic) id post; %property(strong, nonatomic) id post;
%new %new
-(void) handleUndeletePostAction:(id) sender{ - (void)handleUndeletePostAction:(id)sender {
[sender setEnabled:NO]; [sender setEnabled:NO];
@ -156,7 +157,7 @@ static CGFloat pushshiftRequestTimeoutValue;
} }
%new %new
-(void) completeUndeletePostAction:(NSDictionary *) data{ - (void)completeUndeletePostAction:(NSDictionary *)data {
id post = [self post]; id post = [self post];
@ -164,11 +165,11 @@ static CGFloat pushshiftRequestTimeoutValue;
[post setContent:data[@"body"]]; [post setContent:data[@"body"]];
[post setMarkdownString:nil]; [post setMarkdownString:nil];
if ([self selfTextView]){ if ([self selfTextView]) {
[[self selfTextView] reloadContents]; [[self selfTextView] reloadContents];
} }
if ([self metadataView]){ if ([self metadataView]) {
[[self metadataView] setPost:post]; [[self metadataView] setPost:post];
} }
@ -186,26 +187,12 @@ static void loadPrefs(){
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"]; NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
if (prefs){ if (prefs){
isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES;
if ([prefs objectForKey:@"isBeamEnabled"] != nil){ isBeamEnabled = [prefs objectForKey:@"isBeamEnabled"] ? [[prefs objectForKey:@"isBeamEnabled"] boolValue] : YES;
isBeamEnabled = [[prefs objectForKey:@"isBeamEnabled"] boolValue]; isTFDeletedOnly = [prefs objectForKey:@"isTFDeletedOnly"] ? [[prefs objectForKey:@"isTFDeletedOnly"] boolValue] : YES;
} else { pushshiftRequestTimeoutValue = [prefs objectForKey:@"requestTimeoutValue"] ? [[prefs objectForKey:@"requestTimeoutValue"] doubleValue] : 10;
isBeamEnabled = YES;
}
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil) {
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
} else {
isTFDeletedOnly = YES;
}
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
} else {
pushshiftRequestTimeoutValue = 10;
}
} else { } else {
isEnabled = YES;
isBeamEnabled = YES; isBeamEnabled = YES;
isTFDeletedOnly = YES; isTFDeletedOnly = YES;
pushshiftRequestTimeoutValue = 10; pushshiftRequestTimeoutValue = 10;
@ -223,9 +210,9 @@ static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStrin
NSString* processName = [[NSProcessInfo processInfo] processName]; NSString* processName = [[NSProcessInfo processInfo] processName];
if ([processName isEqualToString:@"beam"]){ if ([processName isEqualToString:@"beam"]){
if (isBeamEnabled){ if (isBeamEnabled && isEnabled){
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
%init(Beam, CommentCell = objc_getClass("beam.CommentCell"), PostDetailEmbeddedViewController = objc_getClass("beam.PostDetailEmbeddedViewController"), PostToolbarView = objc_getClass("beam.PostToolbarView"), PostSelfTextPartCell = objc_getClass("beam.PostSelfTextPartCell"), PostMetadataView = objc_getClass("beam.PostMetadataView")); %init(Beam, CommentCell = objc_getClass("beam.CommentCell"), PostDetailEmbeddedViewController = objc_getClass("beam.PostDetailEmbeddedViewController"), PostToolbarView = objc_getClass("beam.PostToolbarView"), PostSelfTextPartCell = objc_getClass("beam.PostSelfTextPartCell"), PostMetadataView = objc_getClass("beam.PostMetadataView"));
} }

View File

@ -7,13 +7,13 @@
@property(assign,nonatomic) NSString* body; @property(assign,nonatomic) NSString* body;
@property(assign,nonatomic) NSString* fullName; @property(assign,nonatomic) NSString* fullName;
-(BOOL) isSaved; - (BOOL)isSaved;
@end @end
@interface NRTCommentsManager @interface NRTCommentsManager
@property(assign,nonatomic) NSMutableArray* comments; @property(assign,nonatomic) NSMutableArray* comments;
-(void) updateComment:(id) arg1 fromEdited:(id) arg2; - (void)updateComment:(id)arg1 fromEdited:(id)arg2;
@end @end
/* -- Post Interfaces -- */ /* -- Post Interfaces -- */
@ -25,13 +25,13 @@
@end @end
@interface NRTLinkTitleCell @interface NRTLinkTitleCell
-(void) configureCellForLink:(id) arg1; - (void)configureCellForLink:(id)arg1;
@end @end
@interface NRTLinkTextCell @interface NRTLinkTextCell
@property(assign,nonatomic) id bodyLabel; @property(assign,nonatomic) id bodyLabel;
-(void) configureCellForText:(id) arg1 links:(id) arg2; - (void)configureCellForText:(id)arg1 links:(id)arg2;
@end @end
/* -- Other Interfaces -- */ /* -- Other Interfaces -- */
@ -39,11 +39,11 @@
@interface NRTAuthManager @interface NRTAuthManager
@property(assign,nonatomic) NSString* currentUsername; @property(assign,nonatomic) NSString* currentUsername;
+(id) sharedManager; + (id)sharedManager;
@end @end
@interface NRTMarkdownManager @interface NRTMarkdownManager
+(id) attributedStringFromMarkdown:(id) arg1 type:(id) arg2; + (id)attributedStringFromMarkdown:(id)arg1 type:(id)arg2;
@end @end
@interface NRTAttributedLabel @interface NRTAttributedLabel
@ -62,70 +62,58 @@
@property(assign,nonatomic) id linkText; @property(assign,nonatomic) id linkText;
@property(assign,nonatomic) id tableView; @property(assign,nonatomic) id tableView;
-(void) _handleActionSheetCopyCommentText:(id) arg1; - (void)_handleActionSheetCopyCommentText:(id)arg1;
-(void) _handleActionSheetDeleteComment:(id) arg1; - (void)_handleActionSheetDeleteComment:(id)arg1;
-(void) _handleActionSheetDeletePost; - (void)_handleActionSheetDeletePost;
-(void) _handleActionSheetEditComment:(id) arg1; - (void)_handleActionSheetEditComment:(id)arg1;
-(void) _handleActionSheetEditPost; - (void)_handleActionSheetEditPost;
-(void) _handleActionSheetOpenChrome; - (void)_handleActionSheetOpenChrome;
-(void) _handleActionSheetOpenSafari; - (void)_handleActionSheetOpenSafari;
-(void) _handleActionSheetPrivateMessage:(id) arg1; - (void)_handleActionSheetPrivateMessage:(id)arg1;
-(void) _handleActionSheetRefreshComments; - (void)_handleActionSheetRefreshComments;
-(void) _handleActionSheetRefreshPost; - (void)_handleActionSheetRefreshPost;
-(void) _handleActionSheetReportComment:(id) arg1; - (void)_handleActionSheetReportComment:(id)arg1;
-(void) _handleActionSheetReportPost; - (void)_handleActionSheetReportPost;
-(void) _handleActionSheetSaveComment:(id) arg1 index:(NSUInteger) arg2; - (void)_handleActionSheetSaveComment:(id)arg1 index:(NSUInteger)arg2;
-(void) _handleActionSheetShareComment:(id) arg1; - (void)_handleActionSheetShareComment:(id)arg1;
-(void) _handleActionSheetShareLink; - (void)_handleActionSheetShareLink;
-(void) _handleActionSheetSharePost; - (void)_handleActionSheetSharePost;
-(void) _handleActionSheetSortComments; - (void)_handleActionSheetSortComments;
-(void) _handleActionSheetUnsaveComment:(id) arg1 index:(NSUInteger) arg2; - (void)_handleActionSheetUnsaveComment:(id)arg1 index:(NSUInteger)arg2;
-(void) _handleActionSheetViewParent:(id) arg1; - (void)_handleActionSheetViewParent:(id)arg1;
-(void) _handleActionSheetViewProfile:(id) arg1; - (void)_handleActionSheetViewProfile:(id)arg1;
//custom elements //custom elements
-(void) handleUndeleteAction:(id) arg1; - (void) handleUndeleteAction:(id)arg1;
-(void) handleUndeletePostAction; - (void) handleUndeletePostAction;
-(void) mainThreadTest:(id) arg1; - (void) mainThreadTest:(id)arg1;
@end @end
@interface NRTMediaTableViewDataSource @interface NRTMediaTableViewDataSource
@property(assign,nonatomic) id commentsManager; @property(assign,nonatomic) id commentsManager;
@property(assign,nonatomic) id parentController; @property(assign,nonatomic) id parentController;
-(void) _handleActionSheetCopyCommentText:(id) arg1; - (void)_handleActionSheetCopyCommentText:(id)arg1;
-(void) _handleActionSheetDeleteComment:(id) arg1; - (void)_handleActionSheetDeleteComment:(id)arg1;
-(void) _handleActionSheetDeletePost; - (void)_handleActionSheetDeletePost;
-(void) _handleActionSheetEditComment:(id) arg1; - (void)_handleActionSheetEditComment:(id)arg1;
-(void) _handleActionSheetEditPost; - (void)_handleActionSheetEditPost;
-(void) _handleActionSheetOpenChrome; - (void)_handleActionSheetOpenChrome;
-(void) _handleActionSheetOpenSafari; - (void)_handleActionSheetOpenSafari;
-(void) _handleActionSheetPrivateMessage:(id) arg1; - (void)_handleActionSheetPrivateMessage:(id)arg1;
-(void) _handleActionSheetRefreshComments; - (void)_handleActionSheetRefreshComments;
-(void) _handleActionSheetRefreshPost; - (void)_handleActionSheetRefreshPost;
-(void) _handleActionSheetReportComment:(id) arg1; - (void)_handleActionSheetReportComment:(id)arg1;
-(void) _handleActionSheetReportPost; - (void)_handleActionSheetReportPost;
-(void) _handleActionSheetSaveComment:(id) arg1 index:(NSUInteger) arg2; - (void)_handleActionSheetSaveComment:(id)arg1 index:(NSUInteger)arg2;
-(void) _handleActionSheetShareComment:(id) arg1; - (void)_handleActionSheetShareComment:(id)arg1;
-(void) _handleActionSheetShareLink; - (void)_handleActionSheetShareLink;
-(void) _handleActionSheetSharePost; - (void)_handleActionSheetSharePost;
-(void) _handleActionSheetSortComments; - (void)_handleActionSheetSortComments;
-(void) _handleActionSheetUnsaveComment:(id) arg1 index:(NSUInteger) arg2; - (void)_handleActionSheetUnsaveComment:(id)arg1 index:(NSUInteger)arg2;
-(void) _handleActionSheetViewParent:(id) arg1; - (void)_handleActionSheetViewParent:(id)arg1;
-(void) _handleActionSheetViewProfile:(id) arg1; - (void)_handleActionSheetViewProfile:(id)arg1;
//custom elements //custom elements
-(void) handleUndeleteCommentAction:(id) comment; - (void)handleUndeleteCommentAction:(id)comment;
@end @end

View File

@ -2,6 +2,7 @@
#import "Narwhal.h" #import "Narwhal.h"
#import "assets/TFHelper.h" #import "assets/TFHelper.h"
static BOOL isEnabled;
static BOOL isNarwhalEnabled; static BOOL isNarwhalEnabled;
static BOOL isTFDeletedOnly; static BOOL isTFDeletedOnly;
static CGFloat pushshiftRequestTimeoutValue; static CGFloat pushshiftRequestTimeoutValue;
@ -19,13 +20,13 @@ void getUndeleteCommentData(id controller, id comment){
%hook UIViewController %hook UIViewController
-(void) presentViewController:(id) arg1 animated:(BOOL) arg2 completion:(id) arg3{ - (void)presentViewController:(id)arg1 animated:(BOOL)arg2 completion:(id)arg3 {
if ([arg1 isKindOfClass:[UIAlertController class]] && shouldHaveUndeleteAction){ if ([arg1 isKindOfClass:[UIAlertController class]] && shouldHaveUndeleteAction) {
UIAlertAction* undeleteAction; UIAlertAction* undeleteAction;
if (tfComment){ if (tfComment) {
undeleteAction = [UIAlertAction actionWithTitle:@"tf did that say?" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){getUndeleteCommentData(tfController, tfComment);}]; undeleteAction = [UIAlertAction actionWithTitle:@"tf did that say?" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){getUndeleteCommentData(tfController, tfComment);}];
} else { } else {
undeleteAction = [UIAlertAction actionWithTitle:@"tf did that say?" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){[tfController handleUndeletePostAction];}]; undeleteAction = [UIAlertAction actionWithTitle:@"tf did that say?" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){[tfController handleUndeletePostAction];}];
@ -42,9 +43,9 @@ void getUndeleteCommentData(id controller, id comment){
%hook NRTLinkViewController %hook NRTLinkViewController
-(void) swipeCell:(id) arg1 didEndDragWithState:(NSUInteger) arg2{ - (void)swipeCell:(id)arg1 didEndDragWithState:(NSUInteger)arg2 {
if (arg2 == 2){ if (arg2 == 2) {
if ([arg1 isKindOfClass:[%c(NRTCommentTableViewCell) class]]) { if ([arg1 isKindOfClass:[%c(NRTCommentTableViewCell) class]]) {
NSString *commentBody = MSHookIvar<NSString*>([arg1 comment], "_body"); NSString *commentBody = MSHookIvar<NSString*>([arg1 comment], "_body");
@ -62,13 +63,13 @@ void getUndeleteCommentData(id controller, id comment){
shouldHaveUndeleteAction = NO; shouldHaveUndeleteAction = NO;
} }
-(void) _dotsButtonTouched:(id) arg1{ - (void)_dotsButtonTouched:(id)arg1 {
if ([self linkTextOffscreenCell]){ if ([self linkTextOffscreenCell]) {
NSString *postBody = [[self link] selfText]; NSString *postBody = [[self link] selfText];
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){ if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]) {
tfController = self; tfController = self;
tfComment = nil; tfComment = nil;
shouldHaveUndeleteAction = YES; shouldHaveUndeleteAction = YES;
@ -81,7 +82,7 @@ void getUndeleteCommentData(id controller, id comment){
} }
%new %new
-(void) handleUndeletePostAction{ - (void)handleUndeletePostAction {
id post = [self link]; id post = [self link];
@ -89,7 +90,7 @@ void getUndeleteCommentData(id controller, id comment){
} }
%new %new
-(void) completeUndeletePostAction:(NSDictionary *) data{ - (void)completeUndeletePostAction:(NSDictionary *)data {
id post = data[@"post"]; id post = data[@"post"];
@ -102,11 +103,11 @@ void getUndeleteCommentData(id controller, id comment){
} }
%new %new
-(void) completeUndeleteCommentAction:(NSDictionary *) data{ - (void)completeUndeleteCommentAction:(NSDictionary *)data {
id comment = data[@"comment"]; id comment = data[@"comment"];
if (comment){ if (comment) {
MSHookIvar<NSString*>(comment, "_author") = data[@"author"]; MSHookIvar<NSString*>(comment, "_author") = data[@"author"];
MSHookIvar<NSString*>(comment, "_body") = data[@"body"]; MSHookIvar<NSString*>(comment, "_body") = data[@"body"];
@ -120,14 +121,14 @@ void getUndeleteCommentData(id controller, id comment){
%hook NRTMediaTableViewDataSource %hook NRTMediaTableViewDataSource
-(void) swipeCell:(id) arg1 didEndDragWithState:(NSUInteger) arg2{ - (void)swipeCell:(id)arg1 didEndDragWithState:(NSUInteger)arg2 {
if (arg2 == 2){ if (arg2 == 2) {
if ([arg1 isKindOfClass:[%c(NRTCommentTableViewCell) class]]) { if ([arg1 isKindOfClass:[%c(NRTCommentTableViewCell) class]]) {
NSString *commentBody = MSHookIvar<NSString*>([arg1 comment], "_body"); NSString *commentBody = MSHookIvar<NSString*>([arg1 comment], "_body");
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){ if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]) {
tfComment = [arg1 comment]; tfComment = [arg1 comment];
tfController = self; tfController = self;
shouldHaveUndeleteAction = YES; shouldHaveUndeleteAction = YES;
@ -141,11 +142,11 @@ void getUndeleteCommentData(id controller, id comment){
} }
%new %new
-(void) completeUndeleteCommentAction:(NSDictionary *) data{ - (void)completeUndeleteCommentAction:(NSDictionary *)data {
id comment = data[@"comment"]; id comment = data[@"comment"];
if (comment){ if (comment) {
MSHookIvar<NSString*>(comment, "_author") = data[@"author"]; MSHookIvar<NSString*>(comment, "_author") = data[@"author"];
MSHookIvar<NSString*>(comment, "_body") = data[@"body"]; MSHookIvar<NSString*>(comment, "_body") = data[@"body"];
@ -163,26 +164,12 @@ static void loadPrefs(){
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"]; NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
if (prefs){ if (prefs){
isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES;
if ([prefs objectForKey:@"isNarwhalEnabled"] != nil){ isNarwhalEnabled = [prefs objectForKey:@"isNarwhalEnabled"] ? [[prefs objectForKey:@"isNarwhalEnabled"] boolValue] : YES;
isNarwhalEnabled = [[prefs objectForKey:@"isNarwhalEnabled"] boolValue]; isTFDeletedOnly = [prefs objectForKey:@"isTFDeletedOnly"] ? [[prefs objectForKey:@"isTFDeletedOnly"] boolValue] : YES;
} else { pushshiftRequestTimeoutValue = [prefs objectForKey:@"requestTimeoutValue"] ? [[prefs objectForKey:@"requestTimeoutValue"] doubleValue] : 10;
isNarwhalEnabled = YES;
}
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil) {
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
} else {
isTFDeletedOnly = YES;
}
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
} else {
pushshiftRequestTimeoutValue = 10;
}
} else { } else {
isEnabled = YES;
isNarwhalEnabled = YES; isNarwhalEnabled = YES;
isTFDeletedOnly = YES; isTFDeletedOnly = YES;
pushshiftRequestTimeoutValue = 10; pushshiftRequestTimeoutValue = 10;
@ -200,9 +187,9 @@ static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStrin
NSString* processName = [[NSProcessInfo processInfo] processName]; NSString* processName = [[NSProcessInfo processInfo] processName];
if ([processName isEqualToString:@"narwhal"]){ if ([processName isEqualToString:@"narwhal"]){
if (isNarwhalEnabled){ if (isNarwhalEnabled && isEnabled){
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
%init(Narwhal); %init(Narwhal);
} }

View File

@ -16,22 +16,22 @@
@interface CommentsViewController : NSObject @interface CommentsViewController : NSObject
@property(strong,nonatomic) id postData; @property(strong,nonatomic) id postData;
-(void) reloadCommentsWithNewCommentsHighlight:(BOOL) arg1 autoScroll:(BOOL) arg2 animated:(BOOL) arg3; - (void)reloadCommentsWithNewCommentsHighlight:(BOOL)arg1 autoScroll:(BOOL)arg2 animated:(BOOL)arg3;
-(void) reloadCommentsSection:(BOOL) arg1; - (void)reloadCommentsSection:(BOOL)arg1;
-(void) reloadPostSection:(BOOL) arg1; - (void)reloadPostSection:(BOOL)arg1;
-(void) feedPostViewDidUpdatePost:(id) arg1 shouldReloadFeed:(BOOL) arg2; - (void)feedPostViewDidUpdatePost:(id)arg1 shouldReloadFeed:(BOOL)arg2;
-(void) updateFloatingViews; - (void)updateFloatingViews;
//custom elements //custom elements
-(void) updateComments; - (void)updateComments;
-(void) updatePostText; - (void)updatePostText;
@end @end
@interface CommentActionSheetViewController : UIViewController @interface CommentActionSheetViewController : UIViewController
@property(strong,nonatomic) Comment *comment; @property(strong,nonatomic) Comment *comment;
@property(strong,nonatomic) id commentTreeNode; @property(strong,nonatomic) id commentTreeNode;
@property(strong,nonatomic) CommentsViewController *commentActionSheetDelegate; @property(strong,nonatomic) CommentsViewController *commentActionSheetDelegate;
-(id)animationControllerForDismissedController:(id) arg1; - (id)animationControllerForDismissedController:(id)arg1;
@end @end
@ -54,7 +54,7 @@
@interface CommentTreeHeaderNode @interface CommentTreeHeaderNode
@property(strong,nonatomic) id commentTreeNode; @property(strong,nonatomic) id commentTreeNode;
-(void) updateContentViewsForData:(id)arg1; - (void)updateContentViewsForData:(id)arg1;
@end @end
@interface CommentTreeCommandBarNode @interface CommentTreeCommandBarNode
@ -68,7 +68,7 @@
@interface CommentTreeHeaderView @interface CommentTreeHeaderView
@property(strong,nonatomic) id commentTreeNode; @property(strong,nonatomic) id commentTreeNode;
-(void) updateContentViewsForData:(id) arg1; - (void)updateContentViewsForData:(id)arg1;
@end @end
/* -- Post Interfaces -- */ /* -- Post Interfaces -- */
@ -85,7 +85,7 @@
@interface PostDetailViewController @interface PostDetailViewController
@property(strong,nonatomic) id selfTextNode; @property(strong,nonatomic) id selfTextNode;
-(void) configureSelfTextNode; - (void)configureSelfTextNode;
//custom elements //custom elements
@property(strong,nonatomic) id feedPostTextWithThumbnailNode; @property(strong,nonatomic) id feedPostTextWithThumbnailNode;
@ -111,7 +111,7 @@
@interface FeedPostTitleNode @interface FeedPostTitleNode
@property(strong,nonatomic) id delegate; @property(strong,nonatomic) id delegate;
-(void) configureNodes; - (void)configureNodes;
@end @end
@interface FeedPostDetailDelegator @interface FeedPostDetailDelegator
@ -119,7 +119,7 @@
@end @end
@interface FeedPostContentNode @interface FeedPostContentNode
-(void) configureSelfTextNode; - (void)configureSelfTextNode;
@end @end
/* -- Other Interfaces -- */ /* -- Other Interfaces -- */
@ -130,14 +130,14 @@
@interface RUIActionSheetItem : NSObject @interface RUIActionSheetItem : NSObject
@property(strong,nonatomic) id leftIconImage; @property(strong,nonatomic) id leftIconImage;
-(id) initWithLeftIconImage:(id) arg1 text:(id) arg2 identifier:(id) arg3 context:(id) arg4; - (id)initWithLeftIconImage:(id)arg1 text:(id)arg2 identifier:(id)arg3 context:(id)arg4;
@end @end
@interface ActionSheetItem : NSObject @interface ActionSheetItem : NSObject
// <= 4.17 // <= 4.17
@property(strong,nonatomic) id leftIconImage; @property(strong,nonatomic) id leftIconImage;
-(id) initWithLeftIconImage:(id) arg1 text:(id) arg2 identifier:(id) arg3 context:(id) arg4; - (id) initWithLeftIconImage:(id)arg1 text:(id)arg2 identifier:(id)arg3 context:(id)arg4;
@end @end
@interface RUITheme @interface RUITheme
@ -145,65 +145,66 @@
@end @end
@interface NSAttributedStringMarkdownParser @interface NSAttributedStringMarkdownParser
+(id) currentConfig; + (id)currentConfig;
+(id) attributedStringUsingCurrentConfig:(id) arg1; + (id)attributedStringUsingCurrentConfig:(id)arg1;
-(id) attributedStringFromMarkdownString:(id) arg1; - (id)attributedStringFromMarkdownString:(id)arg1;
-(id) initWithConfig:(id) arg1; - (id)initWithConfig:(id)arg1;
@end @end
@interface ThemeManager @interface ThemeManager
+(id) sharedManager; + (id)sharedManager;
// >= 4.45.0 // >= 4.45.0
@property(strong,nonatomic) id darkTheme; @property(strong,nonatomic) id darkTheme;
@property(strong,nonatomic) id lightTheme; @property(strong,nonatomic) id lightTheme;
-(id) initWithAppSettings:(id) arg1; - (id)initWithAppSettings:(id)arg1;
// < 4.45.0 // < 4.45.0
@property(strong,nonatomic) id dayTheme; @property(strong,nonatomic) id dayTheme;
@property(strong,nonatomic) id nightTheme; @property(strong,nonatomic) id nightTheme;
-(id) initWithTraitCollection:(id) arg1 appSettings:(id) arg2; - (id)initWithTraitCollection:(id)arg1 appSettings:(id)arg2;
@end @end
@interface AppSettings @interface AppSettings
+(id) sharedSettings; + (id)sharedSettings;
@end @end
@interface AccountManager @interface AccountManager
@property(assign,nonatomic) id defaults; @property(assign,nonatomic) id defaults;
+(id) sharedManager; + (id)sharedManager;
@end @end
/* ---- Reddit v3 ---- */ /* ---- Reddit v3 ---- */
/* -- Comment Interfaces -- */ /* -- Comment Interfaces -- */
@interface CommentCell : UIView @interface CommentCell : UIView
-(id) delegate; - (id)delegate;
-(id) comment; - (id)comment;
- (id)commentView; - (id)commentView;
@end @end
@interface CommentView @interface CommentView
-(void) configureSubviews; - (void)configureSubviews;
-(void) layoutSubviews; - (void)layoutSubviews;
-(id) commandView; - (id)commandView;
-(id) comment; - (id)comment;
- (id)delegate; - (id)delegate;
@end @end
@interface CommentCommandView @interface CommentCommandView
@property (strong, nonatomic) id undeleteButton; @property (strong, nonatomic) id undeleteButton;
-(id)overflowButton; - (id)overflowButton;
-(id) comment; - (id)comment;
- (id)delegate; - (id)delegate;
@end @end
/* -- Other Interfaces -- */ /* -- Other Interfaces -- */
@interface MarkDownParser @interface MarkDownParser
+ (id)attributedStringFromMarkdownString:(id)arg1; + (id)attributedStringFromMarkdownString:(id)arg1;

View File

@ -2,6 +2,7 @@
#import "Reddit.h" #import "Reddit.h"
#import "assets/TFHelper.h" #import "assets/TFHelper.h"
static BOOL isEnabled;
static BOOL isRedditEnabled; static BOOL isRedditEnabled;
static BOOL isTFDeletedOnly; static BOOL isTFDeletedOnly;
static CGFloat pushshiftRequestTimeoutValue; static CGFloat pushshiftRequestTimeoutValue;
@ -18,7 +19,7 @@ int secondVersionPart = 0;
%hook CommentTreeHeaderView %hook CommentTreeHeaderView
-(void) layoutSubviews{ - (void)layoutSubviews {
%orig; %orig;
[[self commentTreeNode] setCommentTreeHeaderNode:self]; [[self commentTreeNode] setCommentTreeHeaderNode:self];
@ -28,7 +29,7 @@ int secondVersionPart = 0;
%hook CommentTreeHeaderNode %hook CommentTreeHeaderNode
-(void) didLoad{ - (void)didLoad {
%orig; %orig;
[[self commentTreeNode] setCommentTreeHeaderNode:self]; [[self commentTreeNode] setCommentTreeHeaderNode:self];
@ -38,7 +39,7 @@ int secondVersionPart = 0;
%hook CommentTreeCommandBarNode %hook CommentTreeCommandBarNode
-(void) didLoad{ - (void)didLoad {
%orig; %orig;
[[self commentTreeNode] setCommentTreeCommandBarNode:self]; [[self commentTreeNode] setCommentTreeCommandBarNode:self];
@ -48,11 +49,11 @@ int secondVersionPart = 0;
%hook CommentActionSheetViewController %hook CommentActionSheetViewController
-(void) setItems:(id) arg1{ - (void)setItems:(id)arg1 {
NSString *commentBody = [[self comment] bodyText]; NSString *commentAuthor = [[self comment] author];
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){ if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentAuthor 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"];
@ -71,10 +72,10 @@ int secondVersionPart = 0;
%orig; %orig;
} }
-(void) handleDidSelectActionSheetItem:(id) arg1{ - (void)handleDidSelectActionSheetItem:(id)arg1 {
%orig; %orig;
if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]){ if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]) {
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
@ -86,7 +87,7 @@ int secondVersionPart = 0;
} }
%new %new
-(void) completeUndeleteCommentAction:(NSDictionary *) data{ - (void)completeUndeleteCommentAction:(NSDictionary *)data {
id commentTreeNode = [self commentTreeNode]; id commentTreeNode = [self commentTreeNode];
Comment *comment = [commentTreeNode comment]; Comment *comment = [commentTreeNode comment];
@ -100,38 +101,38 @@ int secondVersionPart = 0;
id isNightMode; id isNightMode;
id textColor; id textColor;
if (firstVersionPart == 2020){ if (firstVersionPart == 2020) {
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]]; themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"]; isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
if (isNightMode) { if (isNightMode) {
textColor = [[themeManager darkTheme] bodyTextColor]; textColor = [[themeManager darkTheme] bodyTextColor];
} else{ } else {
textColor = [[themeManager lightTheme] bodyTextColor]; textColor = [[themeManager lightTheme] bodyTextColor];
} }
[themeManager release]; [themeManager release];
} else { } else {
if (secondVersionPart >= 45){ if (secondVersionPart >= 45) {
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]]; themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"]; isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
if (isNightMode) { if (isNightMode) {
textColor = [[themeManager darkTheme] bodyTextColor]; textColor = [[themeManager darkTheme] bodyTextColor];
} else{ } else {
textColor = [[themeManager lightTheme] bodyTextColor]; textColor = [[themeManager lightTheme] bodyTextColor];
} }
[themeManager release]; [themeManager release];
} else if (secondVersionPart >= 37){ } else if (secondVersionPart >= 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"];
if (isNightMode) { if (isNightMode) {
textColor = [[themeManager nightTheme] bodyTextColor]; textColor = [[themeManager nightTheme] bodyTextColor];
} else{ } else {
textColor = [[themeManager dayTheme] bodyTextColor]; textColor = [[themeManager dayTheme] bodyTextColor];
} }
@ -143,7 +144,7 @@ int secondVersionPart = 0;
if (isNightMode) { if (isNightMode) {
textColor = [[themeManager nightTheme] bodyTextColor]; textColor = [[themeManager nightTheme] bodyTextColor];
} else{ } else {
textColor = [[themeManager dayTheme] bodyTextColor]; textColor = [[themeManager dayTheme] bodyTextColor];
} }
} }
@ -178,7 +179,7 @@ int secondVersionPart = 0;
%hook FeedPostDetailCellNode %hook FeedPostDetailCellNode
-(void) didLoad{ - (void)didLoad {
%orig; %orig;
[[[self delegate] viewController] setFeedPostDetailCellNode:self]; [[[self delegate] viewController] setFeedPostDetailCellNode:self];
@ -187,13 +188,13 @@ int secondVersionPart = 0;
%hook PostActionSheetViewController %hook PostActionSheetViewController
-(void) setItems:(id) arg1{ - (void)setItems:(id)arg1 {
Post *post = [self post]; Post *post = [self post];
NSString *postBody = [post selfText]; NSString *postBody = [post selfText];
if ([post isSelfPost]){ if ([post isSelfPost]) {
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly: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"];
@ -214,10 +215,10 @@ int secondVersionPart = 0;
} }
-(void) handleDidSelectActionSheetItem:(id) arg1{ - (void)handleDidSelectActionSheetItem:(id)arg1 {
%orig; %orig;
if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]){ if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]) {
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
@ -231,7 +232,7 @@ int secondVersionPart = 0;
} }
%new %new
-(void) completeUndeletePostAction:(NSDictionary *) data{ - (void)completeUndeletePostAction:(NSDictionary *)data {
Post *post = [self post]; Post *post = [self post];
NSString *author = data[@"author"]; NSString *author = data[@"author"];
@ -241,38 +242,38 @@ int secondVersionPart = 0;
id isNightMode; id isNightMode;
id textColor; id textColor;
if (firstVersionPart == 2020){ if (firstVersionPart == 2020) {
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]]; themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"]; isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
if (isNightMode) { if (isNightMode) {
textColor = [[themeManager darkTheme] bodyTextColor]; textColor = [[themeManager darkTheme] bodyTextColor];
} else{ } else {
textColor = [[themeManager lightTheme] bodyTextColor]; textColor = [[themeManager lightTheme] bodyTextColor];
} }
[themeManager release]; [themeManager release];
} else { } else {
if (secondVersionPart >= 45){ if (secondVersionPart >= 45) {
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]]; themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"]; isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
if (isNightMode) { if (isNightMode) {
textColor = [[themeManager darkTheme] bodyTextColor]; textColor = [[themeManager darkTheme] bodyTextColor];
} else{ } else {
textColor = [[themeManager lightTheme] bodyTextColor]; textColor = [[themeManager lightTheme] bodyTextColor];
} }
[themeManager release]; [themeManager release];
} else if (secondVersionPart >= 37){ } else if (secondVersionPart >= 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"];
if (isNightMode) { if (isNightMode) {
textColor = [[themeManager nightTheme] bodyTextColor]; textColor = [[themeManager nightTheme] bodyTextColor];
} else{ } else {
textColor = [[themeManager dayTheme] bodyTextColor]; textColor = [[themeManager dayTheme] bodyTextColor];
} }
@ -284,7 +285,7 @@ int secondVersionPart = 0;
if (isNightMode) { if (isNightMode) {
textColor = [[themeManager nightTheme] bodyTextColor]; textColor = [[themeManager nightTheme] bodyTextColor];
} else{ } else {
textColor = [[themeManager dayTheme] bodyTextColor]; textColor = [[themeManager dayTheme] bodyTextColor];
} }
} }
@ -304,10 +305,10 @@ int secondVersionPart = 0;
[post setSelfPostRichTextAttributed:bodyMutableAttributedText]; [post setSelfPostRichTextAttributed:bodyMutableAttributedText];
[post setPreviewFeedPostTextString:bodyMutableAttributedText]; [post setPreviewFeedPostTextString:bodyMutableAttributedText];
if (firstVersionPart == 2020){ if (firstVersionPart == 2020) {
[[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] configureSelfTextNode]; [[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] configureSelfTextNode];
} else { } else {
if (secondVersionPart >= 44){ if (secondVersionPart >= 44) {
[[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] configureSelfTextNode]; [[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] configureSelfTextNode];
} else if (secondVersionPart >= 38) { } else if (secondVersionPart >= 38) {
[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] configureSelfTextNode]; [[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] configureSelfTextNode];
@ -330,12 +331,12 @@ int secondVersionPart = 0;
%hook CommentsViewController %hook CommentsViewController
%new %new
-(void) updateComments{ - (void)updateComments {
[self reloadCommentsWithNewCommentsHighlight:NO autoScroll:NO animated:NO]; [self reloadCommentsWithNewCommentsHighlight:NO autoScroll:NO animated:NO];
} }
%new %new
-(void) updatePostText{ - (void)updatePostText {
if (secondVersionPart >= 2){ if (secondVersionPart >= 2){
[self reloadPostSection:YES]; [self reloadPostSection:YES];
@ -348,11 +349,11 @@ int secondVersionPart = 0;
%hook CommentActionSheetViewController %hook CommentActionSheetViewController
-(void) setItems:(id) arg1{ - (void)setItems:(id)arg1 {
NSString *commentBody = [[self comment] bodyText]; NSString *commentAuthor = [[self comment] author];
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){ if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentAuthor 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"];
@ -378,10 +379,10 @@ int secondVersionPart = 0;
} }
// >= 4.21 // >= 4.21
-(void) handleDidSelectActionSheetItem:(id) arg1{ - (void)handleDidSelectActionSheetItem:(id)arg1 {
%orig; %orig;
if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]){ if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]) {
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
@ -392,7 +393,7 @@ int secondVersionPart = 0;
} }
// <= 4.20 // <= 4.20
-(void) actionSheetViewController:(id) arg1 didSelectItem:(id) arg2{ - (void)actionSheetViewController:(id)arg1 didSelectItem:(id)arg2 {
%orig; %orig;
if ([[arg2 identifier] isEqualToString:@"undeleteItemIdentifier"]){ if ([[arg2 identifier] isEqualToString:@"undeleteItemIdentifier"]){
@ -406,7 +407,7 @@ int secondVersionPart = 0;
} }
%new %new
-(void) completeUndeleteCommentAction:(NSDictionary *) data{ - (void)completeUndeleteCommentAction:(NSDictionary *)data {
Comment *comment = [self comment]; Comment *comment = [self comment];
@ -431,13 +432,13 @@ int secondVersionPart = 0;
%hook PostActionSheetViewController %hook PostActionSheetViewController
-(void) setItems:(id) arg1{ - (void)setItems:(id)arg1{
Post *post = [self post]; Post *post = [self post];
NSString *postBody = [post selfText]; NSString *postBody = [post selfText];
if ([post isSelfPost]){ if ([post isSelfPost]) {
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly: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"];
@ -464,27 +465,26 @@ int secondVersionPart = 0;
} }
// >= 4.21 // >= 4.21
-(void) handleDidSelectActionSheetItem:(id) arg1{ - (void)handleDidSelectActionSheetItem:(id)arg1 {
%orig; %orig;
if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]){ if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]) {
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
Post *post = [self post]; Post *post = [self post];
if ([post isSelfPost]){ if ([post isSelfPost]) {
[%c(TFHelper) getUndeleteDataWithID:[[post pk] componentsSeparatedByString:@"_"][1] isComment:NO timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeletePostAction:)]; [%c(TFHelper) getUndeleteDataWithID:[[post pk] componentsSeparatedByString:@"_"][1] isComment:NO timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeletePostAction:)];
} }
} }
} }
// <= 4.20 // <= 4.20
-(void) actionSheetViewController:(id) arg1 didSelectItem:(id) arg2{ - (void)actionSheetViewController:(id)arg1 didSelectItem:(id)arg2 {
%orig; %orig;
if ([[arg2 identifier] isEqualToString:@"undeleteItemIdentifier"]){ if ([[arg2 identifier] isEqualToString:@"undeleteItemIdentifier"]) {
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
@ -498,7 +498,7 @@ int secondVersionPart = 0;
} }
%new %new
-(void) completeUndeletePostAction:(NSDictionary *) data{ - (void)completeUndeletePostAction:(NSDictionary *)data {
Post *post = [self post]; Post *post = [self post];
@ -615,26 +615,12 @@ static void loadPrefs(){
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"]; NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
if (prefs){ if (prefs){
isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES;
if ([prefs objectForKey:@"isRedditEnabled"] != nil){ isRedditEnabled = [prefs objectForKey:@"isRedditEnabled"] ? [[prefs objectForKey:@"isRedditEnabled"] boolValue] : YES;
isRedditEnabled = [[prefs objectForKey:@"isRedditEnabled"] boolValue]; isTFDeletedOnly = [prefs objectForKey:@"isTFDeletedOnly"] ? [[prefs objectForKey:@"isTFDeletedOnly"] boolValue] : YES;
} else { pushshiftRequestTimeoutValue = [prefs objectForKey:@"requestTimeoutValue"] ? [[prefs objectForKey:@"requestTimeoutValue"] doubleValue] : 10;
isRedditEnabled = YES;
}
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil) {
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
} else {
isTFDeletedOnly = YES;
}
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
} else {
pushshiftRequestTimeoutValue = 10;
}
} else { } else {
isEnabled = YES;
isRedditEnabled = YES; isRedditEnabled = YES;
isTFDeletedOnly = YES; isTFDeletedOnly = YES;
pushshiftRequestTimeoutValue = 10; pushshiftRequestTimeoutValue = 10;
@ -651,24 +637,24 @@ static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStrin
NSString* processName = [[NSProcessInfo processInfo] processName]; NSString* processName = [[NSProcessInfo processInfo] processName];
@try{ @try {
NSArray *redditVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."]; NSArray *redditVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."];
firstVersionPart = [redditVersion[0] intValue]; firstVersionPart = [redditVersion[0] intValue];
secondVersionPart = [redditVersion[1] intValue]; secondVersionPart = [redditVersion[1] intValue];
} }
@catch (NSException *exc){ @catch (NSException *exc) {
firstVersionPart = 2020; firstVersionPart = 2020;
secondVersionPart = 0; secondVersionPart = 0;
} }
if ([processName isEqualToString:@"Reddit"]){ if ([processName isEqualToString:@"Reddit"]){
if (isRedditEnabled) { if (isRedditEnabled && isEnabled) {
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
if (firstVersionPart == 4 || firstVersionPart == 2020){ if (firstVersionPart == 4 || firstVersionPart == 2020) {
if (secondVersionPart <= 32 && firstVersionPart != 2020){ if (secondVersionPart <= 32 && firstVersionPart != 2020) {
%init(Reddit_v4_ios10); %init(Reddit_v4_ios10);
} else{ } else{
%init(Reddit_v4_current); %init(Reddit_v4_current);

View File

@ -9,10 +9,10 @@
@end @end
@interface CommentDepthCell @interface CommentDepthCell
-(void) showMenu:(id) arg1; - (void)showMenu:(id)arg1;
//custom elements //custom elements
-(void) addUndeleteButtonToMenu; - (void)addUndeleteButtonToMenu;
@end @end
/* -- Post Interfaces -- */ /* -- Post Interfaces -- */
@ -22,38 +22,38 @@
@end @end
@interface CommentViewController : UIViewController @interface CommentViewController : UIViewController
-(void) refresh:(id) arg1; - (void)refresh:(id)arg1;
//custom elements //custom elements
@property(strong, nonatomic) UIButton *undeleteButton; @property(strong, nonatomic) UIButton *undeleteButton;
-(void) addUndeleteButtonToToolbar; - (void)addUndeleteButtonToToolbar;
-(BOOL) shouldAddUndeleteButtonToToolbar; - (BOOL)shouldAddUndeleteButtonToToolbar;
@end @end
/* -- Utility Interfaces -- */ /* -- Utility Interfaces -- */
@interface UIColor () @interface UIColor ()
+(UIColor *) colorWithHex:(NSString *) arg1; + (UIColor *)colorWithHex:(NSString *)arg1;
-(NSString *) hexString; - (NSString *)hexString;
@end @end
@interface NSAttributedString () @interface NSAttributedString ()
-(void) yy_setTextHighlightRange:(NSRange) range color:(UIColor *) color backgroundColor:(UIColor *) backgroundColor userInfo:(NSDictionary *) userInfo; - (void)yy_setTextHighlightRange:(NSRange)range color:(UIColor *)color backgroundColor:(UIColor *)backgroundColor userInfo:(NSDictionary *)userInfo;
@end @end
@interface ColorUtil : NSObject @interface ColorUtil : NSObject
+(UIColor *) accentColorForSub:(NSString *) arg1; + (UIColor *)accentColorForSub:(NSString *)arg1;
+(UIColor *) fontColorForTheme:(NSString *) arg1; + (UIColor *)fontColorForTheme:(NSString *)arg1;
+(UIColor *) backgroundColorForTheme:(NSString *) arg1; + (UIColor *)backgroundColorForTheme:(NSString *)arg1;
@end @end
@interface DTHTMLAttributedStringBuilder @interface DTHTMLAttributedStringBuilder
-(id) initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttributes:(NSDictionary * __autoreleasing*)docAttributes; - (id) initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttributes:(NSDictionary * __autoreleasing*)docAttributes;
-(NSAttributedString *) generatedAttributedString; - (NSAttributedString *)generatedAttributedString;
@end @end
@interface FontGenerator : NSObject @interface FontGenerator : NSObject
+(UIFont *) fontOfSize:(CGFloat) arg1 submission:(BOOL) arg2 willOffset:(BOOL) arg3; + (UIFont *)fontOfSize:(CGFloat)arg1 submission:(BOOL)arg2 willOffset:(BOOL)arg3;
+(UIFont *) boldFontOfSize:(CGFloat) arg1 submission:(BOOL) arg2 willOffset:(BOOL) arg3; + (UIFont *)boldFontOfSize:(CGFloat)arg1 submission:(BOOL)arg2 willOffset:(BOOL)arg3;
+(UIFont *) italicFontOfSize:(CGFloat) arg1 submission:(BOOL) arg2 willOffset:(BOOL) arg3; + (UIFont *)italicFontOfSize:(CGFloat)arg1 submission:(BOOL)arg2 willOffset:(BOOL)arg3;
@end @end

View File

@ -3,6 +3,7 @@
#import "assets/TFHelper.h" #import "assets/TFHelper.h"
#import "assets/MMMarkdown/MMMarkdown.h" #import "assets/MMMarkdown/MMMarkdown.h"
static BOOL isEnabled;
static BOOL isSlideEnabled; static BOOL isSlideEnabled;
static BOOL isTFDeletedOnly; static BOOL isTFDeletedOnly;
static CGFloat pushshiftRequestTimeoutValue; static CGFloat pushshiftRequestTimeoutValue;
@ -15,13 +16,13 @@ NSString *slidePostOverrideBodyHtml;
@implementation FontGenerator @implementation FontGenerator
+(UIFont *) fontOfSize:(CGFloat) size submission:(BOOL) isSubmission willOffset:(BOOL) willOffset{ + (UIFont *)fontOfSize:(CGFloat)size submission:(BOOL)isSubmission willOffset:(BOOL)willOffset {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSString *fontName; NSString *fontName;
CGFloat fontSize = size; CGFloat fontSize = size;
if (willOffset){ if (willOffset) {
if (isSubmission){ if (isSubmission){
fontSize += ([userDefaults objectForKey:@"POST_FONT_SIZE"] == nil) ? 0 : [userDefaults integerForKey:@"POST_FONT_SIZE"]; fontSize += ([userDefaults objectForKey:@"POST_FONT_SIZE"] == nil) ? 0 : [userDefaults integerForKey:@"POST_FONT_SIZE"];
} else { } else {
@ -29,7 +30,7 @@ NSString *slidePostOverrideBodyHtml;
} }
} }
if ([userDefaults stringForKey:(isSubmission ? @"postfont" : @"commentfont")] == nil){ if ([userDefaults stringForKey:(isSubmission ? @"postfont" : @"commentfont")] == nil) {
fontName = isSubmission ? @"AvenirNext-DemiBold" : @"AvenirNext-Medium"; fontName = isSubmission ? @"AvenirNext-DemiBold" : @"AvenirNext-Medium";
} else { } else {
fontName = [userDefaults stringForKey:(isSubmission ? @"postfont" : @"commentfont")]; fontName = [userDefaults stringForKey:(isSubmission ? @"postfont" : @"commentfont")];
@ -37,14 +38,14 @@ NSString *slidePostOverrideBodyHtml;
UIFont *font = [UIFont fontWithName:fontName size:fontSize]; UIFont *font = [UIFont fontWithName:fontName size:fontSize];
if (!font){ if (!font) {
font = [UIFont systemFontOfSize:fontSize]; font = [UIFont systemFontOfSize:fontSize];
} }
return font; return font;
} }
+(UIFont *) boldFontOfSize:(CGFloat) size submission:(BOOL) isSubmission willOffset:(BOOL) willOffset { + (UIFont *)boldFontOfSize:(CGFloat)size submission:(BOOL)isSubmission willOffset:(BOOL)willOffset {
UIFont *font = [self fontOfSize:size submission:isSubmission willOffset:willOffset]; UIFont *font = [self fontOfSize:size submission:isSubmission willOffset:willOffset];
if ([font.fontName isEqualToString:[UIFont systemFontOfSize:10].fontName]){ if ([font.fontName isEqualToString:[UIFont systemFontOfSize:10].fontName]){
@ -60,15 +61,15 @@ NSString *slidePostOverrideBodyHtml;
} }
} }
+(UIFont *) italicFontOfSize:(CGFloat) size submission:(BOOL) isSubmission willOffset:(BOOL) willOffset { + (UIFont *)italicFontOfSize:(CGFloat)size submission:(BOOL)isSubmission willOffset:(BOOL)willOffset {
UIFont *font = [self fontOfSize:size submission:isSubmission willOffset:willOffset]; UIFont *font = [self fontOfSize:size submission:isSubmission willOffset:willOffset];
if ([font.fontName isEqualToString:[UIFont systemFontOfSize:10].fontName]){ if ([font.fontName isEqualToString:[UIFont systemFontOfSize:10].fontName]) {
return [UIFont italicSystemFontOfSize:font.pointSize]; return [UIFont italicSystemFontOfSize:font.pointSize];
} else { } else {
UIFontDescriptor *desc = [font.fontDescriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitItalic]; UIFontDescriptor *desc = [font.fontDescriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitItalic];
if (desc == nil){ if (desc == nil) {
return font; return font;
} else { } else {
return [UIFont fontWithDescriptor:desc size: 0]; return [UIFont fontWithDescriptor:desc size: 0];
@ -81,7 +82,7 @@ NSString *slidePostOverrideBodyHtml;
@implementation ColorUtil @implementation ColorUtil
+(UIColor *) accentColorForSub:(NSString *) subreddit{ + (UIColor *)accentColorForSub:(NSString *)subreddit {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSData *colorData = [userDefaults dataForKey:[NSString stringWithFormat:@"accent+%@", subreddit]]; NSData *colorData = [userDefaults dataForKey:[NSString stringWithFormat:@"accent+%@", subreddit]];
UIColor *color = [NSKeyedUnarchiver unarchiveObjectWithData:colorData]; UIColor *color = [NSKeyedUnarchiver unarchiveObjectWithData:colorData];
@ -90,7 +91,7 @@ NSString *slidePostOverrideBodyHtml;
} else { } else {
UIColor *baseAccentColor = [NSKeyedUnarchiver unarchiveObjectWithData:[userDefaults dataForKey:@"accentcolor"]]; UIColor *baseAccentColor = [NSKeyedUnarchiver unarchiveObjectWithData:[userDefaults dataForKey:@"accentcolor"]];
if (baseAccentColor){ if (baseAccentColor) {
return baseAccentColor; return baseAccentColor;
} else { } else {
return [UIColor colorWithRed:0.161 green:0.475 blue:1.0 alpha:1.0]; return [UIColor colorWithRed:0.161 green:0.475 blue:1.0 alpha:1.0];
@ -98,7 +99,7 @@ NSString *slidePostOverrideBodyHtml;
} }
} }
+(UIColor *) fontColorForTheme:(NSString *)theme{ + (UIColor *)fontColorForTheme:(NSString *)theme {
UIColor *fontColor; UIColor *fontColor;
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
@ -142,7 +143,7 @@ NSString *slidePostOverrideBodyHtml;
return fontColor; return fontColor;
} }
+(UIColor *) backgroundColorForTheme:(NSString *) theme{ + (UIColor *)backgroundColorForTheme:(NSString *)theme {
UIColor *backgroundColor; UIColor *backgroundColor;
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
@ -216,7 +217,7 @@ static UIButton *createUndeleteButton(){
%hook UIColor %hook UIColor
%new %new
+(UIColor *) colorWithHex:(NSString *) arg1 { + (UIColor *)colorWithHex:(NSString *)arg1 {
if (!arg1){ if (!arg1){
NSString *firstChar = [arg1 substringToIndex:1]; NSString *firstChar = [arg1 substringToIndex:1];
if ([firstChar isEqualToString:@"#"]){ if ([firstChar isEqualToString:@"#"]){
@ -234,7 +235,7 @@ static UIButton *createUndeleteButton(){
} }
%new %new
-(NSString *) hexString { - (NSString *)hexString {
const CGFloat *components = CGColorGetComponents(self.CGColor); const CGFloat *components = CGColorGetComponents(self.CGColor);
CGFloat r = components[0]; CGFloat r = components[0];
@ -249,32 +250,32 @@ static UIButton *createUndeleteButton(){
%hook CommentDepthCell %hook CommentDepthCell
-(void) doShortClick{ - (void)doShortClick {
%orig; %orig;
[self addUndeleteButtonToMenu]; [self addUndeleteButtonToMenu];
} }
-(void) doLongClick { - (void)doLongClick {
%orig; %orig;
[self addUndeleteButtonToMenu]; [self addUndeleteButtonToMenu];
} }
%new %new
-(void) addUndeleteButtonToMenu{ - (void)addUndeleteButtonToMenu {
NSString *commentBody = [MSHookIvar<id>(self, "comment") body]; NSString *commentBody = [MSHookIvar<id>(self, "comment") body];
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){ if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]) {
id controller = MSHookIvar<id>(self, "parent"); id controller = MSHookIvar<id>(self, "parent");
if (MSHookIvar<id>(controller, "menuCell")){ if (MSHookIvar<id>(controller, "menuCell")) {
UIStackView *menu = MSHookIvar<UIStackView *>(self, "menu"); UIStackView *menu = MSHookIvar<UIStackView *>(self, "menu");
if (![[[[menu arrangedSubviews] lastObject] actionsForTarget:self forControlEvent:UIControlEventTouchUpInside] containsObject:@"handleUndeleteComment:"]){ if (![[[[menu arrangedSubviews] lastObject] actionsForTarget:self forControlEvent:UIControlEventTouchUpInside] containsObject:@"handleUndeleteComment:"]) {
UIButton *undeleteButton = createUndeleteButton(); UIButton *undeleteButton = createUndeleteButton();
[undeleteButton addTarget:self action:@selector(handleUndeleteComment:) forControlEvents:UIControlEventTouchUpInside]; [undeleteButton addTarget:self action:@selector(handleUndeleteComment:) forControlEvents:UIControlEventTouchUpInside];
@ -285,7 +286,7 @@ static UIButton *createUndeleteButton(){
} }
%new %new
-(void) handleUndeleteComment:(id) sender{ - (void)handleUndeleteComment:(id)sender {
[sender setEnabled:NO]; [sender setEnabled:NO];
@ -295,7 +296,7 @@ static UIButton *createUndeleteButton(){
} }
%new %new
-(void) completeUndeleteCommentAction:(NSDictionary *) data{ - (void)completeUndeleteCommentAction:(NSDictionary *)data {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
id textStackDisplayView = MSHookIvar<id>(self, "commentBody"); id textStackDisplayView = MSHookIvar<id>(self, "commentBody");
@ -330,21 +331,21 @@ static UIButton *createUndeleteButton(){
[htmlAttributedString removeAttribute:@"CTForegroundColorFromContext" range:htmlStringRange]; [htmlAttributedString removeAttribute:@"CTForegroundColorFromContext" range:htmlStringRange];
[htmlAttributedString enumerateAttributesInRange:htmlStringRange options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired usingBlock:^(NSDictionary *attributes, NSRange range, BOOL *stop) { [htmlAttributedString enumerateAttributesInRange:htmlStringRange options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired usingBlock:^(NSDictionary *attributes, NSRange range, BOOL *stop) {
for (NSString *key in attributes){ for (NSString *key in attributes) {
if ([(UIColor *) attributes[key] isKindOfClass:[UIColor class]]){ if ([(UIColor *) attributes[key] isKindOfClass:[UIColor class]]) {
UIColor *attrColor = (UIColor *) attributes[key]; UIColor *attrColor = (UIColor *) attributes[key];
if ([[attrColor hexString] isEqualToString:@"#0000FF"]){ if ([[attrColor hexString] isEqualToString:@"#0000FF"]) {
UIFont *tempFont = [UIFont fontWithName:@"Courier" size:font.pointSize]; UIFont *tempFont = [UIFont fontWithName:@"Courier" size:font.pointSize];
[htmlAttributedString setAttributes:@{NSForegroundColorAttributeName: accentColor, NSBackgroundColorAttributeName: [%c(ColorUtil) backgroundColorForTheme:themeName], NSFontAttributeName: (tempFont ? tempFont : font)} range:range]; [htmlAttributedString setAttributes:@{NSForegroundColorAttributeName: accentColor, NSBackgroundColorAttributeName: [%c(ColorUtil) backgroundColorForTheme:themeName], NSFontAttributeName: (tempFont ? tempFont : font)} range:range];
} else if ([[attrColor hexString] isEqualToString:@"#008000"]) { } else if ([[attrColor hexString] isEqualToString:@"#008000"]) {
[htmlAttributedString setAttributes:@{NSForegroundColorAttributeName: fontColor, NSFontAttributeName:font} range:range]; [htmlAttributedString setAttributes:@{NSForegroundColorAttributeName: fontColor, NSFontAttributeName:font} range:range];
} }
} else if ([(NSURL *) attributes[key] isKindOfClass:[NSURL class]]){ } else if ([(NSURL *) attributes[key] isKindOfClass:[NSURL class]]) {
NSURL *attrUrl = (NSURL *)attributes[key]; NSURL *attrUrl = (NSURL *)attributes[key];
if (([userDefaults objectForKey:@"ENLARGE_LINKS"] == nil) ? YES : [userDefaults boolForKey:@"ENLARGE_LINKS"]){ if (([userDefaults objectForKey:@"ENLARGE_LINKS"] == nil) ? YES : [userDefaults boolForKey:@"ENLARGE_LINKS"]) {
[htmlAttributedString addAttribute:NSFontAttributeName value:[%c(FontGenerator) boldFontOfSize:18 submission:NO willOffset:YES] range:range]; [htmlAttributedString addAttribute:NSFontAttributeName value:[%c(FontGenerator) boldFontOfSize:18 submission:NO willOffset:YES] range:range];
} }
@ -360,7 +361,7 @@ static UIButton *createUndeleteButton(){
}]; }];
[htmlAttributedString beginEditing]; [htmlAttributedString beginEditing];
[htmlAttributedString enumerateAttribute:NSFontAttributeName inRange:NSMakeRange(0, [htmlAttributedString length]) options:0 usingBlock:^(id value, NSRange range, BOOL *stop){ [htmlAttributedString enumerateAttribute:NSFontAttributeName inRange:NSMakeRange(0, [htmlAttributedString length]) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) {
UIFont *attrFont = (UIFont *)value; UIFont *attrFont = (UIFont *)value;
@ -401,7 +402,7 @@ static UIButton *createUndeleteButton(){
%hook RSubmission %hook RSubmission
-(id) author{ - (id)author {
if (shouldSlideOverridePostInfo){ if (shouldSlideOverridePostInfo){
return slidePostOverrideAuthor; return slidePostOverrideAuthor;
} else { } else {
@ -409,7 +410,7 @@ static UIButton *createUndeleteButton(){
} }
} }
-(id) htmlBody{ - (id)htmlBody {
if (shouldSlideOverridePostInfo){ if (shouldSlideOverridePostInfo){
return slidePostOverrideBodyHtml; return slidePostOverrideBodyHtml;
} }
@ -424,7 +425,7 @@ static UIButton *createUndeleteButton(){
%hook CommentViewController %hook CommentViewController
%property(strong, nonatomic) UIButton *undeleteButton; %property(strong, nonatomic) UIButton *undeleteButton;
-(void) viewDidLoad { - (void)viewDidLoad {
%orig; %orig;
shouldSlideOverridePostInfo = NO; shouldSlideOverridePostInfo = NO;
@ -437,17 +438,17 @@ static UIButton *createUndeleteButton(){
[self setUndeleteButton:undeleteButton]; [self setUndeleteButton:undeleteButton];
} }
-(void) viewDidLayoutSubviews{ - (void)viewDidLayoutSubviews {
%orig; %orig;
if ([self undeleteButton]){ if ([self undeleteButton]) {
if ([self shouldAddUndeleteButtonToToolbar]){ if ([self shouldAddUndeleteButtonToToolbar]) {
[self addUndeleteButtonToToolbar]; [self addUndeleteButtonToToolbar];
} }
} }
} }
-(void) loadAll:(id) arg1{ - (void)loadAll:(id)arg1 {
%orig; %orig;
if ([self undeleteButton]){ if ([self undeleteButton]){
@ -458,14 +459,14 @@ static UIButton *createUndeleteButton(){
} }
%new %new
-(BOOL) shouldAddUndeleteButtonToToolbar{ - (BOOL)shouldAddUndeleteButtonToToolbar {
id post = MSHookIvar<id>(self, "submission"); id post = MSHookIvar<id>(self, "submission");
if ([post isSelf]){ if ([post isSelf]) {
NSString *postBody = [post body]; NSString *postBody = [post body];
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){ if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]) {
return YES; return YES;
} }
} }
@ -474,23 +475,23 @@ static UIButton *createUndeleteButton(){
} }
%new %new
-(void) addUndeleteButtonToToolbar{ - (void)addUndeleteButtonToToolbar {
UIToolbar *toolbar = [[self navigationController] toolbar]; UIToolbar *toolbar = [[self navigationController] toolbar];
NSMutableArray *toolbarItems = [[toolbar items] mutableCopy]; NSMutableArray *toolbarItems = [[toolbar items] mutableCopy];
UIView *firstView = [toolbarItems[0] customView]; UIView *firstView = [toolbarItems[0] customView];
if (firstView){ if (firstView) {
UIColor *tintColor = [toolbar tintColor]; UIColor *tintColor = [toolbar tintColor];
UIButton *undeleteButton = [self undeleteButton]; UIButton *undeleteButton = [self undeleteButton];
[undeleteButton setTintColor:tintColor]; [undeleteButton setTintColor:tintColor];
if ([firstView isMemberOfClass:[UIView class]]){ if ([firstView isMemberOfClass:[UIView class]]) {
if (![undeleteButton isDescendantOfView:firstView]){ if (![undeleteButton isDescendantOfView:firstView]){
[firstView addSubview:undeleteButton]; [firstView addSubview:undeleteButton];
[undeleteButton setFrame:firstView.bounds]; [undeleteButton setFrame:firstView.bounds];
} }
} else if ([firstView isMemberOfClass:[UIButton class]] && undeleteButton != firstView){ } else if ([firstView isMemberOfClass:[UIButton class]] && undeleteButton != firstView) {
UIBarButtonItem *undeleteItem = [[UIBarButtonItem alloc] initWithCustomView:undeleteButton]; UIBarButtonItem *undeleteItem = [[UIBarButtonItem alloc] initWithCustomView:undeleteButton];
[toolbarItems insertObject:toolbarItems[1] atIndex:0]; [toolbarItems insertObject:toolbarItems[1] atIndex:0];
@ -501,7 +502,7 @@ static UIButton *createUndeleteButton(){
} }
%new %new
-(void) handleUndeletePost:(id) sender{ - (void)handleUndeletePost:(id)sender {
shouldSlideOverridePostInfo = YES; shouldSlideOverridePostInfo = YES;
[sender setEnabled:NO]; [sender setEnabled:NO];
@ -510,7 +511,7 @@ static UIButton *createUndeleteButton(){
} }
%new %new
-(void) completeUndeletePostAction:(NSDictionary *) data{ - (void)completeUndeletePostAction:(NSDictionary *)data {
slidePostOverrideAuthor = data[@"author"]; slidePostOverrideAuthor = data[@"author"];
slidePostOverrideBodyHtml = [%c(MMMarkdown) HTMLStringWithMarkdown:data[@"body"] extensions:MMMarkdownExtensionsGitHubFlavored error:nil]; slidePostOverrideBodyHtml = [%c(MMMarkdown) HTMLStringWithMarkdown:data[@"body"] extensions:MMMarkdownExtensionsGitHubFlavored error:nil];
@ -529,26 +530,13 @@ static void loadPrefs(){
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"]; NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
if (prefs){ if (prefs){
isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES;
if ([prefs objectForKey:@"isSlideEnabled"] != nil){ isSlideEnabled = [prefs objectForKey:@"isSlideEnabled"] ? [[prefs objectForKey:@"isSlideEnabled"] boolValue] : YES;
isSlideEnabled = [[prefs objectForKey:@"isSlideEnabled"] boolValue]; isTFDeletedOnly = [prefs objectForKey:@"isTFDeletedOnly"] ? [[prefs objectForKey:@"isTFDeletedOnly"] boolValue] : YES;
} else { pushshiftRequestTimeoutValue = [prefs objectForKey:@"requestTimeoutValue"] ? [[prefs objectForKey:@"requestTimeoutValue"] doubleValue] : 10;
isSlideEnabled = YES;
}
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil){
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
} else {
isTFDeletedOnly = YES;
}
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
} else {
pushshiftRequestTimeoutValue = 10;
}
} else { } else {
isEnabled = YES;
isSlideEnabled = YES; isSlideEnabled = YES;
isTFDeletedOnly = YES; isTFDeletedOnly = YES;
pushshiftRequestTimeoutValue = 10; pushshiftRequestTimeoutValue = 10;
@ -566,9 +554,9 @@ static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStrin
NSString* processName = [[NSProcessInfo processInfo] processName]; NSString* processName = [[NSProcessInfo processInfo] processName];
if ([processName isEqualToString:@"Slide for Reddit"]){ if ([processName isEqualToString:@"Slide for Reddit"]){
if (isSlideEnabled){ if (isSlideEnabled && isEnabled){
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
%init(Slide, CommentDepthCell = objc_getClass("Slide_for_Reddit.CommentDepthCell"), RSubmission = objc_getClass("Slide_for_Reddit.RSubmission"), CommentViewController = objc_getClass("Slide_for_Reddit.CommentViewController")); %init(Slide, CommentDepthCell = objc_getClass("Slide_for_Reddit.CommentDepthCell"), RSubmission = objc_getClass("Slide_for_Reddit.RSubmission"), CommentViewController = objc_getClass("Slide_for_Reddit.CommentViewController"));
} }

View File

@ -1,7 +1,9 @@
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
@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; + (BOOL)shouldShowUndeleteButtonWithInfo:(NSString *)content isDeletedOnly:(BOOL)isDeletedOnly;
@end @end

View File

@ -3,7 +3,7 @@
@implementation TFHelper @implementation TFHelper
+(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 {
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSOperationQueue *queue = [[NSOperationQueue alloc] init]; NSOperationQueue *queue = [[NSOperationQueue alloc] init];