|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702 |
-
- #import "Reddit.h"
- #import "assets/TFHelper.h"
-
- static BOOL isEnabled;
- static BOOL isRedditEnabled;
- static BOOL isTFDeletedOnly;
- static CGFloat pushshiftRequestTimeoutValue;
-
- int firstVersionPart = 2020;
- int secondVersionPart = 0;
-
- %group Reddit_v4_current
-
- %hook CommentTreeNode
- %property(assign,nonatomic)id commentTreeHeaderNode;
- %property(assign,nonatomic)id commentTreeCommandBarNode;
- %end
-
- %hook CommentTreeHeaderView
-
- - (void)layoutSubviews {
- %orig;
-
- [[self commentTreeNode] setCommentTreeHeaderNode:self];
- }
-
- %end
-
- %hook CommentTreeHeaderNode
-
- - (void)didLoad {
- %orig;
-
- [[self commentTreeNode] setCommentTreeHeaderNode:self];
- }
- %end
-
-
- %hook CommentTreeCommandBarNode
-
- - (void)didLoad {
- %orig;
-
- [[self commentTreeNode] setCommentTreeCommandBarNode:self];
- }
- %end
-
-
- %hook CommentActionSheetViewController
-
- - (void)setItems:(id)arg1 {
-
- NSString *author = [[self comment] author];
-
- if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:author isDeletedOnly:isTFDeletedOnly]) {
-
- UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
-
- CGSize existingImageSize = [[arg1[0] leftIconImage] size];
- CGFloat scale = origImage.size.width / existingImageSize.width;
-
- UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
-
- id undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self comment]];
-
- arg1 = [arg1 arrayByAddingObject:undeleteItem];
-
- [undeleteItem release];
- }
-
- %orig;
- }
-
- - (void)handleDidSelectActionSheetItem:(id)arg1 {
- %orig;
-
- if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]) {
-
- [self dismissViewControllerAnimated:YES completion:nil];
-
- id commentTreeNode = [self commentTreeNode];
- Comment *comment = [commentTreeNode comment];
-
- [%c(TFHelper) getUndeleteDataWithID:[[comment pk] componentsSeparatedByString:@"_"][1] isComment:YES timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeleteCommentAction:)];
- }
- }
-
- %new
- - (void)completeUndeleteCommentAction:(NSDictionary *)data {
-
- id commentTreeNode = [self commentTreeNode];
- Comment *comment = [commentTreeNode comment];
-
- NSString *author = data[@"author"];
- NSString *body = data[@"body"];
-
- NSMutableAttributedString *bodyMutableAttributedText;
-
- id themeManager;
- id isNightMode;
- id textColor;
-
- if (firstVersionPart == 2020) {
- if (secondVersionPart <= 40) {
- AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
- AppSettings *appSettings = [%c(AppSettings) sharedSettings];
- AccountManager *accountManager = secondVersionPart >= 29 ? [appDelegate accountManager] : [%c(AccountManager) sharedManager];
- themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:appSettings];
- isNightMode = [[accountManager defaults] objectForKey:@"kUseNightKey"];
-
- if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"13.0") && [appSettings isAutoDarkModeEnabled]) {
-
- NSInteger sysInterfaceStyle = [[UITraitCollection _currentTraitCollection] userInterfaceStyle];
-
- if (sysInterfaceStyle == UIUserInterfaceStyleDark){
- textColor = [[themeManager darkTheme] bodyTextColor];
- } else {
- textColor = [[themeManager lightTheme] bodyTextColor];
- }
-
- } else {
-
- if (isNightMode) {
- textColor = [[themeManager darkTheme] bodyTextColor];
- } else {
- textColor = [[themeManager lightTheme] bodyTextColor];
- }
- }
-
- [themeManager release];
- } else {
- RUIThemeGuidance *themeGuidance = [%c(RUIThemeGuidance) sharedGuidance];
- textColor = [[themeGuidance currentTheme] bodyTextColor];
- }
-
- } else {
-
- if (secondVersionPart >= 45) {
- themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
- isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
-
- if (isNightMode) {
- textColor = [[themeManager darkTheme] bodyTextColor];
- } else {
- textColor = [[themeManager lightTheme] bodyTextColor];
- }
-
- [themeManager release];
-
- } else if (secondVersionPart >= 37) {
- themeManager = [[%c(ThemeManager) alloc] initWithTraitCollection:nil appSettings:[%c(AppSettings) sharedSettings]];
- isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
-
- if (isNightMode) {
- textColor = [[themeManager nightTheme] bodyTextColor];
- } else {
- textColor = [[themeManager dayTheme] bodyTextColor];
- }
-
- [themeManager release];
-
- } else {
- themeManager = [%c(ThemeManager) sharedManager];
- isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
-
- if (isNightMode) {
- textColor = [[themeManager nightTheme] bodyTextColor];
- } else {
- textColor = [[themeManager dayTheme] bodyTextColor];
- }
- }
- }
-
- bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
-
- [bodyMutableAttributedText beginEditing];
- [bodyMutableAttributedText enumerateAttribute:NSForegroundColorAttributeName inRange:NSMakeRange(0, bodyMutableAttributedText.length) options:0 usingBlock:^(id _Nullable value, NSRange range, BOOL * _Nonnull stop) {
- [bodyMutableAttributedText removeAttribute:NSForegroundColorAttributeName range:range];
- [bodyMutableAttributedText addAttribute:NSForegroundColorAttributeName value:textColor range:range];
- }];
- [bodyMutableAttributedText endEditing];
-
- [comment setAuthor:author];
- [comment setBodyText:body];
- [comment setBodyRichTextAttributed:bodyMutableAttributedText];
-
- if (secondVersionPart <= 39) {
- [comment setBodyAttributedText:bodyMutableAttributedText];
- }
-
- [[commentTreeNode commentTreeHeaderNode] updateContentViewsForData:comment];
-
- [bodyMutableAttributedText release];
- }
-
- %end
-
-
- %hook PostDetailViewController
- %property(strong,nonatomic) id feedPostTextWithThumbnailNode;
- %property(strong,nonatomic) id feedPostDetailCellNode;
- %end
-
- %hook FeedPostDetailCellNode
-
- - (void)didLoad {
- %orig;
-
- [[[self delegate] viewController] setFeedPostDetailCellNode:self];
- }
- %end
-
- %hook PostActionSheetViewController
-
- - (void)setItems:(id)arg1 {
-
- Post *post = [self post];
- NSString *author = [post author];
-
- if ([post isSelfPost]) {
- if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:author isDeletedOnly:isTFDeletedOnly]) {
-
- UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
-
- CGSize existingImageSize = [[arg1[0] leftIconImage] size];
- CGFloat scale = origImage.size.width / existingImageSize.width;
-
- UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
-
- id undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self post]];
-
- arg1 = [arg1 arrayByAddingObject:undeleteItem];
-
- [undeleteItem release];
- }
- }
-
- %orig;
- }
-
-
- - (void)handleDidSelectActionSheetItem:(id)arg1 {
- %orig;
-
- if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]) {
-
- [self dismissViewControllerAnimated:YES completion:nil];
-
- Post *post = [self post];
-
- if ([post isSelfPost]){
-
- [%c(TFHelper) getUndeleteDataWithID:[[post pk] componentsSeparatedByString:@"_"][1] isComment:NO timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeletePostAction:)];
- }
- }
- }
-
- %new
- - (void)completeUndeletePostAction:(NSDictionary *)data {
- Post *post = [self post];
-
- NSString *author = data[@"author"];
- NSString *body = data[@"body"];
-
- id themeManager;
- id isNightMode;
- id textColor;
-
- if (firstVersionPart == 2020) {
-
- if (secondVersionPart <= 40) {
-
- AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
- AccountManager *accountManager = secondVersionPart >= 29 ? [appDelegate accountManager] : [%c(AccountManager) sharedManager];
- themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
- isNightMode = [[accountManager defaults] objectForKey:@"kUseNightKey"];
-
- if (isNightMode) {
- textColor = [[themeManager darkTheme] bodyTextColor];
- } else {
- textColor = [[themeManager lightTheme] bodyTextColor];
- }
-
- [themeManager release];
- } else {
- RUIThemeGuidance *themeGuidance = [%c(RUIThemeGuidance) sharedGuidance];
- textColor = [[themeGuidance currentTheme] bodyTextColor];
- }
-
- } else {
-
- if (secondVersionPart >= 45) {
- themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
- isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
-
- if (isNightMode) {
- textColor = [[themeManager darkTheme] bodyTextColor];
- } else {
- textColor = [[themeManager lightTheme] bodyTextColor];
- }
-
- [themeManager release];
-
- } else if (secondVersionPart >= 37) {
- themeManager = [[%c(ThemeManager) alloc] initWithTraitCollection:nil appSettings:[%c(AppSettings) sharedSettings]];
- isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
-
- if (isNightMode) {
- textColor = [[themeManager nightTheme] bodyTextColor];
- } else {
- textColor = [[themeManager dayTheme] bodyTextColor];
- }
-
- [themeManager release];
-
- } else {
- themeManager = [%c(ThemeManager) sharedManager];
- isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
-
- if (isNightMode) {
- textColor = [[themeManager nightTheme] bodyTextColor];
- } else {
- textColor = [[themeManager dayTheme] bodyTextColor];
- }
- }
- }
-
- NSMutableAttributedString *bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
-
- [bodyMutableAttributedText beginEditing];
- [bodyMutableAttributedText enumerateAttribute:NSForegroundColorAttributeName inRange:NSMakeRange(0, bodyMutableAttributedText.length) options:0 usingBlock:^(id _Nullable value, NSRange range, BOOL * _Nonnull stop) {
- [bodyMutableAttributedText removeAttribute:NSForegroundColorAttributeName range:range];
- [bodyMutableAttributedText addAttribute:NSForegroundColorAttributeName value:textColor range:range];
- }];
- [bodyMutableAttributedText endEditing];
-
- [post setSelfText:body];
- [post setAuthor:author];
- [post setSelfPostRichTextAttributed:bodyMutableAttributedText];
- [post setPreviewFeedPostTextString:bodyMutableAttributedText];
-
- if (firstVersionPart == 2020) {
- [[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] configureSelfTextNode];
- } else {
- if (secondVersionPart >= 44) {
- [[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] configureSelfTextNode];
- } else if (secondVersionPart >= 38) {
- [[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] configureSelfTextNode];
- } else {
- [[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] configureSelfTextNode];
- [[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] titleNode] configureNodes];
- }
- }
-
- [bodyMutableAttributedText release];
- }
-
- %end
-
- %end
-
-
- %group Reddit_v4_ios10
-
- %hook CommentsViewController
-
- %new
- - (void)updateComments {
- [self reloadCommentsWithNewCommentsHighlight:NO autoScroll:NO animated:NO];
- }
-
- %new
- - (void)updatePostText {
-
- if (secondVersionPart >= 2){
- [self reloadPostSection:YES];
- } else {
- [self feedPostViewDidUpdatePost:[self postData] shouldReloadFeed:NO];
- }
- }
-
- %end
-
- %hook CommentActionSheetViewController
-
- - (void)setItems:(id)arg1 {
-
- NSString *author = [[self comment] author];
-
- if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:author isDeletedOnly:isTFDeletedOnly]) {
-
- UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
-
- CGSize existingImageSize = [[arg1[0] leftIconImage] size];
- CGFloat scale = origImage.size.width / existingImageSize.width;
-
- UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
-
- id undeleteItem;
-
- if (secondVersionPart >= 18) {
- undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self comment]];
- } else {
- undeleteItem = [[%c(ActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self comment]];
- }
-
- arg1 = [arg1 arrayByAddingObject:undeleteItem];
-
- [undeleteItem release];
- }
-
- %orig;
- }
-
- // >= 4.21
- - (void)handleDidSelectActionSheetItem:(id)arg1 {
- %orig;
-
- if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]) {
-
- [self dismissViewControllerAnimated:YES completion:nil];
-
- Comment *comment = [self comment];
-
- [%c(TFHelper) getUndeleteDataWithID:[[comment pk] componentsSeparatedByString:@"_"][1] isComment:YES timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeleteCommentAction:)];
- }
- }
-
- // <= 4.20
- - (void)actionSheetViewController:(id)arg1 didSelectItem:(id)arg2 {
- %orig;
-
- if ([[arg2 identifier] isEqualToString:@"undeleteItemIdentifier"]){
-
- [self dismissViewControllerAnimated:YES completion:nil];
-
- Comment *comment = [self comment];
-
- [%c(TFHelper) getUndeleteDataWithID:[[comment pk] componentsSeparatedByString:@"_"][1] isComment:YES timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeleteCommentAction:)];
- }
- }
-
- %new
- - (void)completeUndeleteCommentAction:(NSDictionary *)data {
-
- Comment *comment = [self comment];
-
- NSString *body = data[@"body"];
-
- NSMutableAttributedString *bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
-
- [comment setAuthor:data[@"author"]];
- [comment setBodyText:body];
- [comment setBodyAttributedText:bodyMutableAttributedText];
-
- if (secondVersionPart >= 12) {
- [comment setBodyRichTextAttributed:bodyMutableAttributedText];
- }
-
- [[self commentActionSheetDelegate] updateComments];
-
- [bodyMutableAttributedText release];
- }
- %end
-
-
- %hook PostActionSheetViewController
-
- - (void)setItems:(id)arg1{
-
- Post *post = [self post];
- NSString *author = [post author];
-
- if ([post isSelfPost]) {
- if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:author isDeletedOnly:isTFDeletedOnly]) {
-
- UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
-
- CGSize existingImageSize = [[arg1[0] leftIconImage] size];
- CGFloat scale = origImage.size.width / existingImageSize.width;
-
- UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
-
- id undeleteItem;
-
- if (secondVersionPart >= 18) {
- undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self post]];
- } else {
- undeleteItem = [[%c(ActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self post]];
- }
-
- arg1 = [arg1 arrayByAddingObject:undeleteItem];
-
- [undeleteItem release];
- }
- }
-
- %orig;
- }
-
- // >= 4.21
- - (void)handleDidSelectActionSheetItem:(id)arg1 {
- %orig;
-
- if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]) {
-
- [self dismissViewControllerAnimated:YES completion:nil];
-
- Post *post = [self post];
-
- if ([post isSelfPost]) {
- [%c(TFHelper) getUndeleteDataWithID:[[post pk] componentsSeparatedByString:@"_"][1] isComment:NO timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeletePostAction:)];
- }
- }
- }
-
- // <= 4.20
- - (void)actionSheetViewController:(id)arg1 didSelectItem:(id)arg2 {
- %orig;
-
- if ([[arg2 identifier] isEqualToString:@"undeleteItemIdentifier"]) {
-
- [self dismissViewControllerAnimated:YES completion:nil];
-
- Post *post = [self post];
-
- if ([post isSelfPost]){
-
- [%c(TFHelper) getUndeleteDataWithID:[[post pk] componentsSeparatedByString:@"_"][1] isComment:NO timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeletePostAction:)];
- }
- }
- }
-
- %new
- - (void)completeUndeletePostAction:(NSDictionary *)data {
-
- Post *post = [self post];
-
- NSString *body = data[@"body"];
-
- NSMutableAttributedString *bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
-
- [post setAuthor:data[@"author"]];
- [post setSelfText:body];
- [post setSelfTextAttributed:bodyMutableAttributedText];
-
- if (secondVersionPart >= 8) {
- [post setSelfPostRichTextAttributed:bodyMutableAttributedText];
- }
-
- if (secondVersionPart >= 15) {
- [post setPreviewFeedPostTextString:bodyMutableAttributedText];
- }
-
- [[self postActionSheetDelegate] updatePostText];
-
- [bodyMutableAttributedText release];
- }
-
- %end
-
- %end
-
-
- //outdated and unchanged from first version of this tweak...
- //TODO: move button to menu, add post support, make async requests once I feel like doing it
- %group Reddit_v3
-
- %hook CommentView
-
- %new
- -(void) buttonAction {
-
- id commentsViewController = [self delegate];
- id comment = [self comment];
-
- NSError* error;
-
- NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
- [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/comment/?ids=%@&fields=author,body",[comment pkWithoutPrefix]]]];
- [request setHTTPMethod:@"GET"];
-
- NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error];
-
- NSString *author = @"[author]";
- NSString *body = @"[body]";
-
- if (data != nil && error == nil){
-
- id jsonData = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
-
- author = [[jsonData objectForKey:@"data"][0] objectForKey:@"author"];
- body = [[jsonData objectForKey:@"data"][0] objectForKey:@"body"];
-
- if ([body isEqualToString:@"[deleted]"] || [body isEqualToString:@"[removed]"]){
- body = @"[comment was unable to be archived]";
- }
-
- } else if (error != nil || data == nil){
- body = @"[an error occured]";
- }
-
- [comment setValue:author forKey:@"author"];
-
- [comment setValue:[%c(MarkDownParser) attributedStringFromMarkdownString: body] forKey:@"bodyAttributedText"];
- [comment setValue:body forKey:@"bodyText"];
-
- [commentsViewController reloadCommentsWithNewCommentsHighlight:NO autoScroll:NO animated:NO];
- }
-
-
- -(id) initWithFrame:(id)arg1{
- id orig = %orig;
- id commandView = [self commandView];
-
- UIButton *undeleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
- [undeleteButton addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
-
- UIImage* undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
-
- [undeleteButton setImage:undeleteImage forState:UIControlStateNormal];
-
- [commandView setUndeleteButton:undeleteButton];
- [commandView addSubview:undeleteButton];
-
- return orig;
- }
-
-
- %end
-
-
- %hook CommentCommandView
- %property (assign, nonatomic) id undeleteButton;
-
- -(void) layoutSubviews{
- %orig;
-
- UIButton *button = [self undeleteButton];
-
- button.frame = CGRectMake([[self overflowButton ] frame].origin.x - 32, 0, 32, 32);
- }
- %end
-
- %end
-
-
- static void loadPrefs(){
- NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
-
- if (prefs){
- isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES;
- isRedditEnabled = [prefs objectForKey:@"isRedditEnabled"] ? [[prefs objectForKey:@"isRedditEnabled"] boolValue] : YES;
- isTFDeletedOnly = [prefs objectForKey:@"isTFDeletedOnly"] ? [[prefs objectForKey:@"isTFDeletedOnly"] boolValue] : YES;
- pushshiftRequestTimeoutValue = [prefs objectForKey:@"requestTimeoutValue"] ? [[prefs objectForKey:@"requestTimeoutValue"] doubleValue] : 10;
- } else {
- isEnabled = YES;
- isRedditEnabled = YES;
- isTFDeletedOnly = YES;
- pushshiftRequestTimeoutValue = 10;
- }
- }
-
- static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
- loadPrefs();
- }
-
-
- %ctor{
- loadPrefs();
-
- NSString* processName = [[NSProcessInfo processInfo] processName];
-
- @try {
- NSArray *redditVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."];
-
- firstVersionPart = [redditVersion[0] intValue];
- secondVersionPart = [redditVersion[1] intValue];
- }
- @catch (NSException *exc) {
- firstVersionPart = 2020;
- secondVersionPart = 0;
- }
-
- if ([processName isEqualToString:@"Reddit"]){
- if (isRedditEnabled && isEnabled) {
-
- CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
-
- if (firstVersionPart == 4 || firstVersionPart == 2020) {
- if (secondVersionPart <= 32 && firstVersionPart != 2020) {
- %init(Reddit_v4_ios10);
- } else{
- %init(Reddit_v4_current);
- }
- } else if (firstVersionPart == 3) {
- %init(Reddit_v3);
- }
- }
- }
- }
|