<commit_before>'use strict';

// When the user clicks browserAction icon in toolbar, execute runLightbeam function
browser.browserAction.onClicked.addListener(runLightbeam);

async function runLightbeam() {

  // Checks to see if Lightbeam is already open. Returns true if it is, false if not.
  async function isOpen() {
    const tabs = await browser.tabs.query({});
    const fullUrl = browser.extension.getURL('index.html');
    const lightbeamTabs = tabs.filter((tab) => {
      return (tab.url === fullUrl);
    });
    return lightbeamTabs[0] || false;
  }

  // Only open a new Lightbeam instance if one isn't already open.
  const lightbeamTab = await isOpen();
  if (!lightbeamTab) {
    browser.tabs.create({url: 'index.html'});
  }
}<commit_msg>Re-focus tab on subsequent icon clicks. Fixes #14.<commit_after>'use strict';

// When the user clicks browserAction icon in toolbar, run Lightbeam
browser.browserAction.onClicked.addListener(runLightbeam);

async function runLightbeam() {
  // Checks to see if Lightbeam is already open. Returns true if it is, false if not.
  async function isOpen() {
    const tabs = await browser.tabs.query({});
    const fullUrl = browser.extension.getURL('index.html');
    const lightbeamTabs = tabs.filter((tab) => {
      return (tab.url === fullUrl);
    });
    return lightbeamTabs[0] || false;
  }

  const lightbeamTab = await isOpen();
  if (!lightbeamTab) {
    // only open a new Lightbeam instance if one isn't already open.
    browser.tabs.create({url: 'index.html'});
  } else if (!lightbeamTab.active) {
     // re-focus Lightbeam if it is already open but lost focus
    browser.tabs.update(lightbeamTab.id, {active: true});
  }
}
{'fraction_non_alphanumeric': 0.12212389380530973, 'fraction_numerical': 0.002359882005899705, 'mean_word_length': 3.659340659340659, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3569358', 'n_tokens_mistral': 537, 'n_tokens_neox': 499, 'n_words': 164}