-- AppleScript -- -- This example is meant as a simple starting point to show how to get the information in the simplest available way. -- Keep in mind that when asking for a `return` after another, only the first one will be output. -- This method is as good as its JXA counterpart. -- Webkit variants include "Safari", "Webkit", "Orion". -- Specific editions are valid, including "Safari Technology Preview". -- "Safari" Example: tell application "Safari" to return name of front document tell application "Safari" to return URL of front document -- "Webkit" Example: tell application "Webkit" to return name of front document tell application "Webkit" to return URL of front document -- Chromium variants include "Google Chrome", "Chromium", "Opera", "Vivaldi", "Brave Browser", "Microsoft Edge". -- Specific editions are valid, including "Google Chrome Canary", "Microsoft Edge Dev". -- "Google Chrome" Example: tell application "Google Chrome" to return title of active tab of front window tell application "Google Chrome" to return URL of active tab of front window -- "Chromium" Example: tell application "Chromium" to return title of active tab of front window tell application "Chromium" to return URL of active tab of front window -- This example returns both the title and URL for the frontmost tab of the active browser, separated by a newline. -- For shorter code inclusive of all editions, only the start of the application name is checked. -- Keep in mind that to be able to use a variable in `tell application` — via `using terms from` — we’re basically requiring that referenced browser to be available on the system. -- That means that to use this on "Google Chrome Canary" or "Chromium", "Google Chrome" needs to be installed. Same for other browsers. -- This method also does not exit with a non-zero exit status when the frontmost application is not a supported browser. -- For the aforementioned reasons, this method is inferior to its JXA counterpart. tell application "System Events" to set frontApp to name of first process whose frontmost is true if (frontApp starts with "Safari") or (frontApp starts with "Webkit") or (frontApp starts with "Orion") then using terms from application "Safari" tell application frontApp to set currentTabTitle to name of front document tell application frontApp to set currentTabURL to URL of front document end using terms from else if (frontapp starts with "Google Chrome") or (frontApp starts with "Chromium") or (frontApp starts with "Opera") or (frontApp starts with "Vivaldi") or (frontApp starts with "Brave Browser") or (frontApp starts with "Microsoft Edge") then using terms from application "Google Chrome" tell application frontApp to set currentTabTitle to title of active tab of front window tell application frontApp to set currentTabURL to URL of active tab of front window end using terms from else return frontApp & " is not a supported browser" end if return currentTabURL & "\n" & currentTabTitle