您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

654 行
20KB

  1. #import "Reddit.h"
  2. #import "assets/TFHelper.h"
  3. static BOOL isRedditEnabled;
  4. static BOOL isTFDeletedOnly;
  5. static CGFloat pushshiftRequestTimeoutValue;
  6. static NSArray *redditVersion;
  7. int getRedditVersionPart(int index){
  8. if (![redditVersion[index] isEqual:[NSNull null]]){
  9. return [redditVersion[index] intValue];
  10. } else {
  11. NSArray *newVersionArray = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."];
  12. if (![newVersionArray[index] isEqual:[NSNull null]]){
  13. return [newVersionArray[index] intValue];
  14. } else {
  15. return [@[@4, @48, @1][index] intValue];
  16. }
  17. }
  18. }
  19. %group Reddit_v4_current
  20. %hook CommentTreeNode
  21. %property(assign,nonatomic)id commentTreeHeaderNode;
  22. %property(assign,nonatomic)id commentTreeCommandBarNode;
  23. %end
  24. %hook CommentTreeHeaderView
  25. -(void) layoutSubviews{
  26. %orig;
  27. [[self commentTreeNode] setCommentTreeHeaderNode:self];
  28. }
  29. %end
  30. %hook CommentTreeHeaderNode
  31. -(void) didLoad{
  32. %orig;
  33. [[self commentTreeNode] setCommentTreeHeaderNode:self];
  34. }
  35. %end
  36. %hook CommentTreeCommandBarNode
  37. -(void) didLoad{
  38. %orig;
  39. [[self commentTreeNode] setCommentTreeCommandBarNode:self];
  40. }
  41. %end
  42. %hook CommentActionSheetViewController
  43. -(void) setItems:(id) arg1{
  44. NSString *commentBody = [[self comment] bodyText];
  45. if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
  46. UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
  47. CGSize existingImageSize = [[arg1[0] leftIconImage] size];
  48. CGFloat scale = origImage.size.width / existingImageSize.width;
  49. UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
  50. id undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self comment]];
  51. arg1 = [arg1 arrayByAddingObject:undeleteItem];
  52. [undeleteItem release];
  53. }
  54. %orig;
  55. }
  56. -(void) handleDidSelectActionSheetItem:(id) arg1{
  57. %orig;
  58. if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]){
  59. [self dismissViewControllerAnimated:YES completion:nil];
  60. id commentTreeNode = [self commentTreeNode];
  61. Comment *comment = [commentTreeNode comment];
  62. [%c(TFHelper) getUndeleteDataWithID:[[comment pk] componentsSeparatedByString:@"_"][1] isComment:YES timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeleteCommentAction:)];
  63. }
  64. }
  65. %new
  66. -(void) completeUndeleteCommentAction:(NSDictionary *) data{
  67. id commentTreeNode = [self commentTreeNode];
  68. Comment *comment = [commentTreeNode comment];
  69. NSString *author = data[@"author"];
  70. NSString *body = data[@"body"];
  71. NSMutableAttributedString *bodyMutableAttributedText;
  72. id themeManager;
  73. id isNightMode;
  74. id textColor;
  75. if (getRedditVersionPart(1) >= 45){
  76. themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
  77. isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
  78. if (isNightMode) {
  79. textColor = [[themeManager darkTheme] bodyTextColor];
  80. } else{
  81. textColor = [[themeManager lightTheme] bodyTextColor];
  82. }
  83. [themeManager release];
  84. } else if (getRedditVersionPart(1) >= 37){
  85. themeManager = [[%c(ThemeManager) alloc] initWithTraitCollection:nil appSettings:[%c(AppSettings) sharedSettings]];
  86. isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
  87. if (isNightMode) {
  88. textColor = [[themeManager nightTheme] bodyTextColor];
  89. } else{
  90. textColor = [[themeManager dayTheme] bodyTextColor];
  91. }
  92. [themeManager release];
  93. } else {
  94. themeManager = [%c(ThemeManager) sharedManager];
  95. isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
  96. if (isNightMode) {
  97. textColor = [[themeManager nightTheme] bodyTextColor];
  98. } else{
  99. textColor = [[themeManager dayTheme] bodyTextColor];
  100. }
  101. }
  102. bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
  103. [bodyMutableAttributedText beginEditing];
  104. [bodyMutableAttributedText enumerateAttribute:NSForegroundColorAttributeName inRange:NSMakeRange(0, bodyMutableAttributedText.length) options:0 usingBlock:^(id _Nullable value, NSRange range, BOOL * _Nonnull stop) {
  105. [bodyMutableAttributedText removeAttribute:NSForegroundColorAttributeName range:range];
  106. [bodyMutableAttributedText addAttribute:NSForegroundColorAttributeName value:textColor range:range];
  107. }];
  108. [bodyMutableAttributedText endEditing];
  109. [comment setAuthor:author];
  110. [comment setBodyText:body];
  111. [comment setBodyRichTextAttributed:bodyMutableAttributedText];
  112. [comment setBodyAttributedText:bodyMutableAttributedText];
  113. [[commentTreeNode commentTreeHeaderNode] updateContentViewsForData:comment];
  114. [bodyMutableAttributedText release];
  115. }
  116. %end
  117. %hook PostDetailViewController
  118. %property(strong,nonatomic) id feedPostTextWithThumbnailNode;
  119. %property(strong,nonatomic) id feedPostDetailCellNode;
  120. %end
  121. %hook FeedPostDetailCellNode
  122. -(void) didLoad{
  123. %orig;
  124. [[[self delegate] viewController] setFeedPostDetailCellNode:self];
  125. }
  126. %end
  127. %hook PostActionSheetViewController
  128. -(void) setItems:(id) arg1{
  129. Post *post = [self post];
  130. NSString *postBody = [post selfText];
  131. if ([post isSelfPost]){
  132. if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
  133. UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
  134. CGSize existingImageSize = [[arg1[0] leftIconImage] size];
  135. CGFloat scale = origImage.size.width / existingImageSize.width;
  136. UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
  137. id undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self post]];
  138. arg1 = [arg1 arrayByAddingObject:undeleteItem];
  139. [undeleteItem release];
  140. }
  141. }
  142. %orig;
  143. }
  144. -(void) handleDidSelectActionSheetItem:(id) arg1{
  145. %orig;
  146. if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]){
  147. [self dismissViewControllerAnimated:YES completion:nil];
  148. Post *post = [self post];
  149. if ([post isSelfPost]){
  150. [%c(TFHelper) getUndeleteDataWithID:[[post pk] componentsSeparatedByString:@"_"][1] isComment:NO timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeletePostAction:)];
  151. }
  152. }
  153. }
  154. %new
  155. -(void) completeUndeletePostAction:(NSDictionary *) data{
  156. Post *post = [self post];
  157. NSString *author = data[@"author"];
  158. NSString *body = data[@"body"];
  159. id themeManager;
  160. id isNightMode;
  161. id textColor;
  162. if (getRedditVersionPart(1) >= 45){
  163. themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
  164. isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
  165. if (isNightMode) {
  166. textColor = [[themeManager darkTheme] bodyTextColor];
  167. } else{
  168. textColor = [[themeManager lightTheme] bodyTextColor];
  169. }
  170. [themeManager release];
  171. } else if (getRedditVersionPart(1) >= 37){
  172. themeManager = [[%c(ThemeManager) alloc] initWithTraitCollection:nil appSettings:[%c(AppSettings) sharedSettings]];
  173. isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
  174. if (isNightMode) {
  175. textColor = [[themeManager nightTheme] bodyTextColor];
  176. } else{
  177. textColor = [[themeManager dayTheme] bodyTextColor];
  178. }
  179. [themeManager release];
  180. } else {
  181. themeManager = [%c(ThemeManager) sharedManager];
  182. isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
  183. if (isNightMode) {
  184. textColor = [[themeManager nightTheme] bodyTextColor];
  185. } else{
  186. textColor = [[themeManager dayTheme] bodyTextColor];
  187. }
  188. }
  189. NSMutableAttributedString *bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
  190. [bodyMutableAttributedText beginEditing];
  191. [bodyMutableAttributedText enumerateAttribute:NSForegroundColorAttributeName inRange:NSMakeRange(0, bodyMutableAttributedText.length) options:0 usingBlock:^(id _Nullable value, NSRange range, BOOL * _Nonnull stop) {
  192. [bodyMutableAttributedText removeAttribute:NSForegroundColorAttributeName range:range];
  193. [bodyMutableAttributedText addAttribute:NSForegroundColorAttributeName value:textColor range:range];
  194. }];
  195. [bodyMutableAttributedText endEditing];
  196. [post setSelfText:body];
  197. [post setAuthor:author];
  198. [post setSelfPostRichTextAttributed:bodyMutableAttributedText];
  199. [post setPreviewFeedPostTextString:bodyMutableAttributedText];
  200. if (getRedditVersionPart(1) >= 44){
  201. [[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] configureSelfTextNode];
  202. } else if (getRedditVersionPart(1) >= 38) {
  203. [[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] configureSelfTextNode];
  204. } else {
  205. [[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] configureSelfTextNode];
  206. [[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] titleNode] configureNodes];
  207. }
  208. [bodyMutableAttributedText release];
  209. }
  210. %end
  211. %end
  212. %group Reddit_v4_ios10
  213. %hook CommentsViewController
  214. %new
  215. -(void) updateComments{
  216. [self reloadCommentsWithNewCommentsHighlight:NO autoScroll:NO animated:NO];
  217. }
  218. %new
  219. -(void) updatePostText{
  220. if (getRedditVersionPart(1) >= 2){
  221. [self reloadPostSection:YES];
  222. } else {
  223. [self feedPostViewDidUpdatePost:[self postData] shouldReloadFeed:NO];
  224. }
  225. }
  226. %end
  227. %hook CommentActionSheetViewController
  228. -(void) setItems:(id) arg1{
  229. NSString *commentBody = [[self comment] bodyText];
  230. if ((isTFDeletedOnly && ([commentBody isEqualToString:@"[deleted]"] || [commentBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
  231. UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
  232. CGSize existingImageSize = [[arg1[0] leftIconImage] size];
  233. CGFloat scale = origImage.size.width / existingImageSize.width;
  234. UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
  235. id undeleteItem;
  236. if (getRedditVersionPart(1) >= 18) {
  237. undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self comment]];
  238. } else {
  239. undeleteItem = [[%c(ActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self comment]];
  240. }
  241. arg1 = [arg1 arrayByAddingObject:undeleteItem];
  242. [undeleteItem release];
  243. }
  244. %orig;
  245. }
  246. // >= 4.21
  247. -(void) handleDidSelectActionSheetItem:(id) arg1{
  248. %orig;
  249. if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]){
  250. [self dismissViewControllerAnimated:YES completion:nil];
  251. Comment *comment = [self comment];
  252. [%c(TFHelper) getUndeleteDataWithID:[[comment pk] componentsSeparatedByString:@"_"][1] isComment:YES timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeleteCommentAction:)];
  253. }
  254. }
  255. // <= 4.20
  256. -(void) actionSheetViewController:(id) arg1 didSelectItem:(id) arg2{
  257. %orig;
  258. if ([[arg2 identifier] isEqualToString:@"undeleteItemIdentifier"]){
  259. [self dismissViewControllerAnimated:YES completion:nil];
  260. Comment *comment = [self comment];
  261. [%c(TFHelper) getUndeleteDataWithID:[[comment pk] componentsSeparatedByString:@"_"][1] isComment:YES timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeleteCommentAction:)];
  262. }
  263. }
  264. %new
  265. -(void) completeUndeleteCommentAction:(NSDictionary *) data{
  266. Comment *comment = [self comment];
  267. NSString *body = data[@"body"];
  268. NSMutableAttributedString *bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
  269. [comment setAuthor:data[@"author"]];
  270. [comment setBodyText:body];
  271. [comment setBodyAttributedText:bodyMutableAttributedText];
  272. if (getRedditVersionPart(1) >= 12) {
  273. [comment setBodyRichTextAttributed:bodyMutableAttributedText];
  274. }
  275. [[self commentActionSheetDelegate] updateComments];
  276. [bodyMutableAttributedText release];
  277. }
  278. %end
  279. %hook PostActionSheetViewController
  280. -(void) setItems:(id) arg1{
  281. Post *post = [self post];
  282. NSString *postBody = [post selfText];
  283. if ([post isSelfPost]){
  284. if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
  285. UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
  286. CGSize existingImageSize = [[arg1[0] leftIconImage] size];
  287. CGFloat scale = origImage.size.width / existingImageSize.width;
  288. UIImage *newImage = [UIImage imageWithCGImage:[origImage CGImage] scale:scale orientation:origImage.imageOrientation];
  289. id undeleteItem;
  290. if (getRedditVersionPart(1) >= 18) {
  291. undeleteItem = [[%c(RUIActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self post]];
  292. } else {
  293. undeleteItem = [[%c(ActionSheetItem) alloc] initWithLeftIconImage:newImage text:@"TF did that say?" identifier:@"undeleteItemIdentifier" context:[self post]];
  294. }
  295. arg1 = [arg1 arrayByAddingObject:undeleteItem];
  296. [undeleteItem release];
  297. }
  298. }
  299. %orig;
  300. }
  301. // >= 4.21
  302. -(void) handleDidSelectActionSheetItem:(id) arg1{
  303. %orig;
  304. if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]){
  305. [self dismissViewControllerAnimated:YES completion:nil];
  306. Post *post = [self post];
  307. if ([post isSelfPost]){
  308. [%c(TFHelper) getUndeleteDataWithID:[[post pk] componentsSeparatedByString:@"_"][1] isComment:NO timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeletePostAction:)];
  309. }
  310. }
  311. }
  312. // <= 4.20
  313. -(void) actionSheetViewController:(id) arg1 didSelectItem:(id) arg2{
  314. %orig;
  315. if ([[arg2 identifier] isEqualToString:@"undeleteItemIdentifier"]){
  316. [self dismissViewControllerAnimated:YES completion:nil];
  317. Post *post = [self post];
  318. if ([post isSelfPost]){
  319. [%c(TFHelper) getUndeleteDataWithID:[[post pk] componentsSeparatedByString:@"_"][1] isComment:NO timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeletePostAction:)];
  320. }
  321. }
  322. }
  323. %new
  324. -(void) completeUndeletePostAction:(NSDictionary *) data{
  325. Post *post = [self post];
  326. NSString *body = data[@"body"];
  327. NSMutableAttributedString *bodyMutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:[%c(NSAttributedStringMarkdownParser) attributedStringUsingCurrentConfig:body]];
  328. [post setAuthor:data[@"author"]];
  329. [post setSelfText:body];
  330. [post setSelfTextAttributed:bodyMutableAttributedText];
  331. if (getRedditVersionPart(1) >= 8) {
  332. [post setSelfPostRichTextAttributed:bodyMutableAttributedText];
  333. }
  334. if (getRedditVersionPart(1) >= 15) {
  335. [post setPreviewFeedPostTextString:bodyMutableAttributedText];
  336. }
  337. [[self postActionSheetDelegate] updatePostText];
  338. [bodyMutableAttributedText release];
  339. }
  340. %end
  341. %end
  342. //outdated and unchanged from first version of this tweak...
  343. //TODO: move button to menu, add post support, make async requests once I feel like doing it
  344. %group Reddit_v3
  345. %hook CommentView
  346. %new
  347. -(void) buttonAction {
  348. id commentsViewController = [self delegate];
  349. id comment = [self comment];
  350. NSError* error;
  351. NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
  352. [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.pushshift.io/reddit/search/comment/?ids=%@&fields=author,body",[comment pkWithoutPrefix]]]];
  353. [request setHTTPMethod:@"GET"];
  354. NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error];
  355. NSString *author = @"[author]";
  356. NSString *body = @"[body]";
  357. if (data != nil && error == nil){
  358. id jsonData = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
  359. author = [[jsonData objectForKey:@"data"][0] objectForKey:@"author"];
  360. body = [[jsonData objectForKey:@"data"][0] objectForKey:@"body"];
  361. if ([body isEqualToString:@"[deleted]"] || [body isEqualToString:@"[removed]"]){
  362. body = @"[comment was unable to be archived]";
  363. }
  364. } else if (error != nil || data == nil){
  365. body = @"[an error occured]";
  366. }
  367. [comment setValue:author forKey:@"author"];
  368. [comment setValue:[%c(MarkDownParser) attributedStringFromMarkdownString: body] forKey:@"bodyAttributedText"];
  369. [comment setValue:body forKey:@"bodyText"];
  370. [commentsViewController reloadCommentsWithNewCommentsHighlight:NO autoScroll:NO animated:NO];
  371. }
  372. -(id) initWithFrame:(id)arg1{
  373. id orig = %orig;
  374. id commandView = [self commandView];
  375. UIButton *undeleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
  376. [undeleteButton addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
  377. UIImage* undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
  378. [undeleteButton setImage:undeleteImage forState:UIControlStateNormal];
  379. [commandView setUndeleteButton:undeleteButton];
  380. [commandView addSubview:undeleteButton];
  381. return orig;
  382. }
  383. %end
  384. %hook CommentCommandView
  385. %property (assign, nonatomic) id undeleteButton;
  386. -(void) layoutSubviews{
  387. %orig;
  388. UIButton *button = [self undeleteButton];
  389. button.frame = CGRectMake([[self overflowButton ] frame].origin.x - 32, 0, 32, 32);
  390. }
  391. %end
  392. %end
  393. static void loadPrefs(){
  394. NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
  395. if (prefs){
  396. if ([prefs objectForKey:@"isRedditEnabled"] != nil){
  397. isRedditEnabled = [[prefs objectForKey:@"isRedditEnabled"] boolValue];
  398. } else {
  399. isRedditEnabled = YES;
  400. }
  401. if ([prefs objectForKey:@"isTFDeletedOnly"] != nil) {
  402. isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
  403. } else {
  404. isTFDeletedOnly = YES;
  405. }
  406. if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
  407. pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
  408. } else {
  409. pushshiftRequestTimeoutValue = 10;
  410. }
  411. } else {
  412. isRedditEnabled = YES;
  413. isTFDeletedOnly = YES;
  414. pushshiftRequestTimeoutValue = 10;
  415. }
  416. }
  417. static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
  418. loadPrefs();
  419. }
  420. %ctor{
  421. loadPrefs();
  422. NSString* processName = [[NSProcessInfo processInfo] processName];
  423. redditVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."];
  424. if ([processName isEqualToString:@"Reddit"]){
  425. if (isRedditEnabled) {
  426. CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
  427. if (getRedditVersionPart(0) == 4){
  428. if (getRedditVersionPart(1) <= 32){
  429. %init(Reddit_v4_ios10);
  430. } else{
  431. %init(Reddit_v4_current);
  432. }
  433. } else if (getRedditVersionPart(0) == 3) {
  434. %init(Reddit_v3);
  435. }
  436. }
  437. }
  438. }