• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!--
2Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
3source code is governed by a BSD-style license that can be found in the
4LICENSE file.
5-->
6
7<script>
8var selectedId = -1;
9function refreshLanguage() {
10  chrome.tabs.detectLanguage(null, function(language) {
11    console.log(language);
12    if (language == " invalid_language_code")
13      language = "???";
14    chrome.browserAction.setBadgeText({"text": language, tabId: selectedId});
15  });
16}
17
18chrome.tabs.onUpdated.addListener(function(tabId, props) {
19  if (props.status == "complete" && tabId == selectedId)
20    refreshLanguage();
21});
22
23chrome.tabs.onSelectionChanged.addListener(function(tabId, props) {
24  selectedId = tabId;
25  refreshLanguage();
26});
27
28chrome.tabs.getSelected(null, function(tab) {
29  selectedId = tab.id;
30  refreshLanguage();
31});
32</script>
33