Created
December 3, 2015 01:05
-
-
Save zachloubier/9b07fd21292a7dfb92d9 to your computer and use it in GitHub Desktop.
Scripts for controlling YouTube videos. Inspiration taken from https://gist.github.com/fent/7763775
This file contains 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
# Next Youtube Video in Playlist | |
tell application "Google Chrome" | |
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 | |
execute javascript " | |
var player = document.getElementById('movie_player') || document.getElementsByTagName('embed')[0]; | |
if (player) { | |
document.getElementsByClassName('ytp-next-button')[0].click() | |
} | |
" | |
exit repeat | |
end if | |
end tell | |
end repeat | |
end tell |
This file contains 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
# Play or pause a video. | |
tell application "Google Chrome" | |
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 | |
execute javascript " | |
var player = document.getElementById('movie_player') || document.getElementsByTagName('embed')[0]; | |
if (player) { | |
document.getElementsByClassName('ytp-play-button')[0].click() | |
} | |
" | |
exit repeat | |
end if | |
end tell | |
end repeat | |
end tell |
This file contains 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
# Previous Youtube Video in Playlist | |
tell application "Google Chrome" | |
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 | |
execute javascript " | |
var player = document.getElementById('movie_player') || document.getElementsByTagName('embed')[0]; | |
if (player) { | |
document.getElementsByClassName('ytp-prev-button')[0].click() | |
} | |
" | |
exit repeat | |
end if | |
end tell | |
end repeat | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment