Вы можете назначить ярлык для скрипта следующим образом:
tell application "Safari"
repeat with t in documents
tell t
if URL starts with "http://www.saavn.com/" then
do JavaScript "e = document.querySelectorAll('#pause:not(.hide)')[0] || document.querySelectorAll('#play:not(.hide)')[0]; e.click()"
exit repeat
end if
end tell
end repeat
end tell
Аналогичный скрипт для YouTube и Chrome:
tell application "Google Chrome"
repeat with t in tabs of windows
tell t
if URL starts with "http://www.youtube.com" then
execute javascript "player = document.querySelectorAll('#player embed')[0]
if (player) {
player.getPlayerState() == 1 ? player.pauseVideo() : player.playVideo()
} else { // if youtube.com/html5 is enabled
document.querySelectorAll('.html5-player-chrome > button:first-child')[0].click()
}"
exit repeat
end if
end tell
end repeat
end tell