Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 533
Сергей Avatar asked Dec 05 '17 09:12

Сергей


1 Answers

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});
    }
});

}

like image 104
Сергей Avatar answered Oct 19 '22 14:10

Сергей