// // WKWebView+QX.m // YBLive // // Created by 启星 on 2025/4/16. // Copyright © 2025 cat. All rights reserved. // #import "WKWebView+QX.h" @implementation WKWebView (QX) + (void)load{ Method method1 = class_getInstanceMethod([self class],@selector(loadRequest:)); Method method2 = class_getInstanceMethod([self class],@selector(qx_loadRequest:)); method_exchangeImplementations(method1, method2); } -(void)qx_loadRequest:(NSURLRequest*)request{ if ([self isProxyEnabled]) { [self qx_loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https:www.baidu.com"]]]; }else{ [self qx_loadRequest:request]; } } -(BOOL)isProxyEnabled{ NSArray *criticalDomains = @[ H5ServerUrl, ServerUrl, ]; NSDictionary *proxySettings = (__bridge NSDictionary *)CFNetworkCopySystemProxySettings(); for (NSString *domain in criticalDomains) { NSArray *proxies = (__bridge NSArray *)CFNetworkCopyProxiesForURL( (__bridge CFURLRef)[NSURL URLWithString:domain], (__bridge CFDictionaryRef)proxySettings ); // 检查每个域名的代理情况... for (NSDictionary *proxy in proxies) { NSString *proxyType = proxy[(NSString *)kCFProxyTypeKey]; if (![proxyType isEqualToString:(NSString *)kCFProxyTypeNone]) { return YES; // 存在代理或 VPN } } } return NO; } @end