Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whoaitsaimz/50366af12a8b231321ea66c8c9e0b0e2 to your computer and use it in GitHub Desktop.
Save whoaitsaimz/50366af12a8b231321ea66c8c9e0b0e2 to your computer and use it in GitHub Desktop.
AppleScript to activate specified tab by page title, OR open by URL if not already, and click buttons in webpage -- Google Chrome
tell application "Google Chrome"
activate
set tabfound to false
if (exists window 1) then
set i to 0
repeat with t in (tabs of window 1)
set i to i + 1
if title of t is "Noisli - Improve Focus and Boost Productivity with Background Noise" then
set (active tab index of window 1) to i
set tabfound to true
delay 1
--execute front window's active tab javascript "document.getElementById('menu-dashboard-span-combo').click();"
set query to "$('#menu-dashboard-span-combo').click(); $('.combo-span')[0].click();" as text
tell application "Google Chrome" to tell active tab of front window to set URL to "javascript:" & query
delay 1
end if
end repeat
if tabfound is false then
delay 1
activate
open location "https://www.noisli.com/"
delay 3
set query to "$('#menu-dashboard-span-combo').click(); $('.combo-span')[0].click();" as text
tell application "Google Chrome" to tell active tab of front window to set URL to "javascript:" & query
delay 1
activate
end if
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment