diff --git a/README.md b/README.md index 2f7a70d..0e8ec83 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ Free & Open Source Tweak for Twitter app on iOS! ## Features - Remove Ads +- Hide News and Trending posts in search tab +- Hide who to follow section - Can Save Video (long press on video to save) - Lightweight - Support iOS 10 (not tested) - 11 (tested) - 12 (tested) - 13 (tested) diff --git a/Tweak.h b/Tweak.h index f773cc4..99080d3 100644 --- a/Tweak.h +++ b/Tweak.h @@ -1,10 +1,12 @@ #import +#include #import #define PLIST_PATH "/var/mobile/Library/Preferences/com.haoict.twitternoadspref.plist" #define PREF_CHANGED_NOTIF "com.haoict.twitternoadspref/PrefChanged" @interface TFNItemsDataViewController : NSObject +@property(copy, nonatomic) NSArray *sections; - (id)itemAtIndexPath:(id)arg1; @end @@ -50,3 +52,11 @@ @interface T1SlideshowViewController : UIViewController @property (nonatomic, readonly, strong) id slideStatus; @end + +@interface T1URTFooterViewModel : NSObject +@property(nonatomic, readonly) NSURL *url; +@end + +@interface TFNTwitterModuleFooter : NSObject +@property(nonatomic, readonly) NSURL *url; +@end \ No newline at end of file diff --git a/Tweak.xm b/Tweak.xm index eda5a13..50fd72d 100644 --- a/Tweak.xm +++ b/Tweak.xm @@ -5,6 +5,7 @@ */ BOOL noads; BOOL hideNewsAndTrending; +BOOL hideWhoToFollow; BOOL canSaveVideo; static void reloadPrefs() { @@ -12,6 +13,7 @@ static void reloadPrefs() { noads = [[settings objectForKey:@"noads"] ?: @(YES) boolValue]; hideNewsAndTrending = [[settings objectForKey:@"hideNewsAndTrending"] ?: @(YES) boolValue]; + hideWhoToFollow = [[settings objectForKey:@"hideWhoToFollow"] ?: @(YES) boolValue]; canSaveVideo = [[settings objectForKey:@"canSaveVideo"] ?: @(YES) boolValue]; } @@ -50,8 +52,8 @@ static void showDownloadPopup(id twStatus, UIViewController *viewController, voi return tbvCell; } + NSString *itemClassName = NSStringFromClass([item classForCoder]); if (hideNewsAndTrending) { - NSString *itemClassName = NSStringFromClass([item classForCoder]); if ([itemClassName isEqualToString:@"T1Twitter.URTTimelineTrendViewModel"] || [itemClassName isEqualToString:@"T1Twitter.URTTimelineEventSummaryViewModel"] || [itemClassName isEqualToString:@"T1URTTimelineMessageItemViewModel"]) { @@ -60,6 +62,33 @@ static void showDownloadPopup(id twStatus, UIViewController *viewController, voi } } + if (hideWhoToFollow) { + if ([itemClassName isEqualToString:@"TFNTwitterUser"] || [itemClassName isEqualToString:@"T1URTTimelineUserItemViewModel"]) { + [tbvCell setHidden: YES]; + return tbvCell; + } + + if ([itemClassName isEqualToString:@"T1Twitter.URTModuleHeaderViewModel"]) { + // Ivar textIvar = class_getInstanceVariable([item class], "text"); + // id text = object_getIvar(item, textIvar); + // if ([text isEqualToString:@"Who to follow"]) { } + [tbvCell setHidden: YES]; + return tbvCell; + } + + if ([itemClassName isEqualToString:@"T1URTFooterViewModel"] && [((T1URTFooterViewModel *)item).url.absoluteString containsString:@"connect_people"] ) { + [tbvCell setHidden: YES]; + return tbvCell; + } + + if ([itemClassName isEqualToString:@"TFNTwitterModuleFooter"] && [((TFNTwitterModuleFooter *)item).url.absoluteString containsString:@"connect_people"] ) { + [tbvCell setHidden: YES]; + return tbvCell; + } + } + + NSLog(@"hao---%@", itemClassName); + return tbvCell; } @@ -70,8 +99,8 @@ static void showDownloadPopup(id twStatus, UIViewController *viewController, voi return 0; } + NSString *itemClassName = NSStringFromClass([item classForCoder]); if (hideNewsAndTrending) { - NSString *itemClassName = NSStringFromClass([item classForCoder]); if ([itemClassName isEqualToString:@"T1Twitter.URTTimelineTrendViewModel"] || [itemClassName isEqualToString:@"T1Twitter.URTTimelineEventSummaryViewModel"] || [itemClassName isEqualToString:@"T1URTTimelineMessageItemViewModel"]) { @@ -79,6 +108,37 @@ static void showDownloadPopup(id twStatus, UIViewController *viewController, voi } } + if (hideWhoToFollow) { + if ([itemClassName isEqualToString:@"TFNTwitterUser"] || [itemClassName isEqualToString:@"T1URTTimelineUserItemViewModel"]) { + return 0; + } + + if ([itemClassName isEqualToString:@"T1Twitter.URTModuleHeaderViewModel"]) { + return 0; + } + + if ([itemClassName isEqualToString:@"T1URTFooterViewModel"] && [((T1URTFooterViewModel *)item).url.absoluteString containsString:@"connect_people"] ) { + return 0; + } + + if ([itemClassName isEqualToString:@"TFNTwitterModuleFooter"] && [((TFNTwitterModuleFooter *)item).url.absoluteString containsString:@"connect_people"] ) { + return 0; + } + } + + return %orig; + } + + - (double)tableView:(id)arg1 heightForHeaderInSection:(long long)arg2 { + if (self.sections + && self.sections[arg2] + && ((NSArray* )self.sections[arg2]).count + && self.sections[arg2][0]) { + NSString *sectionClassName = NSStringFromClass([self.sections[arg2][0] classForCoder]); + if ([sectionClassName isEqualToString:@"TFNTwitterUser"]) { + return 0; + } + } return %orig; } %end diff --git a/control b/control index 460d042..5ee4a1e 100644 --- a/control +++ b/control @@ -1,12 +1,15 @@ Package: com.haoict.twitternoads Name: Twitter No Ads Depends: mobilesubstrate, preferenceloader, com.haoict.libhdev (>= 2.0.0), firmware (>= 10) -Version: 1.0.0 +Version: 1.1.0 Architecture: iphoneos-arm Description: Free & Open Source Tweak for Twitter Free & Open Source Tweak for Twitter + Change log: https://github.com/haoict/twitternoads/releases Features: - Remove Ads + - Hide News and Trending posts in search tab + - Hide who to follow section - Can Save Video (long press on video to save) - Lightweight - Support iOS 10 (not tested) - 11 (tested) - 12 (tested) - 13 (tested) diff --git a/pref/Resources/Root.plist b/pref/Resources/Root.plist index 80b8ad0..903a8fb 100755 --- a/pref/Resources/Root.plist +++ b/pref/Resources/Root.plist @@ -66,9 +66,28 @@ key hideNewsAndTrending label - REMOVE_NEWS_AND_TRENDING + HIDE_NEWS_AND_TRENDING subtitle - REMOVE_NEWS_AND_TRENDING_POST_ON_SEARCH_TAB + HIDE_NEWS_AND_TRENDING_POST_ON_SEARCH_TAB + PostNotification + com.haoict.twitternoadspref/PrefChanged + + + + cell + PSSwitchCell + cellClass + HPSSwitchCell + default + + defaults + com.haoict.twitternoadspref + key + hideWhoToFollow + label + HIDE_WHO_TO_FOLLOW + subtitle + HIDE_WHO_TO_FOLLOW_SECTION PostNotification com.haoict.twitternoadspref/PrefChanged diff --git a/pref/Resources/base.lproj/Root.strings b/pref/Resources/base.lproj/Root.strings index 415fea6..a09620d 100644 --- a/pref/Resources/base.lproj/Root.strings +++ b/pref/Resources/base.lproj/Root.strings @@ -7,8 +7,10 @@ "MAIN_PREFERENCES" = "Main Preferences"; "NO_ADS" = "No Ads"; "REMOVE_ADS_IN_NEWS_FEED" = "Remove Ads in News Feed"; - "REMOVE_NEWS_AND_TRENDING" = "Remove News And Trending"; - "REMOVE_NEWS_AND_TRENDING_POST_ON_SEARCH_TAB" = "Remove News And Trending post on Search tab"; + "HIDE_NEWS_AND_TRENDING" = "Remove News And Trending"; + "HIDE_NEWS_AND_TRENDING_POST_ON_SEARCH_TAB" = "Remove News And Trending post on Search tab"; + "HIDE_WHO_TO_FOLLOW" = "Hide who to follow"; + "HIDE_WHO_TO_FOLLOW_SECTION" = "Hide who to follow section"; "CAN_SAVE_VIDEO" = "Can Save Video"; "LONG_PRESS_ON_VIDEO_TO_SAVE" = "Long press on video to save"; "OTHER_PREFERENCES" = "Other Preferences"; diff --git a/pref/Resources/en.lproj/Root.strings b/pref/Resources/en.lproj/Root.strings index 415fea6..a09620d 100644 --- a/pref/Resources/en.lproj/Root.strings +++ b/pref/Resources/en.lproj/Root.strings @@ -7,8 +7,10 @@ "MAIN_PREFERENCES" = "Main Preferences"; "NO_ADS" = "No Ads"; "REMOVE_ADS_IN_NEWS_FEED" = "Remove Ads in News Feed"; - "REMOVE_NEWS_AND_TRENDING" = "Remove News And Trending"; - "REMOVE_NEWS_AND_TRENDING_POST_ON_SEARCH_TAB" = "Remove News And Trending post on Search tab"; + "HIDE_NEWS_AND_TRENDING" = "Remove News And Trending"; + "HIDE_NEWS_AND_TRENDING_POST_ON_SEARCH_TAB" = "Remove News And Trending post on Search tab"; + "HIDE_WHO_TO_FOLLOW" = "Hide who to follow"; + "HIDE_WHO_TO_FOLLOW_SECTION" = "Hide who to follow section"; "CAN_SAVE_VIDEO" = "Can Save Video"; "LONG_PRESS_ON_VIDEO_TO_SAVE" = "Long press on video to save"; "OTHER_PREFERENCES" = "Other Preferences"; diff --git a/pref/Resources/vi.lproj/Root.strings b/pref/Resources/vi.lproj/Root.strings index 5462ff5..a6d3866 100644 --- a/pref/Resources/vi.lproj/Root.strings +++ b/pref/Resources/vi.lproj/Root.strings @@ -7,8 +7,10 @@ "MAIN_PREFERENCES" = "Tùy chỉnh chính"; "NO_ADS" = "Gỡ quảng cáo"; "REMOVE_ADS_IN_NEWS_FEED" = "Gỡ quảng cáo ở News Feed"; - "REMOVE_NEWS_AND_TRENDING" = "Remove News And Trending"; - "REMOVE_NEWS_AND_TRENDING_POST_ON_SEARCH_TAB" = "Remove News And Trending post on Search tab"; + "HIDE_NEWS_AND_TRENDING" = "Ẩn Tin tức và chủ đề nổi trội"; + "HIDE_NEWS_AND_TRENDING_POST_ON_SEARCH_TAB" = "Ẩn Tin tức và chủ đề nổi trội ở tab Tìm kiếm"; + "HIDE_WHO_TO_FOLLOW" = "Ẩn gợi ý theo dõi"; + "HIDE_WHO_TO_FOLLOW_SECTION" = "Ẩn mục gợi ý theo dõi"; "CAN_SAVE_VIDEO" = "Có thể tải video"; "LONG_PRESS_ON_VIDEO_TO_SAVE" = "Ấn và giữ video để lưu"; "OTHER_PREFERENCES" = "Tùy chỉnh phụ"; diff --git a/release/com.haoict.twitternoads_1.1.0_iphoneos-arm.deb b/release/com.haoict.twitternoads_1.1.0_iphoneos-arm.deb new file mode 100644 index 0000000..9ef7435 Binary files /dev/null and b/release/com.haoict.twitternoads_1.1.0_iphoneos-arm.deb differ