Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobcxdev committed Apr 5, 2020
2 parents b8ca3eb + 045ab5b commit 59d9b73
Show file tree
Hide file tree
Showing 18 changed files with 93 additions and 66 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.theos
.theos/
packages/
Binary file modified Media/Preferences.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion Tweak.x
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Foundation/Foundation.h>
Expand Down
4 changes: 2 additions & 2 deletions control
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion fbspnosorpreferences/FBPGradientHeaderCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
UIView *_blurContentView;
CAGradientLayer *_gradientLayer;
UIVisualEffectView *_blurView;
BOOL _animated;
bool _animated;
}
- (void)addAnimation;
@end
75 changes: 39 additions & 36 deletions fbspnosorpreferences/FBPGradientHeaderCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion fbspnosorpreferences/FBPLinkCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
NSString *_avatarImageSystemName;
NSString *_accessoryImageSystemName;
NSURL *_linkURL;
BOOL _shouldDisplayAvatar;
bool _shouldDisplayAvatar;
}
- (void)loadAvatarIfNeeded;
- (void)setAvatar:(UIImage *)image;
Expand Down
2 changes: 1 addition & 1 deletion fbspnosorpreferences/FBPLinkCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"]];

Expand Down
2 changes: 1 addition & 1 deletion fbspnosorpreferences/FBPPackageInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"]];
Expand Down
3 changes: 2 additions & 1 deletion fbspnosorpreferences/FBPRootListController.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#import <Preferences/PSListController.h>
#import <Preferences/PSSpecifier.h>
#import <NSTask.h>
#import "FBPPackageInfo.h"

@interface FBPRootListController : PSListController
- (void)killallFacebook;
- (void)killall;
@end
20 changes: 17 additions & 3 deletions fbspnosorpreferences/FBPRootListController.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "FBPRootListController.h"
#import "FBPRootListController.h"

@implementation FBPRootListController
- (instancetype)init {
Expand All @@ -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"]];
Expand Down
5 changes: 0 additions & 5 deletions fbspnosorpreferences/FBPSwitchTableCell.h

This file was deleted.

10 changes: 0 additions & 10 deletions fbspnosorpreferences/FBPSwitchTableCell.m

This file was deleted.

21 changes: 21 additions & 0 deletions fbspnosorpreferences/LICENSE
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions fbspnosorpreferences/NSString+Control.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ - (NSString *)stringByInterpolatingPackageInfoFromControl:(NSDictionary *)contro
NSString *string = [self copy];
NSError *error = nil;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\\{(?<fieldName>\\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];
Expand Down
4 changes: 2 additions & 2 deletions fbspnosorpreferences/Resources/Root.plist
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<string>Main Preferences</string>
</dict>
<dict>
<key>cellClass</key>
<string>FBPSwitchTableCell</string>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<true/>
<key>defaults</key>
Expand Down
Binary file not shown.

0 comments on commit 59d9b73

Please sign in to comment.