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

Commit

Permalink
Add pref
Browse files Browse the repository at this point in the history
  • Loading branch information
haoict committed May 26, 2020
1 parent a93268b commit f5f05b7
Show file tree
Hide file tree
Showing 22 changed files with 413 additions and 49 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.theos
packages
packages
HAOUtils*
27 changes: 11 additions & 16 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
MIT License
Twitter No Ads

Copyright (c) 2020 Hao Nguyen <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
ARCHS = arm64 arm64e
TARGET = iphone:clang:12.2:12.2
DEBUG = 0
THEOS_DEVICE_IP = 192.168.1.21

INSTALL_TARGET_PROCESSES = Twitter
ARCHS = armv7 arm64 arm64e
TARGET = iphone:clang:12.2:10.0
INSTALL_TARGET_PROCESSES = Twitter Preferences

include $(THEOS)/makefiles/common.mk

TWEAK_NAME = twitternoads

twitternoads_FILES = Tweak.xm
twitternoads_FILES = $(wildcard *.xm *.m)
twitternoads_EXTRA_FRAMEWORKS = libhdev
twitternoads_CFLAGS = -fobjc-arc

include $(THEOS_MAKE_PATH)/tweak.mk

SUBPROJECTS += pref

include $(THEOS_MAKE_PATH)/aggregate.mk
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# Twitter No Ads

Tweak to remove "Promoted" post on Twitter app for iOS!
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)

Just install, no preferences. Require device jailbroken
Free & Open Source Tweak for Twitter app on iOS!

## Features
- Remove Ads
- 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)

## Cydia Repo

Expand All @@ -16,6 +23,12 @@ Just install, no preferences. Require device jailbroken
make do
```

## Contributors

[haoict](https://github.com/haoict)

Contributions of any kind welcome!

## License

Licensed under the MIT License, Copyright © 2020-present Hao Nguyen <[email protected]>
Licensed under the [GPLv3 License](./LICENSE), Copyright © 2020-present Hao Nguyen <[email protected]>
8 changes: 8 additions & 0 deletions Tweak.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#import <Foundation/Foundation.h>

#define PLIST_PATH "/var/mobile/Library/Preferences/com.haoict.twitternoadspref.plist"
#define PREF_CHANGED_NOTIF "com.haoict.twitternoadspref/PrefChanged"

@interface TFNItemsDataViewController : NSObject
- (id)itemAtIndexPath:(id)arg1;
@end
58 changes: 40 additions & 18 deletions Tweak.xm
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
@interface TFNItemsDataViewController : NSObject
- (id)itemAtIndexPath:(id)arg1;
@end

%hook TFNItemsDataViewController
- (id)tableViewCellForItem:(id)arg1 atIndexPath:(id)arg2 {
UITableViewCell *tbvCell = %orig;
id item = [self itemAtIndexPath: arg2];
if ([item respondsToSelector: @selector(isPromoted)] && [item performSelector:@selector(isPromoted)]) {
[tbvCell setHidden: YES];
}
return tbvCell;
#import "Tweak.h"

/**
* Load Preferences
*/
BOOL noads;

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

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

- (double)tableView:(id)arg1 heightForRowAtIndexPath:(id)arg2 {
id item = [self itemAtIndexPath: arg2];
if ([item respondsToSelector: @selector(isPromoted)] && [item performSelector:@selector(isPromoted)]) {
return 0;
%group NoAds
%hook TFNItemsDataViewController
- (id)tableViewCellForItem:(id)arg1 atIndexPath:(id)arg2 {
UITableViewCell *tbvCell = %orig;
id item = [self itemAtIndexPath: arg2];
if ([item respondsToSelector: @selector(isPromoted)] && [item performSelector:@selector(isPromoted)]) {
[tbvCell setHidden: YES];
}
return tbvCell;
}

- (double)tableView:(id)arg1 heightForRowAtIndexPath:(id)arg2 {
id item = [self itemAtIndexPath: arg2];
if ([item respondsToSelector: @selector(isPromoted)] && [item performSelector:@selector(isPromoted)]) {
return 0;
}
return %orig;
}
return %orig;
%end
%end

%ctor {
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback) reloadPrefs, CFSTR(PREF_CHANGED_NOTIF), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
reloadPrefs();

if (!noads) {
return;
}

%init(NoAds);
}
%end
17 changes: 14 additions & 3 deletions control
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
Package: com.haoict.twitternoads
Name: Twitter No Ads
Depends: mobilesubstrate
Version: 0.0.2
Depends: mobilesubstrate, preferenceloader, com.haoict.libhdev, firmware (>= 10)
Version: 1.0.0
Architecture: iphoneos-arm
Description: Hide "Promoted" post for Twitter app
Description: Free & Open Source Tweak for Twitter
Free & Open Source Tweak for Twitter
Features:
- Remove Ads
- 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)
.
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
.
Thanks a ton
Maintainer: Hao Nguyen
Author: Hao Nguyen
Section: Tweaks
Binary file added photoshop/icon.psd
Binary file not shown.
Binary file added photoshop/tnabanner.psd
Binary file not shown.
16 changes: 16 additions & 0 deletions pref/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ARCHS = armv7 arm64 arm64e

include $(THEOS)/makefiles/common.mk

BUNDLE_NAME = TNAPref
TNAPref_FILES = $(wildcard *.m)
TNAPref_INSTALL_PATH = /Library/PreferenceBundles
TNAPref_PRIVATE_FRAMEWORKS = Preferences
TNAPref_EXTRA_FRAMEWORKS = libhdev
TNAPref_CFLAGS = -fobjc-arc

include $(THEOS_MAKE_PATH)/bundle.mk

internal-stage::
$(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END)
$(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/TNAPref.plist$(ECHO_END)
Binary file added pref/Resources/Banner.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions pref/Resources/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>TNAPref</string>
<key>CFBundleIdentifier</key>
<string>com.haoict.twitternoadspref</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSPrincipalClass</key>
<string>TNARootListController</string>
</dict>
</plist>
18 changes: 18 additions & 0 deletions pref/Resources/Localization-contribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
I'm working on localization, if you like my tweak and want to help, you can help me translate to your language.

(Finished languages are here: https://github.com/haoict/twitternoads/tree/master/pref/Resources)

Here are base strings

```
"DO_YOU_REALLY_WANT_TO_KILL_TWITTER" = "Do you really want to kill Twitter?";
"REMOVE_ADS_IN_NEWS_FEED" = "Remove Ads in News Feed";
```

After you finished translation, Please save and name it with your language code (if you don't know, just write down your country name)

E.g: English -> en, Japanese -> ja, Vietnamese -> vi...

And your nick name, I will add to Contributors part.

Finally, send me the result to my email "[email protected]" or open issue on github.
Loading

0 comments on commit f5f05b7

Please sign in to comment.