diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2017-02-16 01:30:53 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2017-02-16 01:30:53 -0800 |
commit | a3d01a768f0e7f9d5a36b4bcea04458634818863 (patch) | |
tree | a3e62c81f8cf286cabe0bdf382c95caaf0722d0d /CyteKit/WebViewController.mm | |
parent | 68df8c0b7bacec286d4798408b5a110bdac88986 (diff) |
Move a bunch of clearly shared logic into CyteKit.
Diffstat (limited to 'CyteKit/WebViewController.mm')
-rw-r--r-- | CyteKit/WebViewController.mm | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/CyteKit/WebViewController.mm b/CyteKit/WebViewController.mm index 20838bf..40b1200 100644 --- a/CyteKit/WebViewController.mm +++ b/CyteKit/WebViewController.mm @@ -19,6 +19,8 @@ extern NSString * const kCAFilterNearest; #include <dlfcn.h> #include <objc/runtime.h> +#include "Substrate.hpp" + #define ForSaurik 0 #define DefaultTimeout_ 120.0 @@ -1297,3 +1299,29 @@ float CYScrollViewDecelerationRateNormal; } @end + +MSClassHook(WAKWindow) + +static CGSize $WAKWindow$screenSize(WAKWindow *self, SEL _cmd) { + CGSize size([[UIScreen mainScreen] bounds].size); + /*if ([$WAKWindow respondsToSelector:@selector(hasLandscapeOrientation)]) + if ([$WAKWindow hasLandscapeOrientation]) + std::swap(size.width, size.height);*/ + return size; +} + +static struct WAKWindow$screenSize { WAKWindow$screenSize() { + if ($WAKWindow != NULL) + if (Method method = class_getInstanceMethod($WAKWindow, @selector(screenSize))) + method_setImplementation(method, (IMP) &$WAKWindow$screenSize); +} } WAKWindow$screenSize;; + +MSClassHook(NSUserDefaults) + +MSHook(id, NSUserDefaults$objectForKey$, NSUserDefaults *self, SEL _cmd, NSString *key) { + if ([key respondsToSelector:@selector(isEqualToString:)] && [key isEqualToString:@"WebKitLocalStorageDatabasePathPreferenceKey"]) + return [NSString stringWithFormat:@"%@/%@/%@", NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject, NSBundle.mainBundle.bundleIdentifier, @"LocalStorage"]; + return _NSUserDefaults$objectForKey$(self, _cmd, key); +} + +CYHook(NSUserDefaults, objectForKey$, objectForKey:) |