Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iMokhles/040fd935c183787fba3f to your computer and use it in GitHub Desktop.
Save iMokhles/040fd935c183787fba3f to your computer and use it in GitHub Desktop.
How to use the old prefs method within sandbox apps
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