diff --git a/.gitignore b/.gitignore index 2ba817e..d8ca9e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.theos +.theos/ +packages/ \ No newline at end of file diff --git a/Media/Preferences.png b/Media/Preferences.png index c452b0b..082d99d 100644 Binary files a/Media/Preferences.png and b/Media/Preferences.png differ diff --git a/README.md b/README.md index 51aa04a..c0a9e25 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,4 @@ A tweak for Facebook — written in Objective-C + Logos. ## Screenshots -![Preferences](https://user-images.githubusercontent.com/27970288/77005163-44c4ad00-6958-11ea-99c0-a9061e6410df.png) +![Preferences](https://user-images.githubusercontent.com/27970288/78467318-5bfaed00-7703-11ea-8f0e-ce52c73640a7.png) diff --git a/Tweak.x b/Tweak.x index 444df90..781eea8 100644 --- a/Tweak.x +++ b/Tweak.x @@ -3,7 +3,7 @@ // FBSpNOsor // // Created by Jacob Clayden on 13/02/2020. -// Copyright © 2020 JacobCXDev. All rights reserved. +// Copyright © 2020 JacobCXDev. All rights reserved. // #import diff --git a/control b/control index b019ada..03b58f9 100644 --- a/control +++ b/control @@ -1,7 +1,7 @@ Package: com.jacobcxdev.fbspnosor Name: FBSpNOsor -Depends: mobilesubstrate -Version: 1.2.3 +Depends: mobilesubstrate, firmware (>= 11.0) +Version: 1.2.4 Architecture: iphoneos-arm Description: A tweak to remove sponsored and suggested posts, videos, etc. from Facebook. Maintainer: JacobCXDev diff --git a/fbspnosorpreferences/FBPGradientHeaderCell.h b/fbspnosorpreferences/FBPGradientHeaderCell.h index 83920f4..47a1ae5 100644 --- a/fbspnosorpreferences/FBPGradientHeaderCell.h +++ b/fbspnosorpreferences/FBPGradientHeaderCell.h @@ -8,6 +8,7 @@ UIView *_blurContentView; CAGradientLayer *_gradientLayer; UIVisualEffectView *_blurView; - BOOL _animated; + bool _animated; } +- (void)addAnimation; @end diff --git a/fbspnosorpreferences/FBPGradientHeaderCell.m b/fbspnosorpreferences/FBPGradientHeaderCell.m index a816555..a8160e0 100644 --- a/fbspnosorpreferences/FBPGradientHeaderCell.m +++ b/fbspnosorpreferences/FBPGradientHeaderCell.m @@ -41,42 +41,7 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr _gradientLayer.frame = self.bounds; [_blurView.layer insertSublayer:_gradientLayer atIndex:0]; - _animated = specifier.properties[@"animated"]; - if (_animated) { - [_gradientLayer removeAllAnimations]; - const CFTimeInterval duration = [(NSNumber *)specifier.properties[@"animationDuration"] doubleValue] ?: 15; - const CAKeyframeAnimation *startPointAnimation = [CAKeyframeAnimation animationWithKeyPath:@"startPoint"]; - startPointAnimation.values = @[[NSValue valueWithCGPoint:CGPointMake(0, 1)], - [NSValue valueWithCGPoint:CGPointMake(1, 1)], - [NSValue valueWithCGPoint:CGPointMake(1, 1)], - [NSValue valueWithCGPoint:CGPointMake(1, -1)], - [NSValue valueWithCGPoint:CGPointMake(1, -1)], - [NSValue valueWithCGPoint:CGPointMake(-1, -1)], - [NSValue valueWithCGPoint:CGPointMake(-1, -1)], - [NSValue valueWithCGPoint:CGPointMake(-1, 1)], - [NSValue valueWithCGPoint:CGPointMake(0, 1)], - [NSValue valueWithCGPoint:CGPointMake(0, 1)]]; - startPointAnimation.duration = duration; - const CAKeyframeAnimation *endPointAnimation = [CAKeyframeAnimation animationWithKeyPath:@"endPoint"]; - endPointAnimation.values = @[[NSValue valueWithCGPoint:CGPointMake(1, 0)], - [NSValue valueWithCGPoint:CGPointMake(1, 0)], - [NSValue valueWithCGPoint:CGPointMake(-1, 0)], - [NSValue valueWithCGPoint:CGPointMake(-1, 1)], - [NSValue valueWithCGPoint:CGPointMake(1, 1)], - [NSValue valueWithCGPoint:CGPointMake(1, 1)], - [NSValue valueWithCGPoint:CGPointMake(1, -1)], - [NSValue valueWithCGPoint:CGPointMake(1, -1)], - [NSValue valueWithCGPoint:CGPointMake(1, -1)], - [NSValue valueWithCGPoint:CGPointMake(1, 0)]]; - endPointAnimation.duration = duration; - - CAAnimationGroup *animationGroup = [[CAAnimationGroup alloc] init]; - animationGroup.animations = @[startPointAnimation, endPointAnimation]; - animationGroup.duration = duration; - animationGroup.repeatCount = INFINITY; - - [_gradientLayer addAnimation:animationGroup forKey:@"FBPAnimation"]; - } + _animated = specifier.properties[@"animated"] && [specifier.properties[@"animated"] boolValue]; if (specifier.properties[@"icon"]) _icon = [UIImage imageNamed:specifier.properties[@"icon"] inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil]; if (_icon) { @@ -143,7 +108,45 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr } return self; } +- (void)didMoveToWindow { + if (_animated) [self addAnimation]; +} - (void)layoutSubviews { _gradientLayer.frame = self.bounds; } +- (void)addAnimation { + [_gradientLayer removeAllAnimations]; + const CFTimeInterval duration = [(NSNumber *)_specifier.properties[@"animationDuration"] doubleValue] ?: 15; + const CAKeyframeAnimation *startPointAnimation = [CAKeyframeAnimation animationWithKeyPath:@"startPoint"]; + startPointAnimation.values = @[[NSValue valueWithCGPoint:CGPointMake(0, 1)], + [NSValue valueWithCGPoint:CGPointMake(1, 1)], + [NSValue valueWithCGPoint:CGPointMake(1, 1)], + [NSValue valueWithCGPoint:CGPointMake(1, -1)], + [NSValue valueWithCGPoint:CGPointMake(1, -1)], + [NSValue valueWithCGPoint:CGPointMake(-1, -1)], + [NSValue valueWithCGPoint:CGPointMake(-1, -1)], + [NSValue valueWithCGPoint:CGPointMake(-1, 1)], + [NSValue valueWithCGPoint:CGPointMake(0, 1)], + [NSValue valueWithCGPoint:CGPointMake(0, 1)]]; + startPointAnimation.duration = duration; + const CAKeyframeAnimation *endPointAnimation = [CAKeyframeAnimation animationWithKeyPath:@"endPoint"]; + endPointAnimation.values = @[[NSValue valueWithCGPoint:CGPointMake(1, 0)], + [NSValue valueWithCGPoint:CGPointMake(1, 0)], + [NSValue valueWithCGPoint:CGPointMake(-1, 0)], + [NSValue valueWithCGPoint:CGPointMake(-1, 1)], + [NSValue valueWithCGPoint:CGPointMake(1, 1)], + [NSValue valueWithCGPoint:CGPointMake(1, 1)], + [NSValue valueWithCGPoint:CGPointMake(1, -1)], + [NSValue valueWithCGPoint:CGPointMake(1, -1)], + [NSValue valueWithCGPoint:CGPointMake(1, -1)], + [NSValue valueWithCGPoint:CGPointMake(1, 0)]]; + endPointAnimation.duration = duration; + + CAAnimationGroup *animationGroup = [[CAAnimationGroup alloc] init]; + animationGroup.animations = @[startPointAnimation, endPointAnimation]; + animationGroup.duration = duration; + animationGroup.repeatCount = INFINITY; + + [_gradientLayer addAnimation:animationGroup forKey:@"FBPAnimation"]; +} @end diff --git a/fbspnosorpreferences/FBPLinkCell.h b/fbspnosorpreferences/FBPLinkCell.h index 2b4c8ea..916b6fb 100644 --- a/fbspnosorpreferences/FBPLinkCell.h +++ b/fbspnosorpreferences/FBPLinkCell.h @@ -8,7 +8,7 @@ NSString *_avatarImageSystemName; NSString *_accessoryImageSystemName; NSURL *_linkURL; - BOOL _shouldDisplayAvatar; + bool _shouldDisplayAvatar; } - (void)loadAvatarIfNeeded; - (void)setAvatar:(UIImage *)image; diff --git a/fbspnosorpreferences/FBPLinkCell.m b/fbspnosorpreferences/FBPLinkCell.m index d1797b5..2873d3a 100644 --- a/fbspnosorpreferences/FBPLinkCell.m +++ b/fbspnosorpreferences/FBPLinkCell.m @@ -9,7 +9,7 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr self.detailTextLabel.text = specifier.properties[@"subtitle"] ?: @""; _avatarImageSystemName = specifier.properties[@"avatarImageSystemName"]; _accessoryImageSystemName = specifier.properties[@"accessoryImageSystemName"]; - _shouldDisplayAvatar = specifier.properties[@"shouldDisplayAvatar"]; + _shouldDisplayAvatar = specifier.properties[@"shouldDisplayAvatar"] && [specifier.properties[@"shouldDisplayAvatar"] boolValue]; _avatarURL = [NSURL URLWithString:specifier.properties[@"avatarURL"]]; _linkURL = [NSURL URLWithString:specifier.properties[@"linkURL"]]; diff --git a/fbspnosorpreferences/FBPPackageInfo.m b/fbspnosorpreferences/FBPPackageInfo.m index 4c97d9c..70d87a8 100644 --- a/fbspnosorpreferences/FBPPackageInfo.m +++ b/fbspnosorpreferences/FBPPackageInfo.m @@ -28,7 +28,7 @@ + (void)setControlFromBundleID:(NSString *)bundleID { NSArray *matches = [regex matchesInString:output options:0 range:NSMakeRange(0, output.length)]; _control = [[NSMutableDictionary alloc] init]; for (NSTextCheckingResult *match in matches) - [_control setObject:[output substringWithRange:[match rangeWithName:@"fieldContent"]] forKey:[output substringWithRange:[match rangeWithName:@"fieldName"]]]; + _control[[output substringWithRange:[match rangeWithName:@"fieldName"]]] = [output substringWithRange:[match rangeWithName:@"fieldContent"]]; } + (void)retrieveControl { NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle bundleForClass:self.class] pathForResource:@"Info" ofType:@"plist"]]; diff --git a/fbspnosorpreferences/FBPRootListController.h b/fbspnosorpreferences/FBPRootListController.h index 5251b60..6d844d8 100644 --- a/fbspnosorpreferences/FBPRootListController.h +++ b/fbspnosorpreferences/FBPRootListController.h @@ -1,7 +1,8 @@ #import +#import #import #import "FBPPackageInfo.h" @interface FBPRootListController : PSListController -- (void)killallFacebook; +- (void)killall; @end diff --git a/fbspnosorpreferences/FBPRootListController.m b/fbspnosorpreferences/FBPRootListController.m index 1bab284..348db64 100644 --- a/fbspnosorpreferences/FBPRootListController.m +++ b/fbspnosorpreferences/FBPRootListController.m @@ -1,4 +1,4 @@ -#include "FBPRootListController.h" +#import "FBPRootListController.h" @implementation FBPRootListController - (instancetype)init { @@ -9,12 +9,26 @@ - (NSArray *)specifiers { if (!_specifiers) _specifiers = [self loadSpecifiersFromPlistName:@"Root" target:self]; return _specifiers; } +- (id)readPreferenceValue:(PSSpecifier*)specifier { + NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]]; + NSMutableDictionary *plist = [[NSMutableDictionary alloc] initWithContentsOfFile:path]; + return (plist[specifier.properties[@"key"]]) ?: specifier.properties[@"default"]; +} +- (void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier { + NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]]; + NSMutableDictionary *plist = [[NSMutableDictionary alloc] initWithContentsOfFile:path]; + plist[specifier.properties[@"key"]] = value; + [plist writeToFile:path atomically:true]; + CFStringRef notificationName = (__bridge CFStringRef)specifier.properties[@"PostNotification"]; + if (notificationName) + CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), notificationName, NULL, NULL, true); +} - (void)viewDidLoad { [super viewDidLoad]; - UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:@"Kill Facebook" style:UIBarButtonItemStylePlain target:self action:@selector(killallFacebook)]; + UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:@"Kill Facebook" style:UIBarButtonItemStylePlain target:self action:@selector(killall)]; self.navigationItem.rightBarButtonItem = button; } -- (void)killallFacebook { +- (void)killall { NSTask *killall = [[NSTask alloc] init]; [killall setLaunchPath:@"/usr/bin/killall"]; [killall setArguments:@[@"-9", @"Facebook"]]; diff --git a/fbspnosorpreferences/FBPSwitchTableCell.h b/fbspnosorpreferences/FBPSwitchTableCell.h deleted file mode 100644 index 2361c9c..0000000 --- a/fbspnosorpreferences/FBPSwitchTableCell.h +++ /dev/null @@ -1,5 +0,0 @@ -#import -#import - -@interface FBPSwitchTableCell : PSSwitchTableCell -@end diff --git a/fbspnosorpreferences/FBPSwitchTableCell.m b/fbspnosorpreferences/FBPSwitchTableCell.m deleted file mode 100644 index 45117e3..0000000 --- a/fbspnosorpreferences/FBPSwitchTableCell.m +++ /dev/null @@ -1,10 +0,0 @@ -#import "FBPSwitchTableCell.h" - -@implementation FBPSwitchTableCell -- (void)controlChanged:(UIControl *)control { - NSMutableDictionary *plist = [[NSMutableDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", _specifier.properties[@"defaults"]]]; - [plist setObject:[self controlValue] forKey:_specifier.properties[@"key"]]; - [plist writeToFile:[NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", _specifier.properties[@"defaults"]] atomically:1]; - [super controlChanged:control]; -} -@end diff --git a/fbspnosorpreferences/LICENSE b/fbspnosorpreferences/LICENSE new file mode 100644 index 0000000..9276035 --- /dev/null +++ b/fbspnosorpreferences/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Jacob Clayden + +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: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +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. diff --git a/fbspnosorpreferences/NSString+Control.m b/fbspnosorpreferences/NSString+Control.m index 548bda1..930b516 100644 --- a/fbspnosorpreferences/NSString+Control.m +++ b/fbspnosorpreferences/NSString+Control.m @@ -5,6 +5,7 @@ - (NSString *)stringByInterpolatingPackageInfoFromControl:(NSDictionary *)contro NSString *string = [self copy]; NSError *error = nil; NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\\{(?\\S+)\\}" options:0 error:&error]; + if (error) return self; NSArray *matches = [regex matchesInString:string options:0 range:NSMakeRange(0, string.length)]; for (int i = matches.count - 1; i >= 0; i--) { NSTextCheckingResult *match = matches[i]; diff --git a/fbspnosorpreferences/Resources/Root.plist b/fbspnosorpreferences/Resources/Root.plist index 633a725..dedc478 100644 --- a/fbspnosorpreferences/Resources/Root.plist +++ b/fbspnosorpreferences/Resources/Root.plist @@ -23,8 +23,8 @@ Main Preferences - cellClass - FBPSwitchTableCell + cell + PSSwitchCell default defaults diff --git a/packages/com.jacobcxdev.fbspnosor_1.2.3_iphoneos-arm.deb b/packages/com.jacobcxdev.fbspnosor_1.2.3_iphoneos-arm.deb deleted file mode 100644 index f89c9be..0000000 Binary files a/packages/com.jacobcxdev.fbspnosor_1.2.3_iphoneos-arm.deb and /dev/null differ