Browse Source

Add universal visibility option

master
lint 4 years ago
parent
commit
0fef021993
7 changed files with 163 additions and 162 deletions
  1. +3
    -45
      prefs/Resources/Root.plist
  2. +6
    -6
      tweak/AlienBlue.xm
  3. +27
    -23
      tweak/Apollo.xm
  4. +12
    -12
      tweak/BaconReader.xm
  5. +32
    -20
      tweak/Narwhal.xm
  6. +73
    -46
      tweak/Reddit.xm
  7. +10
    -10
      tweak/Slide.xm

+ 3
- 45
prefs/Resources/Root.plist View File

<key>cell</key> <key>cell</key>
<string>PSGroupCell</string> <string>PSGroupCell</string>
<key>footerText</key> <key>footerText</key>
<string>On apps that have an eye button rather than an option in the menu, enable or disable that button from appearing on only deleted comments/posts.</string>
<string>Enable or disable undelete option appearing only on deleted/removed comments and posts.</string>
<key>label</key> <key>label</key>
<string>visibility</string> <string>visibility</string>
</dict> </dict>
<key>defaults</key> <key>defaults</key>
<string>com.lint.undelete.prefs</string> <string>com.lint.undelete.prefs</string>
<key>key</key> <key>key</key>
<string>isApolloDeletedCommentsOnly</string>
<string>isTFDeletedOnly</string>
<key>label</key> <key>label</key>
<string>Apollo | Deleted only</string>
</dict>
<dict>
<key>PostNotification</key>
<string>com.lint.undelete.prefs.changed</string>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<true/>
<key>defaults</key>
<string>com.lint.undelete.prefs</string>
<key>key</key>
<string>isAlienBlueDeletedOnly</string>
<key>label</key>
<string>Alien Blue | Deleted only</string>
</dict>
<dict>
<key>PostNotification</key>
<string>com.lint.undelete.prefs.changed</string>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<true/>
<key>defaults</key>
<string>com.lint.undelete.prefs</string>
<key>key</key>
<string>isSlideDeletedOnly</string>
<key>label</key>
<string>Slide | Deleted only</string>
</dict>
<dict>
<key>PostNotification</key>
<string>com.lint.undelete.prefs.changed</string>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<true/>
<key>defaults</key>
<string>com.lint.undelete.prefs</string>
<key>key</key>
<string>isBaconReaderDeletedOnly</string>
<key>label</key>
<string>BaconReader | Deleted only</string>
<string>Deleted comments/posts only</string>
</dict> </dict>
<dict> <dict>
<key>cell</key> <key>cell</key>

+ 6
- 6
tweak/AlienBlue.xm View File

#import "assets/MMMarkdown.h" #import "assets/MMMarkdown.h"


static BOOL isAlienBlueEnabled; static BOOL isAlienBlueEnabled;
static BOOL isAlienBlueDeletedOnly;
static BOOL isTFDeletedOnly;
static CGFloat pushshiftRequestTimeoutValue; static CGFloat pushshiftRequestTimeoutValue;


%group AlienBlue %group AlienBlue
body = [[(CommentNode *)arg1 comment] body]; body = [[(CommentNode *)arg1 comment] body];
} }
if ((isAlienBlueDeletedOnly && ([body isEqualToString:@"[deleted]"] || [body isEqualToString:@"[removed]"])) || !isAlienBlueDeletedOnly) {
if ((isTFDeletedOnly && ([body isEqualToString:@"[deleted]"] || [body isEqualToString:@"[removed]"])) || !isTFDeletedOnly) {
CGSize refSize = [[self buttons][0] frame].size; CGSize refSize = [[self buttons][0] frame].size;


isAlienBlueEnabled = YES; isAlienBlueEnabled = YES;
} }
if ([prefs objectForKey:@"isAlienBlueDeletedOnly"] != nil){
isAlienBlueDeletedOnly = [[prefs objectForKey:@"isAlienBlueDeletedOnly"] boolValue];
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil){
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
} else { } else {
isAlienBlueDeletedOnly = YES;
isTFDeletedOnly = YES;
} }
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){ if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
} else { } else {
isAlienBlueEnabled = YES; isAlienBlueEnabled = YES;
isAlienBlueDeletedOnly = YES;
isTFDeletedOnly = YES;
pushshiftRequestTimeoutValue = 10; pushshiftRequestTimeoutValue = 10;
} }
} }

+ 27
- 23
tweak/Apollo.xm View File

#import "Apollo.h" #import "Apollo.h"
static BOOL isApolloDeletedCommentsOnly;
static BOOL isTFDeletedOnly;
static BOOL isApolloEnabled; static BOOL isApolloEnabled;
static CGFloat pushshiftRequestTimeoutValue; static CGFloat pushshiftRequestTimeoutValue;
id commentBody = [MSHookIvar<id>(self, "comment") body]; id commentBody = [MSHookIvar<id>(self, "comment") body];
if ((isApolloDeletedCommentsOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isApolloDeletedCommentsOnly) {
if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) {
CGFloat imageSize = 20.0f; CGFloat imageSize = 20.0f;
[bodyNode setAttributedString:[%c(MarkdownRenderer) attributedStringFromMarkdown:body withAttributes:apolloBodyAttributes]]; [bodyNode setAttributedString:[%c(MarkdownRenderer) attributedStringFromMarkdown:body withAttributes:apolloBodyAttributes]];
[sender setEnabled:YES]; [sender setEnabled:YES];
}]; }];
} }
-(void) didLoad{ -(void) didLoad{
%orig; %orig;
id post = MSHookIvar<id>(self, "link");
id postBody = [post selfText];
if ([MSHookIvar<id>(self, "link") isSelfPost]){
CGFloat imageSize = 20.0f;
if ([post isSelfPost]){
if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) {
UIButton *undeleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
[undeleteButton addTarget:self action:@selector(didTapUndeleteButton:) forControlEvents:UIControlEventTouchUpInside];
UIImage* undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
[undeleteButton setImage:undeleteImage forState:UIControlStateNormal];
undeleteButton.frame = CGRectMake(0, 0, imageSize, imageSize);
CGFloat imageSize = 20.0f;
[[self view] addSubview:undeleteButton];
[self setUndeleteButton:undeleteButton];
UIButton *undeleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
[undeleteButton addTarget:self action:@selector(didTapUndeleteButton:) forControlEvents:UIControlEventTouchUpInside];
UIImage* undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
[undeleteButton setImage:undeleteImage forState:UIControlStateNormal];
undeleteButton.frame = CGRectMake(0, 0, imageSize, imageSize);
[[self view] addSubview:undeleteButton];
[self setUndeleteButton:undeleteButton];
}
} }
} }
[[self undeleteButton] setFrame:CGRectMake(buttonXPos, centerHeight - (imageSize / 2), imageSize, imageSize)]; [[self undeleteButton] setFrame:CGRectMake(buttonXPos, centerHeight - (imageSize / 2), imageSize, imageSize)];
} }
} }
%end %end
%end %end
isApolloEnabled = YES; isApolloEnabled = YES;
} }
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil) {
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
} else { } else {
pushshiftRequestTimeoutValue = 10;
isTFDeletedOnly = YES;
} }
if ([prefs objectForKey:@"isApolloDeletedCommentsOnly"] != nil) {
isApolloDeletedCommentsOnly = [[prefs objectForKey:@"isApolloDeletedCommentsOnly"] boolValue];
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
} else { } else {
isApolloDeletedCommentsOnly = YES;
pushshiftRequestTimeoutValue = 10;
} }
} else { } else {
isApolloEnabled = YES; isApolloEnabled = YES;
isTFDeletedOnly = YES;
pushshiftRequestTimeoutValue = 10; pushshiftRequestTimeoutValue = 10;
isApolloDeletedCommentsOnly = YES;
} }
} }

+ 12
- 12
tweak/BaconReader.xm View File

#import "assets/MMMarkdown.h" #import "assets/MMMarkdown.h"
static BOOL isBaconReaderEnabled; static BOOL isBaconReaderEnabled;
static BOOL isBaconReaderDeletedOnly;
static BOOL isTFDeletedOnly;
static CGFloat pushshiftRequestTimeoutValue; static CGFloat pushshiftRequestTimeoutValue;
%group BaconReader %group BaconReader
UIAlertAction *undeleteAction; UIAlertAction *undeleteAction;
if (tfCommentCellView){ if (tfCommentCellView){
undeleteAction = [UIAlertAction actionWithTitle:@"TF Did That Say?" style:nil 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:nil handler:^(UIAlertAction* action){[tfStoryController handleUndeletePostAction];}];
undeleteAction = [UIAlertAction actionWithTitle:@"TF Did That Say?" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){[tfStoryController handleUndeletePostAction];}];
} }
[arg1 addAction:undeleteAction]; [arg1 addAction:undeleteAction];
NSString *commentBody = [[arg1 comment] body]; NSString *commentBody = [[arg1 comment] body];
if ((isBaconReaderDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isBaconReaderDeletedOnly) {
if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) {
shouldHaveBRUndeleteAction = YES; shouldHaveBRUndeleteAction = YES;
tfCommentCellView = arg1; tfCommentCellView = arg1;
tfStoryController = self; tfStoryController = self;
if ([[self story] is_selfValue]){ if ([[self story] is_selfValue]){
NSString *postBody = [[self story] selftext]; NSString *postBody = [[self story] selftext];
if ((isBaconReaderDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isBaconReaderDeletedOnly) {
if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly) {
shouldHaveBRUndeleteAction = YES; shouldHaveBRUndeleteAction = YES;
tfCommentCellView = nil; tfCommentCellView = nil;
tfStoryController = self; tfStoryController = self;
isBaconReaderEnabled = YES; isBaconReaderEnabled = YES;
} }
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil) {
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
} else { } else {
pushshiftRequestTimeoutValue = 10;
isTFDeletedOnly = YES;
} }
if ([prefs objectForKey:@"isBaconReaderDeletedOnly"] != nil) {
isBaconReaderDeletedOnly = [[prefs objectForKey:@"isBaconReaderDeletedOnly"] boolValue];
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
} else { } else {
isBaconReaderDeletedOnly = YES;
pushshiftRequestTimeoutValue = 10;
} }
} else { } else {
isBaconReaderEnabled = YES; isBaconReaderEnabled = YES;
isBaconReaderDeletedOnly = YES;
isTFDeletedOnly = YES;
pushshiftRequestTimeoutValue = 10; pushshiftRequestTimeoutValue = 10;
} }
} }

+ 32
- 20
tweak/Narwhal.xm View File

#import "Narwhal.h" #import "Narwhal.h"
static BOOL isNarwhalEnabled; static BOOL isNarwhalEnabled;
static BOOL isTFDeletedOnly;
static CGFloat pushshiftRequestTimeoutValue; static CGFloat pushshiftRequestTimeoutValue;


%group Narwhal %group Narwhal
} }
%hook UIViewController %hook UIViewController
-(void) presentViewController:(id) arg1 animated:(BOOL) arg2 completion:(id) arg3{ -(void) presentViewController:(id) arg1 animated:(BOOL) arg2 completion:(id) arg3{
UIAlertAction* undeleteAction; UIAlertAction* undeleteAction;
if (tfComment){ if (tfComment){
undeleteAction = [UIAlertAction actionWithTitle:@"tf did that say?" style:nil 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:nil handler:^(UIAlertAction* action){[tfController handleUndeletePostAction];}];
undeleteAction = [UIAlertAction actionWithTitle:@"tf did that say?" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){[tfController handleUndeletePostAction];}];
} }
[arg1 addAction:undeleteAction]; [arg1 addAction:undeleteAction];
%end %end

%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]]) {
tfComment = [arg1 comment];
tfController = self;
shouldHaveUndeleteAction = YES;
NSString *commentBody = MSHookIvar<NSString*>([arg1 comment], "_body");
if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
tfComment = [arg1 comment];
tfController = self;
shouldHaveUndeleteAction = YES;
}
} }
} }
shouldHaveUndeleteAction = NO; shouldHaveUndeleteAction = NO;
} }
-(void) _dotsButtonTouched:(id) arg1{ -(void) _dotsButtonTouched:(id) arg1{
if ([self linkTextOffscreenCell]){ if ([self linkTextOffscreenCell]){
tfController = self;
tfComment = nil;
shouldHaveUndeleteAction = YES;
NSString *postBody = [[self link] selfText];
if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
tfController = self;
tfComment = nil;
shouldHaveUndeleteAction = YES;
}
} }
%orig; %orig;
-(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]]) {
tfComment = [arg1 comment];
tfController = self;
shouldHaveUndeleteAction = YES;
NSString *commentBody = MSHookIvar<NSString*>([arg1 comment], "_body");
if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
tfComment = [arg1 comment];
tfController = self;
shouldHaveUndeleteAction = YES;
}
} }
} }
isNarwhalEnabled = YES; isNarwhalEnabled = YES;
} }
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil) {
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
} else {
isTFDeletedOnly = YES;
}
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){ if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue]; pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
} else { } else {
} else { } else {
isNarwhalEnabled = YES; isNarwhalEnabled = YES;
isTFDeletedOnly = YES;
pushshiftRequestTimeoutValue = 10; pushshiftRequestTimeoutValue = 10;
} }
} }
} }
} }
} }

+ 73
- 46
tweak/Reddit.xm View File

#import "Reddit.h" #import "Reddit.h"
static CGFloat pushshiftRequestTimeoutValue;
static BOOL isRedditEnabled; static BOOL isRedditEnabled;
static BOOL isTFDeletedOnly;
static CGFloat pushshiftRequestTimeoutValue;
static NSArray *redditVersion; static NSArray *redditVersion;
%hook CommentActionSheetViewController %hook CommentActionSheetViewController
-(void) setItems:(id) arg1{ -(void) setItems:(id) arg1{
NSString *commentBody = [[self comment] bodyText];
if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !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"];
CGSize existingImageSize = [[arg1[0] leftIconImage] size];
CGFloat scale = origImage.size.width / existingImageSize.width;
CGSize existingImageSize = [[arg1[0] leftIconImage] size];
CGFloat scale = origImage.size.width / existingImageSize.width;
UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
id undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self comment]];
id undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self comment]];
%orig([arg1 arrayByAddingObject:undeleteItem]);
arg1 = [arg1 arrayByAddingObject:undeleteItem];
[undeleteItem release];
}
[undeleteItem release];
%orig;
} }


-(void) handleDidSelectActionSheetItem:(id) arg1{ -(void) handleDidSelectActionSheetItem:(id) arg1{
-(void) setItems:(id) arg1{ -(void) setItems:(id) arg1{
Post *post = [self post]; Post *post = [self post];
NSString *postBody = [post selfText];
if ([post isSelfPost]){ if ([post isSelfPost]){
if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !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"];
CGSize existingImageSize = [[arg1[0] leftIconImage] size];
CGFloat scale = origImage.size.width / existingImageSize.width;
CGSize existingImageSize = [[arg1[0] leftIconImage] size];
CGFloat scale = origImage.size.width / existingImageSize.width;
UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
id undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self post]];
id undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self post]];
arg1 = [arg1 arrayByAddingObject:undeleteItem];
[undeleteItem release];
arg1 = [arg1 arrayByAddingObject:undeleteItem];
[undeleteItem release];
}
} }
%orig; %orig;
%hook CommentActionSheetViewController %hook CommentActionSheetViewController
-(void) setItems:(id) arg1{ -(void) setItems:(id) arg1{
NSString *commentBody = [[self comment] bodyText];
if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !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"];
CGSize existingImageSize = [[arg1[0] leftIconImage] size];
CGFloat scale = origImage.size.width / existingImageSize.width;
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 ([redditVersion[1] integerValue] >= 18) {
undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self comment]];
} else {
undeleteItem = [[%c(ActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self comment]];
}
UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
id undeleteItem;
if ([redditVersion[1] integerValue] >= 18) {
undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self comment]];
} else {
undeleteItem = [[%c(ActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self comment]];
}
%orig([arg1 arrayByAddingObject:undeleteItem]);
arg1 = [arg1 arrayByAddingObject:undeleteItem];
[undeleteItem release];
}
[undeleteItem release];
%orig;
} }
// >= 4.21 // >= 4.21
-(void) setItems:(id) arg1{ -(void) setItems:(id) arg1{
Post *post = [self post]; Post *post = [self post];
NSString *postBody = [post selfText];
if ([post isSelfPost]){ if ([post isSelfPost]){
if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !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"];
CGSize existingImageSize = [[arg1[0] leftIconImage] size];
CGFloat scale = origImage.size.width / existingImageSize.width;
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 ([redditVersion[1] integerValue] >= 18) {
undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self post]];
} else {
undeleteItem = [[%c(ActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self post]];
}
UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
id undeleteItem;
if ([redditVersion[1] integerValue] >= 18) {
undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self post]];
} else {
undeleteItem = [[%c(ActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self post]];
}
arg1 = [arg1 arrayByAddingObject:undeleteItem];
[undeleteItem release];
arg1 = [arg1 arrayByAddingObject:undeleteItem];
[undeleteItem release];
}
} }
%orig; %orig;
isRedditEnabled = YES; isRedditEnabled = YES;
} }
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil) {
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
} else {
isTFDeletedOnly = YES;
}
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){ if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue]; pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
} else { } else {
} else { } else {
isRedditEnabled = YES; isRedditEnabled = YES;
isTFDeletedOnly = YES;
pushshiftRequestTimeoutValue = 10; pushshiftRequestTimeoutValue = 10;
} }
} }

+ 10
- 10
tweak/Slide.xm View File

#import "assets/MMMarkdown.h" #import "assets/MMMarkdown.h"
static BOOL isSlideEnabled; static BOOL isSlideEnabled;
static BOOL isSlideDeletedOnly;
static BOOL isTFDeletedOnly;
static CGFloat pushshiftRequestTimeoutValue; static CGFloat pushshiftRequestTimeoutValue;
%group Slide %group Slide
NSString *body = [MSHookIvar<id>(self, "comment") body]; NSString *body = [MSHookIvar<id>(self, "comment") body];
if ((isSlideDeletedOnly && ([body isEqualToString:@"[deleted]"] || [body isEqualToString:@"[removed]"])) || !isSlideDeletedOnly){
if ((isTFDeletedOnly && ([body isEqualToString:@"[deleted]"] || [body isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
id controller = MSHookIvar<id>(self, "parent"); id controller = MSHookIvar<id>(self, "parent");
NSMutableAttributedString *htmlAttributedString = [[NSMutableAttributedString alloc] initWithAttributedString:[dthtmlBuilder generatedAttributedString]]; NSMutableAttributedString *htmlAttributedString = [[NSMutableAttributedString alloc] initWithAttributedString:[dthtmlBuilder generatedAttributedString]];
NSRange htmlStringRange = NSMakeRange(0, [htmlAttributedString length]); NSRange htmlStringRange = NSMakeRange(0, [htmlAttributedString length]);
[[htmlAttributedString mutableString] replaceOccurrencesOfString:@"\t•\t" withString:@" • " options:nil range: htmlStringRange];
[[htmlAttributedString mutableString] replaceOccurrencesOfString:@"\t◦\t" withString:@"  ◦ " options:nil range: htmlStringRange];
[[htmlAttributedString mutableString] replaceOccurrencesOfString:@"\t▪\t" withString:@" ▪ " options:nil range: htmlStringRange];
[[htmlAttributedString mutableString] replaceOccurrencesOfString:@"\t•\t" withString:@" • " options:0 range: htmlStringRange];
[[htmlAttributedString mutableString] replaceOccurrencesOfString:@"\t◦\t" withString:@"  ◦ " options:0 range: htmlStringRange];
[[htmlAttributedString mutableString] replaceOccurrencesOfString:@"\t▪\t" withString:@" ▪ " options:0 range: htmlStringRange];
[htmlAttributedString removeAttribute:@"CTForegroundColorFromContext" range:htmlStringRange]; [htmlAttributedString removeAttribute:@"CTForegroundColorFromContext" range:htmlStringRange];
}]; }];
[htmlAttributedString beginEditing]; [htmlAttributedString beginEditing];
[htmlAttributedString enumerateAttribute:NSFontAttributeName inRange:NSMakeRange(0, [htmlAttributedString length]) options:nil 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;
isSlideEnabled = YES; isSlideEnabled = YES;
} }
if ([prefs objectForKey:@"isSlideDeletedOnly"] != nil){
isSlideDeletedOnly = [[prefs objectForKey:@"isSlideDeletedOnly"] boolValue];
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil){
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
} else { } else {
isSlideDeletedOnly = YES;
isTFDeletedOnly = YES;
} }
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){ if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
} else { } else {
isSlideEnabled = YES; isSlideEnabled = YES;
isSlideDeletedOnly = YES;
isTFDeletedOnly = YES;
pushshiftRequestTimeoutValue = 10; pushshiftRequestTimeoutValue = 10;
} }
} }

Loading…
Cancel
Save