Detecting the current tab language using Chrome ex

2019-07-15 21:53发布

问题:

Is there a way to use chrome API to detect the language of the current content in the current tab?

回答1:

Use the Chrome Tabs API to select the current tab, then get the language.

Sample usage:

//Get language of current tab
chrome.tabs.getSelected(null, function(tab) {
  chrome.tabs.detectLanguage(tab.id, function(language) {
    console.log(language);
  });
});


回答2:

Yes: chrome.tabs.detectLanguage. See http://code.google.com/chrome/extensions/tabs.html#method-detectLanguage.