Skip to content

madaoCN/WKWebViewHook

Repository files navigation

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

About

hook WKWebViewHook request with NSURLProtocol

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published