gurkensaas
gurkensaas

Reputation: 903

Is there a way to mute a tab in Google Chrome using AppleScript?

So I wanted to make a little script that e.g. mutes all tabs whose URL contains google.com. I wanted to do something like this:

tell application "Google Chrome"
    set theWindows to windows of application "Google Chrome"
    repeat with theWindow in theWindows
        set theTabs to (tabs of theWindow whose URL contains "google.com")
        repeat with theTab in theTabs
            tell theTab
                mute
            end tell
        end repeat
    end repeat
end tell

But if you try to run this, you will soon notice that Applescript thinks mute is a variable. I also tried mute tab but it also doesn't work.

Upvotes: 0

Views: 586

Answers (2)

wch1zpink
wch1zpink

Reputation: 3142

There is no default keyboard shortcut assigned for the Tab Menu Item “Mute Site” in Google Chrome. However, you can assign it a custom keyboard shortcut and use it manually or in an AppleScript with a keystroke or key code command.

This following image shows how I assigned that custom keyboard shortcut.

enter image description here

Once your custom keyboard shortcut is properly set up, this following AppleScript code is an example of how I personally have mine set up.

tell application "Google Chrome" to activate

delay 0.1

tell application "System Events"
    key code 49 using {shift down, command down}
end tell

Upvotes: 1

Mockman
Mockman

Reputation: 1181

This should allow for the muting of tabs:

tell application "Google Chrome" to activate
tell application "System Events" to ¬
    click ¬
        menu item "Mute Site" of ¬
        menu 1 of ¬
        menu bar item "Tab" of ¬
        menu bar 1 of ¬
        application process "Chrome"

Upvotes: 1

Related Questions