Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Oneechan69

macrumors regular
Original poster
Mar 29, 2022
212
27
US
I'd like to do that and might make an extension depending on if it's possible. I did some googling but didn't find anything, so I'm guessing not.
 

Oneechan69

macrumors regular
Original poster
Mar 29, 2022
212
27
US
I should've been more specific about what I want to do: I want a list of all the URLs open on Safari, either in one tab group or all of them; and get it either via Shortcuts, an API, or some other way. I can hold a tab group in the tabs menu and click "copy links." But that copies rich text of all the titles with the links, but when I try to get it in shortcuts, it only copies the titles.
 

Nygaard

macrumors member
Dec 7, 2022
47
20
Houston
What are you trying to do with the URLs in Shortcuts?

With respect to the extension, what you are looking for is called a Safari App Extension. (Not to be confused with a Safari Extension, it's antiquated kin.) It looks like, with the right permissions, you can iterate through all the tabs and get the URL of each. You'll need to try it out and see how it handles tab groups.

Also, in addition to having a terrible API, extensions are fairly constrained in what they can do. Even if you can pull the URLs, you may have trouble passing them off somewhere else.
 

Oneechan69

macrumors regular
Original poster
Mar 29, 2022
212
27
US
Does it say where in the API I could look to try that? Also, do you think it would be hard to just copy the URLs to the clipboard?
 

tgdn

macrumors newbie
Feb 29, 2024
1
1
You can access all the tabs in the background script of a Safari Extension on iOS by using the browser.tabs API:

const tabList = await browser.tabs.query({ currentWindow: true });

The tabs manifest permission allows you to call tabs.query() against four sensitive properties on tabs.Tab instances: url, pendingUrl, title, and favIconUrl.

If you don't need access to those, you can get the tab IDs using the above snippet of code.

The extension needs to have been activated and granted the authorizations first, otherwise browser.tabs.query will return undefined.
 
  • Like
Reactions: Oneechan69
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.