Last active
August 21, 2023 01:07
-
-
Save ybbond/f09ad94de5376558cfe8276a2b460639 to your computer and use it in GitHub Desktop.
This will trigger Safari.app mute or unmute without the need to "Allow JavaScript from Apple Events"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-------------------------------------------------------------------------------- | |
# Auth: Yohanes Bandung Bondowoso | |
# dCre: 2021-07-11 20:52 | |
# dMod: 2021-07-13 19:57 | |
# Appl: System Events, Safari | |
# Task: Toggle Picture in Picture (PiP) on and off | |
# Libs: None | |
# Osax: None | |
# Aojc: None | |
# Tags: @Applescript, @Script, @System_Events, @Safari, @Mute | |
# Vers: 1.01 | |
-------------------------------------------------------------------------------- | |
try | |
tell application "System Events" | |
tell application "Safari" | |
set docItem to first item of documents | |
set tabName to name of docItem | |
end tell | |
tell application process "Safari" | |
tell window tabName | |
try | |
tell button 3 of group 4 of toolbar 1 | |
perform action "AXShowMenu" | |
end tell | |
if exists (menu item "Mute This Tab" of menu 1 of group 4 of toolbar 1) then | |
click menu item "Mute This Tab" of menu 1 of group 4 of toolbar 1 | |
else if exists (menu item "Unmute This Tab" of menu 1 of group 4 of toolbar 1) then | |
click menu item "Unmute This Tab" of menu 1 of group 4 of toolbar 1 | |
end if | |
on error toolbarErrMsg | |
return "Error Level::Toggle Mute:" & space & toolbarErrMsg | |
end try | |
end tell | |
end tell | |
end tell | |
do shell script "killall System\\ Events" | |
on error errMsg | |
return "Error Level::Top:" & space & errMsg | |
end try |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment