https://github.com/user-attachments/assets/0e70bc8c-8564-44c7-ac28-064e975cf892

Open clear-macos-notifications in Script Kit

// Name: Clear MacOS notifications
// Description: Only visible notifications – clearing not visible notifications is not possible
import "@johnlindquist/kit"
await jxa(`
Application("System Events")
.applicationProcesses.byName("NotificationCenter")
.windows[0]
.groups[0]
.scrollAreas[0]
.uiElements[0]
.groups()
.map(banner => banner.actions().slice(-1)[0])
.forEach(banner => banner.perform())
`)
// Inspired by Kit's "applescript" function
async function jxa(script: string) {
await writeFile(kenvTmpPath("clear-macos-notifications.jxa"), script);
await execa("osascript", ["-l", "JavaScript", kenvTmpPath("clear-macos-notifications.jxa")]);
}