logoalt Hacker News

joemiyesterday at 10:27 PM1 replyview on HN

> - Dumping all open Safari tabs to an Obsidian doc

I'd love to do this too. Would you mind sharing how you do it? Or is it trivially easy and not worth explaining? (I haven't looked too deeply into HS yet.)


Replies

michaeltetertoday at 12:45 AM

I have no idea how that person is doing it, but I suspect it could be using osascript. Here's how I do it from my homegrown Go bookmark tool:

  const fetchTabsScript = `
  tell application "Brave Browser"
      set output to ""
      repeat with w in windows
          repeat with t in tabs of w
              set output to output & (URL of t) & "|||" & (title of t) & "\n"
          end repeat
      end repeat
      return output
  end tell
  `  
  
  func GetOpenTabs() ([]Tab, error) {
   cmd := exec.Command("osascript", "-e", fetchTabsScript)
   output, err := cmd.Output()
    // ...
  }