const until = args.until || "VPN 및 기기 관리";
const maxScrolls = Number(args.max || 10);
launch("com.apple.Preferences", { restart: true });
scroll("down", { until: "일반" });
tap("일반");
waitFor("정보");
const names = [];
let found = false;
let scrolls = 0;
while (true) {
const rows = read({ app: true })
.elements.filter((el) => el.role === "button" && el.label && !el.traits.includes("back_button"))
.sort((a, b) => a.frame.y - b.frame.y);
for (const el of rows) {
const name = el.label.split(",")[0].trim();
if (!names.includes(name)) names.push(name);
if (name === until) {
found = true;
break;
}
}
if (found || scrolls >= maxScrolls) break;
if (!scroll("down").screen_changed) break;
scrolls += 1;
}
log(`${names.length}개, 스크롤 ${scrolls}번, '${until}' ${found ? "찾음" : "못 찾음"}`);
return { names, found, scrolls };