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.

 

About

A Mac veteran since 1989, I'm here to share my experience with tips and tricks every Friday. Witnessing the evolution of Mac software and hardware firsthand, I've gained a deep understanding of how these machines work and can help you troubleshoot any issues that may come up.

Schedule

FridayMacintosh
SaturdayInternet Tools
SundayOpen Topic
MondayMedia Monday
TuesdayQA
WednesdayAffinity
ThursdayBBEdit