Last active
August 29, 2015 14:14
-
-
Save iMokhles/040fd935c183787fba3f to your computer and use it in GitHub Desktop.
How to use the old prefs method within sandbox apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static BOOL tweakEnabled = NO; | |
static void PreferencesChangedCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { | |
system("killall WhatsApp"); // kill app to apply changes ;) | |
NSDictionary *preferences = [[NSDictionary alloc] initWithContentsOfFile:@"TWEAK_PREFS_PATH"]; | |
tweakEnabled = [preferences[@"tweakEnabled"] boolValue]; | |
} | |
%ctor { | |
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidFinishLaunchingNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *block) { | |
NSDictionary *preferences = [[NSDictionary alloc] initWithContentsOfFile:@"TWEAK_PREFS_PATH"]; | |
if (preferences == nil) { | |
preferences = @{ @"tweakEnabled" : @(NO)}; | |
[preferences writeToFile:PREFERENCES_PATH atomically:YES]; | |
tweakEnabled = NO; | |
} else { | |
tweakEnabled = [preferences[@"tweakEnabled"] boolValue]; | |
} | |
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, PreferencesChangedCallback, CFSTR("TWEAK_NOTIFICATION_NAME"), NULL, CFNotificationSuspensionBehaviorCoalesce); | |
}]; | |
} | |
// Hook WhatsApp to don't send images ;) | |
%hook ChatViewController | |
- (void)sendImage:(id)arg1 caption:(id)arg2 { | |
if (tweakEnabled) { | |
return | |
} else { | |
%orig; | |
} | |
} | |
%ene |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment