Closing an iCloud Tab?

I would like to script the closing of a specific icloud tab of my choice.

Ideally, I’d prefer to do this without using GUI scripting.

Options tried so far…

1. Toolbar

In Desktop Safari you can enable a toolbar button “iCloud Tabs” which when clicked shows a list of the tabs currently open on your other devices.

If you hover one, an X appears which can be clicked to close the tab. When you next use Safari on the remote device that tab will be closed. If it’s already open and awake then the removal happens around one second later. It’s quick.

(But I did try GUI scripting and I can get to the row in the outline in the popup, but I can’t get the cross to appear to click it)

2. Start Page

they’re also listed on favorites:// “start page” but there are issues viewing all and no way to search them. There used to be until Safari 15.

3. Omnibar

They’re also shown in omnibar but getting that item to appear is fragile.

4. Sidebar

Another alternative to the startpage layout. Same issues.

Are you talking about closing them on all devices, so if you to another device they’ll be closed?

I don’t think you can use AppleScript to do it, cos the “truth” isn’t stored on the local machine

Details of iCloud tabs are stored in a local database. I can’t remember the name right now. But my guess is you could remove the tab from that database - however it would just remove it from the local view. The next time iCloud syncs, the tab will come back if it’s still open on the other device

I wonder if you could get AppleScript to open a synced tab so it’s a local tab, and then close it, but I don’t think that’ll close it cos the “true” tab is on the device that opened it

Sorry, a lot of words to say “I’m not sure but I don’t think you can do it :slightly_smiling_face:

Yeah, deleting from database doesn’t trigger sync.

Safari does it via cloudd, which is the reason I want to automate/script it.

I fear you are correct