Сергей
Сергей

Reputation: 707

How to activate the function "Mute tab" in Google Chrome by the JavaScript?

I am developing an extension for Google Chrome.

Chrome has a "Mute tab" function which blocks the sounds from the site. When this function is activated, a "strikeout speaker" icon is shown on the tab.

The task of my extension is to activate this function and to block any sound in this way. How can I do this in JavaScript?

Upvotes: 6

Views: 7331

Answers (1)

Сергей
Сергей

Reputation: 707

I have learnt, how to do that:

 function turn_Off_On_Sound() {
  chrome.tabs.query({url: []}, function (tabs) {
    for (var i = 0; i < tabs.length; i++) {
      var mutedInfo = tabs[i].mutedInfo;
      if (mutedInfo) chrome.tabs.update(tabs[i].id, {"muted": true});
    }
});

}

Upvotes: 13

Related Questions