I'm trying to understand how to determine if a YouTube video/s is playing in a tab/s on a web browser (Chrome or Safari) and retrieve information like name of the video and the YouTube channel and play or pause the video. Similar to Bearded Spice. I've tried to understand the code of Bearded Spice, but I'm not familiar with Objective-C and there is no extensive documentation.
I know that tabs can be iterated thought and headings can be retrieved using AppleScript. But I'm unable to get the state of the player and some information about the video playing. I don't want to use Chrome and Safari extensions as I'm trying to achieve this using a native app for MacOS. Please point me in the right direction to achieve this.