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

Commit

Permalink
Add more quality options when save video, Fix hide who to follow for …
Browse files Browse the repository at this point in the history
…latest Twitter, Add zh translation
  • Loading branch information
haoict committed Mar 26, 2021
1 parent 2ebc532 commit e8c57d2
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 24 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.theos
packages
HAOUtils*
HAOUtils*
**/.DS_Store
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
ARCHS = arm64 arm64e
TARGET = iphone:clang:12.4:10.0
TARGET = iphone:clang:13.6:12.0
INSTALL_TARGET_PROCESSES = Twitter Preferences

PREFIX = "$(THEOS)/toolchain/XcodeDefault-11.5.xctoolchain/usr/bin/"

include $(THEOS)/makefiles/common.mk

TWEAK_NAME = twitternoads
twitternoads_FILES = $(wildcard *.xm *.m)
twitternoads_EXTRA_FRAMEWORKS = libhdev
twitternoads_CFLAGS = -fobjc-arc
twitternoads_CFLAGS = -fobjc-arc -std=c++11

include $(THEOS_MAKE_PATH)/tweak.mk

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ Free & Open Source Tweak for Twitter app on iOS!
- Can Save Video (long press on video to save)
- Skip analytic URL when open a link
- Lightweight
- Support iOS 10 (not tested) - 11 (tested) - 12 (tested) - 13 (tested)
- Support latest Twitter version (If it doesn't work, you should update the app to latest version)
- Support iOS 12 - 14 & latest Twitter version

## Cydia Repo

Expand Down
34 changes: 20 additions & 14 deletions Tweak.xm
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,25 @@ static void reloadPrefs() {
nofleets = [[settings objectForKey:@"nofleets"] ?: @(NO) boolValue];
hideNewsAndTrending = [[settings objectForKey:@"hideNewsAndTrending"] ?: @(NO) boolValue];
hideWhoToFollow = [[settings objectForKey:@"hideWhoToFollow"] ?: @(NO) boolValue];
canSaveVideo = [[settings objectForKey:@"canSaveVideo"] ?: @(NO) boolValue];
canSaveVideo = [[settings objectForKey:@"canSaveVideo"] ?: @(YES) boolValue];
skipAnalyticUrl = [[settings objectForKey:@"skipAnalyticUrl"] ?: @(NO) boolValue];
}

static void showDownloadPopup(id twStatus, UIViewController *viewController, void (^origHandler)(UIAlertAction *)) {
UIAlertController* alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:IS_iPAD ? UIAlertControllerStyleAlert : UIAlertControllerStyleActionSheet];
[alert addAction:[UIAlertAction actionWithTitle:@"Save Video" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSString* videoUrl = nil;
if ([twStatus isKindOfClass:%c(TFNTwitterStatus)]) {
videoUrl = ((TFNTwitterStatus *)twStatus).primaryMediaVideoURL;
}
// if primary video is m3u8 format, we can't save it, thus we have to look for another place to find .mp4 and save highest bitrate
if (!videoUrl || [videoUrl containsString:@".m3u8"]) {
long long bitrate = 0;
for (TFSTwitterEntityMediaVideoVariant *video in ((id<T1StatusViewModel>)twStatus).primaryMediaInfo.mediaEntity.videoInfo.variants) {
if ([video.contentType isEqualToString:@"video/mp4"] && video.bitrate > bitrate) {
bitrate = video.bitrate;
videoUrl = video.url;
}
UIAlertController* qualitySelectionAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:IS_iPAD ? UIAlertControllerStyleAlert : UIAlertControllerStyleActionSheet];

int linkCount = 1;
for (TFSTwitterEntityMediaVideoVariant *video in ((id<T1StatusViewModel>)twStatus).primaryMediaInfo.mediaEntity.videoInfo.variants) {
if ([video.contentType isEqualToString:@"video/mp4"]) {
[qualitySelectionAlert addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:@"Link %d (bitrate: %lld)", linkCount++, video.bitrate] style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[[[HDownloadMediaWithProgress alloc] init] checkPermissionToPhotosAndDownload:video.url appendExtension:nil mediaType:Video toAlbum:@"Twitter" viewController:viewController];
}]];
}
}
[[[HDownloadMediaWithProgress alloc] init] checkPermissionToPhotosAndDownload:videoUrl appendExtension:nil mediaType:Video toAlbum:@"Twitter" viewController:viewController];
[qualitySelectionAlert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
[viewController presentViewController:qualitySelectionAlert animated:YES completion:nil];
}]];
[alert addAction:[UIAlertAction actionWithTitle:@"Twitter Options" style:UIAlertActionStyleDefault handler:origHandler]];
[alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
Expand Down Expand Up @@ -86,6 +83,11 @@ static void showDownloadPopup(id twStatus, UIViewController *viewController, voi
return tbvCell;
}

if ([itemClassName isEqualToString:@"T1Twitter.URTTimelineCarouselViewModel"]) {
[tbvCell setHidden: YES];
return tbvCell;
}

if ([itemClassName isEqualToString:@"T1URTFooterViewModel"] && [((T1URTFooterViewModel *)item).url.absoluteString containsString:@"connect_people"] ) {
[tbvCell setHidden: YES];
return tbvCell;
Expand Down Expand Up @@ -130,6 +132,10 @@ static void showDownloadPopup(id twStatus, UIViewController *viewController, voi
return 0;
}

if ([itemClassName isEqualToString:@"T1Twitter.URTTimelineCarouselViewModel"]) {
return 0;
}

if ([itemClassName isEqualToString:@"T1URTFooterViewModel"] && [((T1URTFooterViewModel *)item).url.absoluteString containsString:@"connect_people"] ) {
return 0;
}
Expand Down
7 changes: 3 additions & 4 deletions control
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: com.haoict.twitternoads
Name: Twitter No Ads
Depends: mobilesubstrate, preferenceloader, com.haoict.libhdev (>= 4.5.0), firmware (>= 10)
Version: 1.3.0
Depends: mobilesubstrate, preferenceloader, com.haoict.libhdev (>= 4.8.0), firmware (>= 12)
Version: 1.4.0
Architecture: iphoneos-arm
Description: Free & Open Source Tweak for Twitter
Free & Open Source Tweak for Twitter
Expand All @@ -15,8 +15,7 @@ Description: Free & Open Source Tweak for Twitter
- Can Save Video (long press on video to save)
- Skip analytic URL when open a link
- Lightweight
- Support iOS 10 (not tested) - 11 (tested) - 12 (tested) - 13 (tested)
- Support latest Twitter version (If it doesn't work, you should update the app to latest version)
- Support iOS 12 - 14 & latest Twitter app
.
I work very hard to make good, free and open source tweaks for everyone
If you want to support, you can buy me a coffee at https://www.paypal.me/haoict
Expand Down
2 changes: 1 addition & 1 deletion pref/Resources/Root.plist
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<key>cellClass</key>
<string>HPSSwitchCell</string>
<key>default</key>
<false/>
<true/>
<key>defaults</key>
<string>com.haoict.twitternoadspref</string>
<key>key</key>
Expand Down
30 changes: 30 additions & 0 deletions pref/Resources/zh.lproj/Root.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"HIDE_NEWS_AND_TRENDING_POST_ON_SEARCH_TAB": "在“搜索”选项卡上删除“新闻和趋势”帖子",
"CAN_SAVE_VIDEO": "启动保存视频",
"DONATION": "捐赠",
"FOUND_A_BUG": "报告错误",
"CONFIRM": "确认",
"LEAVE_A_BUG_REPORT_ON_GITHUB": "在 Github 上留下错误报告",
"OTHER_PREFERENCES": "其他偏好",
"REMOVE_ADS_IN_NEWS_FEED": "删除信息流中的广告",
"REMOVE_FLEETS_IN_NEWS_FEED": "删除信息流中的Fleets ",
"SEND_ME_AN_EMAIL_WITH_YOUR_REQUEST": "给我发送您的电子邮件请求",
"SKIP_ANALYTIC_URL": "跳过分析网址",
"SKIP_ANALYTIC_URL_WHEN_OPEN_A_LINK": "打开链接时跳过分析网址(t.co)",
"HIDE_WHO_TO_FOLLOW_SECTION": "去除首页顶部出现的推荐用户头像",
"HIDE_NEWS_AND_TRENDING": "屏蔽新闻和趋势",
"HIDE_WHO_TO_FOLLOW": "屏蔽要关注的人",
"CANCEL": "取消",
"LONG_PRESS_ON_VIDEO_TO_SAVE": "长按视频保存",
"APPLY": "重启应用",
"FEATURE_REQUEST": "功能要求",
"NO_FLEETS": "去除 Fleets",
"BUY_ME_A_COFFEE": "请我喝杯咖啡",
"SOURCE_CODE": "源码",
"NO_ADS": "去除广告",
"RESET_SETTINGS": "重置",
"SUPPORT_ME": "支持",
"DEFAULT": "默认",
"DO_YOU_REALLY_WANT_TO_KILL_TWITTER": "您真的要结束 Twitter 吗?",
"MAIN_PREFERENCES": "主要偏好"
}
Binary file not shown.

0 comments on commit e8c57d2

Please sign in to comment.