Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Add option to remove Who to follow section
Browse files Browse the repository at this point in the history
  • Loading branch information
haoict committed May 27, 2020
1 parent 76299bf commit 962a3b8
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions Tweak.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#import <Foundation/Foundation.h>
#include <objc/objc-runtime.h>
#import <libhdev/HUtilities/HDownloadMedia.h>

#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

Expand Down Expand Up @@ -50,3 +52,11 @@
@interface T1SlideshowViewController : UIViewController
@property (nonatomic, readonly, strong) id<T1StatusViewModel> slideStatus;
@end

@interface T1URTFooterViewModel : NSObject
@property(nonatomic, readonly) NSURL *url;
@end

@interface TFNTwitterModuleFooter : NSObject
@property(nonatomic, readonly) NSURL *url;
@end
64 changes: 62 additions & 2 deletions Tweak.xm
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
*/
BOOL noads;
BOOL hideNewsAndTrending;
BOOL hideWhoToFollow;
BOOL canSaveVideo;

static void reloadPrefs() {
NSDictionary *settings = [[NSMutableDictionary alloc] initWithContentsOfFile:@PLIST_PATH] ?: [@{} mutableCopy];

noads = [[settings objectForKey:@"noads"] ?: @(YES) boolValue];
hideNewsAndTrending = [[settings objectForKey:@"hideNewsAndTrending"] ?: @(YES) boolValue];
hideWhoToFollow = [[settings objectForKey:@"hideWhoToFollow"] ?: @(YES) boolValue];
canSaveVideo = [[settings objectForKey:@"canSaveVideo"] ?: @(YES) boolValue];
}

Expand Down Expand Up @@ -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"]) {
Expand All @@ -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;
}

Expand All @@ -70,15 +99,46 @@ 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"]) {
return 0;
}
}

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
Expand Down
5 changes: 4 additions & 1 deletion control
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
23 changes: 21 additions & 2 deletions pref/Resources/Root.plist
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,28 @@
<key>key</key>
<string>hideNewsAndTrending</string>
<key>label</key>
<string>REMOVE_NEWS_AND_TRENDING</string>
<string>HIDE_NEWS_AND_TRENDING</string>
<key>subtitle</key>
<string>REMOVE_NEWS_AND_TRENDING_POST_ON_SEARCH_TAB</string>
<string>HIDE_NEWS_AND_TRENDING_POST_ON_SEARCH_TAB</string>
<key>PostNotification</key>
<string>com.haoict.twitternoadspref/PrefChanged</string>
</dict>

<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>cellClass</key>
<string>HPSSwitchCell</string>
<key>default</key>
<true/>
<key>defaults</key>
<string>com.haoict.twitternoadspref</string>
<key>key</key>
<string>hideWhoToFollow</string>
<key>label</key>
<string>HIDE_WHO_TO_FOLLOW</string>
<key>subtitle</key>
<string>HIDE_WHO_TO_FOLLOW_SECTION</string>
<key>PostNotification</key>
<string>com.haoict.twitternoadspref/PrefChanged</string>
</dict>
Expand Down
6 changes: 4 additions & 2 deletions pref/Resources/base.lproj/Root.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
6 changes: 4 additions & 2 deletions pref/Resources/en.lproj/Root.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
6 changes: 4 additions & 2 deletions pref/Resources/vi.lproj/Root.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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ụ";
Expand Down
Binary file not shown.

0 comments on commit 962a3b8

Please sign in to comment.