QA Graphic

AppleScript Sample

Getting the current active URL in Google Chrome

AppleScript is a scripting language that automates tasks on Apple devices. It is a powerful tool that can control various applications on your Mac. In this blog post, we will discuss how to use AppleScript to get the URL of the current tab in Google Chrome.

Getting the URL of the current tab in Google Chrome

Here is a sample AppleScript that can be used to get the URL of the current tab in Google Chrome:


tell application "Google Chrome"
	set sedCommand to "s/"- Jira"//g"
	set broswerurl to get URL of active tab of first window
	set browsertitle to get title of active tab of first window
	set myecho to "echo " & browsertitle & " | sed `" & sedCommand & "`"
	set mytitle to do shell script "echo " & browsertitle & " | sed " & sedCommand & ""
	set the clipboard to "[" & mytitle & "](" & broswerurl & ")"
end tell

This is an excellent piece of code because it filters out the word "Jira" when you are getting the current Jira Issue.

This works for Slack, but you can easily modify the "set clipboard" to whatever output that you want.

  Filed under the Macintosh category. - Permalink

About

My Friday Blog tips and tricks will be based on my experiences using a Macintosh computer since 1989. I have seen the evolution of the Macintosh software and hardware, and have a good understanding of the capabilities of a Macintosh computer. I also have experience in troubleshooting and fixing problems that can occur with a Mac.