Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 835 Bytes

README.md

File metadata and controls

31 lines (24 loc) · 835 Bytes

WKWebViewHook

hook WKWebViewHook request with NSURLProtocol

hook every loading URL request with use NSURLProtocol

+ (BOOL)canInitWithRequest:(NSURLRequest *)request
{
    NSString *scheme = [[request URL] scheme];
    if ([scheme caseInsensitiveCompare:HttpProtocolKey] == NSOrderedSame ||
        [scheme caseInsensitiveCompare:HttpsProtocolKey] == NSOrderedSame)
    {
        // avoid endless loop
        if ([NSURLProtocol propertyForKey:kURLProtocolHandledKey inRequest:request]) {
            return NO;
        }
    }
    
    return YES;
}

+ (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
    
    NSMutableURLRequest *mutableReqeust = [request mutableCopy];
    return mutableReqeust;
}

screenshot

pic