Pause/Play YouTube Video Running in Background

I love to listen to YouTube videos like Podcasts while working. I bet many people do have this habit.

    to clickClassName(theClassName, elementnum)
	tell application "Google Chrome" to (tabs of window 1 whose URL contains "youtube")
	set youtubeTabs to item 1 of the result
	tell application "Google Chrome"
		execute youtubeTabs javascript "document.getElementsByClassName('" & theClassName & "')[" & elementnum & "].click();"
	end tell
end clickClassName

clickClassName("ytp-play-button ytp-button", 0)

The above AppleScript is for Google Chrome.

Source: https://apple.stackexchange.com/questions/281483/how-to-pause-youtube-video-via-keyboard-shortcut-or-from-menu-bar/281567

2 Likes

I love this macro. It’s very useful when I’m learning - with Chrome running YouTube in the 2nd monitor and XCode on the first monitor and pausing to enter codes. Thank you.

Is there a similar Apple
script command to backward the video by 15 seconds?