Last active
October 17, 2023 22:50
-
-
Save n8henrie/5b8ca8a764cc563f260d98c92ea7eb56 to your computer and use it in GitHub Desktop.
Automatically click "ok" on the dozens of error notifications I get when syncing with MacOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/osascript -l JavaScript | |
function click_ok() { | |
const sys = Application('System Events') | |
const finder = sys.processes["Finder"] | |
try { | |
let sheets = finder.windows.whose({name: "NatePhone"}).sheets().flat() | |
let message = "cannot be played on this iPhone." | |
let error_sheet = sheets.filter(sheet => { | |
return sheet.staticTexts.whose({value: {_contains: message}}).first() | |
})[0] | |
let button = error_sheet.buttons.whose({name: "OK"}).first() | |
button.click() | |
return true | |
} catch (e) { | |
console.log(e) | |
return false | |
} | |
} | |
(function() { | |
var counter = 0 | |
while (counter < 10) { | |
if (click_ok()) { | |
counter = 0 | |
} else { | |
counter += 1 | |
delay(0.5) | |
} | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment