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.

 

Comments

Add Comments

Name:
Comment:

 

About

As someone who has worked on Macs since 1989, I will use my experience to share tips and tricks with you on Fridays. As a Mac user since 1989, I have seen the evolution of Mac software and hardware, and I know how Mac computers work. I also know how to troubleshoot and fix Mac problems that can arise.

Schedule

Monday Media Monday
TuesdayQA
WednesdaySnagIt for QA
ThursdayPython
FridayMacintosh
SaturdayInternet Tools
SundayOpen Topic