9.5 C
New York
Monday, November 18, 2024

macbook professional – How do I management the Play/Cease button for an internet site (e.g., YouTube) in my exterior monitor without having to maneuver my mouse out of my predominant display?


Within the Mission Management Preferences, choose the choice “Shows have separate Areas”.

enter image description here

enter image description here

When you have a YouTube video taking part in in both Google Chrome or Safari, these code snippets will play or pause a YouTube video in both your predominant or secondary monitor, whether or not or not Google Chrome or Safari is lively and visual, and whether or not or not the tabs are lively tabs or not

Google Chrome:

to clickClassName(theClassName, elementnum)
    inform utility "Google Chrome" to (tabs of window 1 whose URL comprises "youtube")
    set youtubeTabs to merchandise 1 of the outcome
    inform utility "Google Chrome"
        execute youtubeTabs javascript "doc.getElementsByClassName('" & theClassName & "')[" & elementnum & "].click on();"
    finish inform
finish clickClassName    

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

--clickClassName("ytp-prev-button ytp-button", 0)
--clickClassName("ytp-next-button ytp-button", 0)

Safari

to clickClassName2(theClassName, elementnum)
    if utility "Safari" is operating then
        strive
            inform utility "Safari"
                inform window 1 to set present tab to tab 1 whose URL comprises "youtube"
                do JavaScript "doc.getElementsByClassName('" & theClassName & "')[" & elementnum & "].click on();" in doc 1
            finish inform
        finish strive
    finish if
finish clickClassName2

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

--clickClassName("ytp-prev-button ytp-button", 0)
--clickClassName("ytp-next-button ytp-button", 0)

In Automator app, create a brand new doc and select “Service” as the sort. Add a “Run AppleScript” motion to the workflow. and insert the AppleScript code

enter image description here

Save your new Automator service and title it one thing like… “Pause YouTube Chrome”

After this, merely go to your keyboard shortcut preferences and assign your new service a keyboard shortcut.

enter image description here

Comply with that complete process two instances. One for Google Chrome and one for Safari.

Now it’s best to be capable of play or pause YouTube movies in Chrome or Safari, accessible by a keyboard shortcut or the “Providers” menu.

enter image description here

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles