-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTweak.xm
36 lines (33 loc) · 830 Bytes
/
Tweak.xm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#import <Foundation/Foundation.h>
#import <Foundation/NSObject.h>
#import <substrate.h>
#include <sys/mman.h>
#import <mach-o/dyld.h>
#include <stdlib.h>
#include <time.h>
#import "UIKit/UIKit.h"
NSString *newDomain = @"https://example.com";
%hook NSURL
+(NSURL *) URLWithString:(NSString *)URLString
{
if ([URLString hasPrefix:@"http"] && ![URLString hasPrefix:newDomain]) {
NSLog(@"nsurlhook: URLWithString:%@", URLString);
NSURL *urlObject = %orig(URLString);
NSString *path = [urlObject path];
NSString *newURLString = newDomain;
if(path != nil){
newURLString = [NSString stringWithFormat:@"%@%@", newURLString, path];
}
NSLog(@"nsurlhook: newUrl:%@", newURLString);
return %orig(newURLString);
}
return %orig(URLString);
}
%end
%ctor
{
@autoreleasepool
{
NSLog(@"nsurlhook: loaded");
}
}