Last active
December 3, 2024 11:48
-
-
Save nbogie/c9f934927dc3d307192634462c1aaab4 to your computer and use it in GitHub Desktop.
applescript and js for midipipe to play/pause youtube video in chrome via a midi event.
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
on runme(message) | |
tell application "Google Chrome" | |
if (item 1 of message = 191) then | |
# Play or pause a video. | |
repeat with t in tabs of windows | |
tell t | |
if URL starts with "http://www.youtube.com/watch" or URL starts with "https://www.youtube.com/watch" then | |
if (item 1 of message = 191) and (item 2 of message = 117) and (item 3 of message > 0) then | |
execute javascript " | |
var v = document.querySelector('video'); | |
if (v.paused) { | |
v.play(); | |
} | |
else { | |
v.pause(); | |
} | |
" | |
exit repeat | |
end if | |
end if | |
end tell | |
end repeat | |
end if | |
end tell | |
end runme |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment