<commit_before>var Browser = {
  msgUnsupported: 'ERROR: Unsupported browser',

  setIcon: function(path) {
    if (BROWSER == 'Chrome') {
      if (chrome.browserAction != undefined) {
        chrome.browserAction.setIcon({path: path});
      }
    }
    else if (BROWSER == 'Opera') {
      // If this is the background page
      if (typeof OPERA_BUTTON != "undefined") {
        OPERA_BUTTON.icon = path;
      }
      // If this is another page reference button through background process
      else {
        this.getBackgroundProcess().OPERA_BUTTON.icon = path;
      }
    }
    else {
      console.log(this.msgUnsupported);
    }
  },

  setTitle: function(title) {
    if (BROWSER == 'Chrome') {
      if (chrome.browserAction != undefined) {
        chrome.browserAction.setTitle({title: title});
      }
    }
    else if (BROWSER == 'Opera') {
      // If this is the background page
      if (typeof OPERA_BUTTON != "undefined") {
        OPERA_BUTTON.title = title;
      }
      // If this is another page reference button through background process
      else {
        this.getBackgroundProcess().OPERA_BUTTON.title = title;
      }
    }
    else {
      console.log(this.msgUnsupported);
    }
  },

  setBadgeText: function(text) {
    if (typeof text == 'undefined' || text == null || text == 0 || text == '0') {
      text = '';
    }
    if (BROWSER == 'Chrome') {
      if (chrome.browserAction != undefined) {
        chrome.browserAction.setBadgeText({text: text});
      }
    }
    else if (BROWSER == 'Opera') {
      // If this is the background page
      if (typeof OPERA_BUTTON != "undefined") {
        OPERA_BUTTON.badge.textContent = text;
      }
      // If this is another page reference button through background process
      else {
        this.getBackgroundProcess().OPERA_BUTTON.badge.textContent = text;
      }
    }
    else {
      console.log(this.msgUnsupported);
    }
  },

  openTab: function(url) {
    if (BROWSER == 'Chrome') {
      if (chrome.tabs != undefined) {
        chrome.tabs.create({url: url, selected: true});
      }
    }
    else if (BROWSER == 'Opera') {
      // If this is the background page
      if (typeof OPERA_BUTTON != "undefined") {
        if (opera.extension.tabs) {
          opera.extension.tabs.create({url: url, focused: true});
        }
        else {
          console.log('ERROR: Opera tab creation not avaliable');
        }
      }
      // Recurse to the background page
      else {
        this.getBackgroundProcess().Browser.openTab(url);
      }
    }
    else {
      console.log(this.msgUnsupported);
    }
  },

  openBackgroundTab: function(url) {
    if (BROWSER == 'Chrome') {
      if (chrome.tabs != undefined) {
        chrome.tabs.create({url: url, selected: false});
      }
    }
    else if (BROWSER == 'Opera') {
      // If this is the background page
      if (typeof OPERA_BUTTON != "undefined") {
        if (opera.extension.tabs) {
          opera.extension.tabs.create({url: url, focused: false});
        }
        else {
          console.log('ERROR: Opera tab creation not avaliable');
        }
      }
      // Recurse to the background page
      else {
        this.getBackgroundProcess().Browser.openBackgroundTab(url);
      }
    }
    else {
      console.log(this.msgUnsupported);
    }
  },

  getBackgroundProcess: function() {
    if (BROWSER == 'Chrome') {
      if (chrome.extension != undefined) {
        return chrome.extension.getBackgroundPage();
      }
    }
    else if (BROWSER == 'Opera') {
      return opera.extension.bgProcess;
    }
    else {
      console.log(this.msgUnsupported);
    }
  },

  // FUNCTIONS BELOW ARE NOT YET FULLY IMPLEMENTED

  createNotification: function(path) {
    // For future reference, support for webkit notifications can be
    // tested with (!window.webkitNotifications)
    if (BROWSER == 'Chrome') {
      // Check if browser is active, not "idle" or "locked"
      if (chrome.idle) {
        chrome.idle.queryState(15, function (state) {
          if (state == 'active') {
            notification = webkitNotifications.createHTMLNotification(path);
            notification.show();
          }
          else {
            if (DEBUG) console.log('Notification not sent, state was', state);
          }<commit_msg>browser: increased the tolerance for what's considered an idle user<commit_after>var Browser = {
  msgUnsupported: 'ERROR: Unsupported browser',

  setIcon: function(path) {
    if (BROWSER == 'Chrome') {
      if (chrome.browserAction != undefined) {
        chrome.browserAction.setIcon({path: path});
      }
    }
    else if (BROWSER == 'Opera') {
      // If this is the background page
      if (typeof OPERA_BUTTON != "undefined") {
        OPERA_BUTTON.icon = path;
      }
      // If this is another page reference button through background process
      else {
        this.getBackgroundProcess().OPERA_BUTTON.icon = path;
      }
    }
    else {
      console.log(this.msgUnsupported);
    }
  },

  setTitle: function(title) {
    if (BROWSER == 'Chrome') {
      if (chrome.browserAction != undefined) {
        chrome.browserAction.setTitle({title: title});
      }
    }
    else if (BROWSER == 'Opera') {
      // If this is the background page
      if (typeof OPERA_BUTTON != "undefined") {
        OPERA_BUTTON.title = title;
      }
      // If this is another page reference button through background process
      else {
        this.getBackgroundProcess().OPERA_BUTTON.title = title;
      }
    }
    else {
      console.log(this.msgUnsupported);
    }
  },

  setBadgeText: function(text) {
    if (typeof text == 'undefined' || text == null || text == 0 || text == '0') {
      text = '';
    }
    if (BROWSER == 'Chrome') {
      if (chrome.browserAction != undefined) {
        chrome.browserAction.setBadgeText({text: text});
      }
    }
    else if (BROWSER == 'Opera') {
      // If this is the background page
      if (typeof OPERA_BUTTON != "undefined") {
        OPERA_BUTTON.badge.textContent = text;
      }
      // If this is another page reference button through background process
      else {
        this.getBackgroundProcess().OPERA_BUTTON.badge.textContent = text;
      }
    }
    else {
      console.log(this.msgUnsupported);
    }
  },

  openTab: function(url) {
    if (BROWSER == 'Chrome') {
      if (chrome.tabs != undefined) {
        chrome.tabs.create({url: url, selected: true});
      }
    }
    else if (BROWSER == 'Opera') {
      // If this is the background page
      if (typeof OPERA_BUTTON != "undefined") {
        if (opera.extension.tabs) {
          opera.extension.tabs.create({url: url, focused: true});
        }
        else {
          console.log('ERROR: Opera tab creation not avaliable');
        }
      }
      // Recurse to the background page
      else {
        this.getBackgroundProcess().Browser.openTab(url);
      }
    }
    else {
      console.log(this.msgUnsupported);
    }
  },

  openBackgroundTab: function(url) {
    if (BROWSER == 'Chrome') {
      if (chrome.tabs != undefined) {
        chrome.tabs.create({url: url, selected: false});
      }
    }
    else if (BROWSER == 'Opera') {
      // If this is the background page
      if (typeof OPERA_BUTTON != "undefined") {
        if (opera.extension.tabs) {
          opera.extension.tabs.create({url: url, focused: false});
        }
        else {
          console.log('ERROR: Opera tab creation not avaliable');
        }
      }
      // Recurse to the background page
      else {
        this.getBackgroundProcess().Browser.openBackgroundTab(url);
      }
    }
    else {
      console.log(this.msgUnsupported);
    }
  },

  getBackgroundProcess: function() {
    if (BROWSER == 'Chrome') {
      if (chrome.extension != undefined) {
        return chrome.extension.getBackgroundPage();
      }
    }
    else if (BROWSER == 'Opera') {
      return opera.extension.bgProcess;
    }
    else {
      console.log(this.msgUnsupported);
    }
  },

  // FUNCTIONS BELOW ARE NOT YET FULLY IMPLEMENTED

  createNotification: function(path) {
    // For future reference, support for webkit notifications can be
    // tested with (!window.webkitNotifications)
    if (BROWSER == 'Chrome') {
      // Check if browser is active, not "idle" or "locked"
      if (chrome.idle) {
        chrome.idle.queryState(30, function (state) {
          if (state == 'active') {
            notification = webkitNotifications.createHTMLNotification(path);
            notification.show();
          }
          else {
            if (DEBUG) console.log('Notification not sent, state was', state);
          }
{'fraction_non_alphanumeric': 0.125635103926097, 'fraction_numerical': 0.0009237875288683603, 'mean_word_length': 2.140319071791153, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '52561', 'n_tokens_mistral': 2619, 'n_tokens_neox': 2582, 'n_words': 623}