<commit_before>(function (){
  var root = this;
  var that = {};
  var isFirefox = !!root.browser;
  var _browser = isFirefox ? root.browser : chrome;

  function noop(){
  }

  that._adapters = {};

  function extend(){
    var s = arguments[0];
    for ( var i = 1; i < arguments.length; i++ ) {
      for ( var j in arguments[i] ) {
        s[j] = arguments[i][j];
      }
    }
  }

  var request = function (opts, callback){
    var $ = root.jQuery;
    $.ajax({
      url : opts.url,
      type: opts.method,
      data: opts.data
    })
      .always(function (data, textStatus, jqXHR){
        if ( textStatus == "success" ) {
          callback(null, data);
        } else {
          callback(data);
        }
      });
  }

  var Adapter = function (id, opts, flow){
    this.lsPath = "oauth2_" + id;
    this.opts = opts;
    this.responseType = this.opts.response_type;
    this.secret = this.opts.client_secret;
    this.redirect = this.opts.redirect_uri.replace(/https*:\/\//i, "");
    delete this.opts.client_secret;
    this.flow = flow;
    this.codeUrl = opts.api + "?" + this.query(opts);
    this._watchInject();
    extend(this, new EventEmitter());
    if ( !isFirefox ) {
      this.syncGet();
      this.sync();
    }
  }

  Adapter.prototype._watchInject = function (){
    var self = this;
    var injectScript = '(' + this.injectScript.toString() + ')()';
    var injectTo;

    injectTo = this.redirect;
    _browser.tabs.onUpdated.addListener(function (tabId, changeInfo){
      if ( changeInfo.url && changeInfo.url.indexOf(injectTo) != -1 ) {
        console.log("\nExecuting scripts");
        _browser.tabs.executeScript(tabId, {code: injectScript});
      }
    })

    _browser.runtime.onMessage.addListener(function (msg, sender, sendResponse){
      if ( msg.type == "OAUTH2" ) {
        self.finalize(msg.value.params);
        setTimeout(function (){
          _browser.tabs.remove(sender.tab.id);
        }, 100)
      }
    });
  }

  Adapter.prototype.injectScript = function (){

    console.log("\n\nInjecting\n\n");
<commit_msg>trigget oauth_token on firefox start<commit_after>(function (){
  var root = this;
  var that = {};
  var isFirefox = !!root.browser;
  var _browser = isFirefox ? root.browser : chrome;

  function noop(){
  }

  that._adapters = {};

  function extend(){
    var s = arguments[0];
    for ( var i = 1; i < arguments.length; i++ ) {
      for ( var j in arguments[i] ) {
        s[j] = arguments[i][j];
      }
    }
  }

  var request = function (opts, callback){
    var $ = root.jQuery;
    $.ajax({
      url : opts.url,
      type: opts.method,
      data: opts.data
    })
      .always(function (data, textStatus, jqXHR){
        if ( textStatus == "success" ) {
          callback(null, data);
        } else {
          callback(data);
        }
      });
  }

  var Adapter = function (id, opts, flow){
    this.lsPath = "oauth2_" + id;
    this.opts = opts;
    this.responseType = this.opts.response_type;
    this.secret = this.opts.client_secret;
    this.redirect = this.opts.redirect_uri.replace(/https*:\/\//i, "");
    delete this.opts.client_secret;
    this.flow = flow;
    this.codeUrl = opts.api + "?" + this.query(opts);
    this._watchInject();
    extend(this, new EventEmitter());
    if ( !isFirefox ) {
      this.syncGet();
      this.sync();
    } else {
      setTimeout(function (){
        console.log("\nFirefox. Triggering token");
        this.trigger("OAUTH2_TOKEN", {value: this.getAccessToken()});
      }, 2000)
    }
  }

  Adapter.prototype._watchInject = function (){
    var self = this;
    var injectScript = '(' + this.injectScript.toString() + ')()';
    var injectTo;

    injectTo = this.redirect;
    _browser.tabs.onUpdated.addListener(function (tabId, changeInfo){
      if ( changeInfo.url && changeInfo.url.indexOf(injectTo) != -1 ) {
        console.log("\nExecuting scripts");
        _browser.tabs.executeScript(tabId, {code: injectScript});
      }
    })

    _browser.runtime.onMessage.addListener(function (msg, sender, sendResponse){
      if ( msg.type == "OAUTH2" ) {
        self.finalize(msg.value.params);
        setTimeout(function (){
          _browser.tabs.remove(sender.tab.id);
        }, 100)
      }
    });
  }

  Adapter.prototype.injectScript = function (){

    console.log("\n\nInjecting\n\n");

{'fraction_non_alphanumeric': 0.15759246496668963, 'fraction_numerical': 0.004824259131633356, 'mean_word_length': 2.388326848249027, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4782476', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1416, 'n_words': 275}