I'd like use a macro that automatically closes or otherwise deals with Youtube ads.
There are two types, pre-roll and banner. The pre-roll is an ad that begins playing in front of a video for at least four seconds. When the four seconds are up, Youtube posts a "skip ad" button, which I'd like the macro to auto detect and click. When clicked, the remainder of the ad is abandoned and the video starts.There are some ads which go a variable number of seconds, typically 30, before the video starts and the 'skip ad' button is never posted; once the ad runs, the video starts at its end. The macro can ignore that kind.
The banner ad is posted atop of a video once it's playing. The banner ad contains a small square icon with an X in it in the ad's upper right corner, which, when clicked, makes the ad vanish. I'd like the macro to auto detect the X whenever it's posted by Youtube (it isn't always) and auto click it.
I understand how to prepare and use a "Move and Click from the Centre of the Found Image" action for each of these types, but the problem I'm having is figuring out how to trigger the macro to search for the ad types only when a Safari window's URL search box contains the "https://www.youtube.com.com" portion of a URL. That's because I don't particularly want the macro running the entire time I'm working in Safari on non-Youtube windows, which is most of the time. Ideally the macro would start searching for the X or the Skip Ad buttons whenever it detects a Youtube window is Safari's front window, and automatically stops watching the page when I move to a window with some non-Youtube URL. If it's not possible to create that trigger, and I'm not sure how it would go back to watching the page at the end. Aany suggestions for accomplish the concept would be welcome.
The two type of ads don't seem to appear at the same time. Normally, it's the Skip Ad button that appears firs, and it sticks around until it's clicked (manually, at the moment), followed by the banner X ad, which only appears a few seconds after the video begins. It stays up, usually, for most of the video unless the X is manually clicked.
I'm guessing it might be helpful for KM to have a trigger action that activates when a URL contains some variable text, but I didn't see anything in the list of triggers where that might be accomplished at the moment, unless there's a work-around with another type of trigger action.