tweak插件代码:
//手机自动点击”信任“
%hook UIAlertController
- (void)viewDidAppear:(BOOL)animated {
%orig(animated); // 调用原始方法
if ([self.title isEqualToString:@"要信任此电脑吗?"] || [self.title isEqualToString:@"Trust This Computer?"]) {
NSLog(@"hook--[AutoTrust] 发现信任弹窗,尝试自动点击信任按钮"); // 遍历 UIAlertController 的 actions
for (UIAlertAction *action in self.actions) {
if ([action.title isEqualToString:@"信任"] || [action.title isEqualToString:@"Trust"]) {
NSLog(@"hook--[AutoTrust] 找到信任按钮,自动点击"); // 使用 KVC 获取 handler
id handler = [action valueForKey:@"handler"];
if (handler) {
((void(^)(UIAlertAction *))handler)(action); // 执行 handler
}
break;
}
}
}
}
%end