coyoteazul / CoAzNeoExporter

// ==UserScript==
// @name        CoAzNeoExporter
// @namespace   CoAzNeoExporter
// @include     https://www.neobux.com/c/rl/?*
// @include     https://www.neobux.com/c/rs/?*
// @include     https://www.neobux.com/c/?*
// @include     http://www.neobux.com/v/?*
// @include     https://www.neobux.com/c/d/?*
// @version     3.15
// @grant       none
// @updateURL   https://openuserjs.org/meta/coyoteazul/CoAzNeoExporter.meta.js
// @copyright   2015
// @license MIT
//Adprize page is included to keep track of the prizes earned. If user wins a prize, a cookie is created to later be read by the exporter

//2.2 = Fixed language issue. Language was always recognized as spanish
//2.3 = Added savebutton function to RD page
//2.4 = No changes. Tried to push update, without success
//2.5 = Added language specification; Expiration dates are now always exported on exact mode; Buttons don't change sizes unnecessarily anymore; Added update URL
//2.7 = Erased last blank line on RD exportation. Blank warning message on last RD page when using the save button was fixed
//2.8 = Fixed dr who stayed even when not exporting it
//2.9 = Fixed referrals page not recognizing exportation when the url includes sp instead of vl
//2.96 = Fixed calculation of expiration's date when referral is about to die, and missing hour of expiration's date on all languages but spanish
//2.98 = page selector now reads modal rather than URL, which seemed to change after 10 pages
//2.99 = correction of the previous fix
//3.00 = correction of the previous correction
//3.01 = correction of the correction of the previous correction
//3.02 = included RD check
//3.04 = added another check for RDs first page
//3.05 = added yet another chack for RDs first page. It constist on a reedition of the first method, but it's very ineficient
//3.06 = fixed 3.05's check, which forgot to consider that neobux doesn't alway show the "sp" marker. Also changed it to make it efficient
//3.07 = hopefully, the final fix. Neobux had a hidden branco, which lead to a check known for failing
//3.08 = For RR list. forced relative expiration dates ("Today" and "Tomorrow") now transforms correctly. Also now transforms the referral since field
//3.09 = Forced english translation. This will help avoiding problems with non ascii characters on c++
//3.10 = Patch due to change on neobux's structure
//3.11 = Patch due to another change on neobux's structure (language's ID changed from "menu_li" to "band")
//3.12 = Yet Patch due to another change on neobux's structure (language's ID changed from "band" to "bandNav")
//3.13 = Another patch due to changes on neobux. Also fixed the conversor on referral since date, which was adding days instead of substracting
//3.14 = removed an unnecesary console.log
//3.15 = Fixed adprize's registry
// ==/UserScript==


//[VARIABLES GLOBALES]
  var direccion = document.URL;
  direccion = direccion.substring(direccion.indexOf('.com'));
  var acumulador = '';
  //[obtenido de NeoExportEBO, de bigpetroman]
     var ebp_Idioma = document.body.innerHTML.indexOf("c0 f-") + 5;
     ebp_Idioma = document.body.innerHTML.substring(ebp_Idioma, ebp_Idioma + 2);
  //[/obtenido de NeoExportEBO, de bigpetroman]
//[/VARIABLES GLOBALES]

//[funciones auxiliares]
  //[funciones para cookies obtenidas de w3schools.com]
    function setCookie(cname, cvalue, exdays) {
      var d = new Date();
      d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
      var expires = 'expires=' + d.toUTCString();
      document.cookie = cname + '=' + cvalue + '; ' + expires + ";path=/";
    }
    function getCookie(cname) {
      var name = cname + '=';
      var ca = document.cookie.split(';');
      for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1);
        if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
      }
      return '';
    }
  //[/funciones para cookies obtenidas de w3schools.com]

  //[devuelve la fecha en formato yyyy/mm/dd]
    function retornaFecha(diasDiferencia)
    {
      var today = new Date(Date.now() + 86400000 * diasDiferencia);
      var dd = today.getDate();
      var mm = today.getMonth() + 1; //January is 0!
      var yyyy = today.getFullYear();
      if (dd < 10) {
        dd = '0' + dd
      }
      if (mm < 10) {
        mm = '0' + mm
      }
      today = yyyy + '/' + mm + '/' + dd;
      return today
    }

    function dateAdd(date, interval, units) /*añade tiempo a una fecha*/ {
      var ret = new Date(date); //don't change original date
      switch(interval.toLowerCase()) {
        case 'year'   :  ret.setFullYear(ret.getFullYear() + units);  break;
        case 'quarter':  ret.setMonth(ret.getMonth() + 3*units);  break;
        case 'month'  :  ret.setMonth(ret.getMonth() + units);  break;
        case 'week'   :  ret.setDate(ret.getDate() + 7*units);  break;
        case 'day'    :  ret.setDate(ret.getDate() + units);  break;
        case 'hour'   :  ret.setTime(ret.getTime() + units*3600000);  break;
        case 'minute' :  ret.setTime(ret.getTime() + units*60000);  break;
        case 'second' :  ret.setTime(ret.getTime() + units*1000);  break;
        default       :  ret = undefined;  break;
      }
      return ret;
    }
  //[/devuelve la fecha en formato yyyy/mm/dd]

  function formatize_date (line, add)/*gives proper format to dates*/{
    //Greek was not included because the caracters are too different from latin
    var todyVctr = ["Today", "Hoy", "Hoje", "Hari ini", "Tänään", "Idag", "Heute", "Aujourd'hui"];
    var yestVctr = ["Yesterday", "Ayer", "Ontem", "Kemarin", "Eilen", "Igår", "Gestern", "Hier"];
    var tomoVctr = ["Tomorrow", "Mañana", "Amanhã", "Besok", "Huomenna", "I morgon", "Morgen", "Demain"];

    var FiCh = line.substring(0,1); //first character

    /*if first digit is not numeric, it's a forced relative date*/
    if (FiCh != "0" && FiCh != "1" && FiCh != "2" && FiCh != "3" && FiCh != "4" && FiCh != "5" && FiCh != "6" && FiCh != "7" && FiCh != "8" && FiCh != "9"){
      for (var i = 0; i < 8; i++){
        var dDot_pos = line.indexOf(":");
        var hour = line.substring(dDot_pos-2, dDot_pos + 3);
        if (line.indexOf(todyVctr[i]) != -1) return retornaFecha(0) + " " + hour;
        if (line.indexOf(yestVctr[i]) != -1) return retornaFecha(-1) + " " + hour;
        if (line.indexOf(tomoVctr[i]) != -1) return retornaFecha(1) + " " + hour;
      }
    }
    else if (line.indexOf("/") == -1){ /*torna las fechas relativas en exactas*/ /*only exact dates have the "/" character*/
      var dias = line.substring(0,line.indexOf(" "));
      var posHora = line.indexOf(":");
      var horas = line.substring(posHora-2,posHora)
      var minu = line.substring (posHora +1 , posHora+3)

      var mult = add ? 1 : -1;
      dias = parseInt(dias) * mult;
      horas = parseInt(horas) * mult;
      minu = parseInt(minu) * mult;

      var expDate = new Date();
      expDate = dateAdd(expDate, "day", dias);
      expDate = dateAdd(expDate, "hour", horas);
      expDate = dateAdd(expDate, "minute", minu);
      //añade ceros si hacen falta
      var daicero = expDate.getDate();
      if (daicero < 10)
        daicero = "0" + daicero;
      var monthcero = (expDate.getMonth()+1);
      if (monthcero < 10)
        monthcero = "0" + monthcero;
      var horacero = expDate.getHours();
      if (horacero < 10)
        horacero = "0" + horacero;
      var minucero = expDate.getMinutes();
      if (minucero < 10)
        minucero = "0" + minucero;

      return (expDate.getFullYear() + "/" + monthcero + "/" + daicero+ " " + horacero + ":" + minucero);
    }
    else { //las fechas ya son exactas, asi que permanecen, pero se le quita la separacion entre fecha y hora
      var borrar = line.substring(10, 16);
      return (line.replace(borrar, ''));
    }
  }

  function translate (line_or, src)/*translates user and stadistics pages*/{
    var line = line_or
    if (src === 0)/*summary*/{
      if (line.indexOf("Rented")!=-1) {/*english*/
       return line
      }
      else if (line.indexOf("Alquilados")!=-1) /*spanish*/ {
        line = line.replace(/Registro/gi,                "Registration");
        line = line.replace(/Fecha/gi,                   "Date");
        line = line.replace(/Expira/gi,                  "Expires");
        line = line.replace(/Alquilados/gi,              "Rented");
        line = line.replace(/Directos/gi,                "Direct");
        line = line.replace(/Saldo Principal/gi,         "Main Balance");
        line = line.replace(/Saldo de Alquiler/gi,       "Rental Balance");
        line = line.replace(/Saldo de Paquete Golden/gi, "Golden Pack Balance");
        line = line.replace(/Recibido/gi,                "Received");
        line = line.replace(/Comisiones/gi,              "Commissions");
        line = line.replace(/pendientes/gi,              "Pending");
        line = line.replace(/Mini Trabajos/gi,           "Mini Jobs");
        line = line.replace(/Bonus/gi,                   "Bonuses");
      }
      else if (line.indexOf("Alugados")!=-1)/*portuguese*/{
        line = line.replace(/Registo/gi,                 "Registration");
        line = line.replace(/Data/gi,                    "Date");
        line = line.replace(/Expira/gi,                  "Expires");
        line = line.replace(/Alugados/gi,                "Rented");
        line = line.replace(/Directos/gi,                "Direct");
        line = line.replace(/Saldo Principal/gi,         "Main Balance");
        line = line.replace(/Saldo de Aluguer/gi,        "Rental Balance");
        line = line.replace(/Saldo para Pack Golden/gi,  "Golden Pack Balance");
        line = line.replace(/Recebido/gi,                "Received");
        line = line.replace(/Comissões/gi,               "Commissions");
        line = line.replace(/Pendentes/gi,               "Pending");
        line = line.replace(/Mini Trabalhos/gi,          "Mini Jobs");
        line = line.replace(/Bónus/gi,                   "Bonuses");
      }
      else if (line.indexOf("Sewa")!=-1){ /*hindi*/
        line = line.replace(/Pendaftaran/gi,             "Registration");
        line = line.replace(/Tanggal/gi,                 "Date");
        line = line.replace(/Expire/gi,                  "Expires");
        line = line.replace(/Sewa/gi,                    "Rented");
        line = line.replace(/Langsung/gi,                "Direct");
        line = line.replace(/Saldo Utama/gi,             "Main Balance");
        line = line.replace(/Saldo Sewa/gi,              "Rental Balance");
        line = line.replace(/Saldo Paket Golden/gi,      "Golden Pack Balance");
        line = line.replace(/Jumlah Yang Diterima/gi,    "Received");
        line = line.replace(/Komisi/gi,                  "Commissions");
        line = line.replace(/Tertunda/gi,                "Pending");
        line = line.replace(/Job Mini/gi,                "Mini Jobs");
        line = line.replace(/Bonus/gi,                   "Bonuses");
      }
      else if (line.indexOf("Vuokratut")!=-1){ /**/
        line = line.replace(/Rekisteröinti/gi,           "Registration");
        line = line.replace(/Päivämäärä/gi,              "Date");
        line = line.replace(/Erääntyy/gi,                "Expires");
        line = line.replace(/Vuokratut/gi,               "Rented");
        line = line.replace(/Suorat/gi,                  "Direct");
        line = line.replace(/Päätili/gi,                 "Main Balance");
        line = line.replace(/Vuokratili/gi,              "Rental Balance");
        line = line.replace(/Golden Pack tili/gi,        "Golden Pack Balance");
        line = line.replace(/Nostettu/gi,                "Received");
        line = line.replace(/Kommissiot/gi,              "Commissions");
        line = line.replace(/Tulossa olevat/gi,          "Pending");
        line = line.replace(/Minityöt/gi,                "Mini Jobs");
        line = line.replace(/Bonukset/gi,                "Bonuses");
      }
      else if (line.indexOf("Hyrda")!=-1){/*aleman*/
        line = line.replace(/Registration/gi,            "Registration");
        line = line.replace(/Datum/gi,                   "Date");
        line = line.replace(/Upphör/gi,                  "Expires");
        line = line.replace(/Hyrda/gi,                   "Rented");
        line = line.replace(/Direkta/gi,                 "Direct");
        line = line.replace(/Huvudkonto/gi,              "Main Balance");
        line = line.replace(/Hyreskonto/gi,              "Rental Balance");
        line = line.replace(/Golden Pack konto/gi,       "Golden Pack Balance");
        line = line.replace(/Utbetalat/gi,               "Received");
        line = line.replace(/Kommissioner/gi,            "Commissions");
        line = line.replace(/Kommande/gi,                "Pending");
        line = line.replace(/Minijobb/gi,                "Mini Jobs");
        line = line.replace(/Bonus/gi,                   "Bonuses");
      }
      else if (line.indexOf("Gemietete")!=-1){/**/
        line = line.replace(/Registrierung/gi,           "Registration");
        line = line.replace(/Datum/gi,                   "Date");
        line = line.replace(/Endet/gi,                   "Expires");
        line = line.replace(/Gemietete/gi,               "Rented");
        line = line.replace(/Direkte/gi,                 "Direct");
        line = line.replace(/Hauptguthaben/gi,           "Main Balance");
        line = line.replace(/Mietguthaben/gi,            "Rental Balance");
        line = line.replace(/Golden Paket Guthaben/gi,   "Golden Pack Balance");
        line = line.replace(/Erhalten/gi,                "Received");
        line = line.replace(/Provisionen/gi,             "Commissions");
        line = line.replace(/Ausstehend/gi,              "Pending");
        line = line.replace(/Bonusse/gi,                 "Bonuses");
      }
      else if (line.indexOf("Loués")!=-1){/*french*/
        line = line.replace(/Inscription/gi,             "Registration");
        line = line.replace(/Expire/gi,                  "Expires");
        line = line.replace(/Loués/gi,                   "Rented");
        line = line.replace(/Directs/gi,                 "Direct");
        line = line.replace(/Solde Principal/gi,         "Main Balance");
        line = line.replace(/Solde de Location/gi,       "Rental Balance");
        line = line.replace(/Solde du Golden Pack/gi,    "Golden Pack Balance");
        line = line.replace(/Reçu/gi,                    "Received");
        line = line.replace(/Commissions/gi,             "Commissions");
        line = line.replace(/En attente/gi,              "Pending");
        line = line.replace(/Petits Boulots/gi,          "Mini Jobs");
        line = line.replace(/Bonus/gi,                   "Bonuses");
      }
    }
    else if (src === 1) /*statistics*/{
      if (line.indexOf("Recycle value")!=-1) {/*english*/
       return line;
      }
      else if (line.indexOf("Coste del reciclaje")!=-1){/*spanish*/
        line = line.replace(/Fijos/gi,                                                   "Fixed");
        line = line.replace(/Micro/gi,                                                   "Micro");
        line = line.replace(/Mini/gi,                                                    "Mini");
        line = line.replace(/Prolongados/gi,                                             "Extended");
        line = line.replace(/Estándar/gi,                                                "Standard");
        line = line.replace(/FijosOR/gi,                                                 "FixedOR");
        line = line.replace(/Clics validados de sus referidos directos/gi,               "Direct referrals clicks credited");
        line = line.replace(/Clics validados de sus referidos alquilados/gi,             "Rented referrals clicks credited");
        line = line.replace(/Coste del reciclaje/gi,                                     "Recycle value");
        line = line.replace(/Reciclaje Automático/gi,                                    "Automatic Recycling");
        line = line.replace(/Coste de la renovación/gi,                                  "Extension value");
        line = line.replace(/Coste del AutoPago/gi,                                      "AutoPay value");
        line = line.replace(/Transferencias al Saldo de Alquiler/gi,                     "Transfers to Rental Balance");
        line = line.replace(/Transferencias al Saldo de Paquete Golden/gi,               "Transfers to Golden Pack Balance");
        line = line.replace(/Ganancias con los Mini Trabajos en los últimos 30 días/gi,  "Mini Jobs earnings in the last 30 days");
      }
      else if (line.indexOf("Valor da reciclagem")!=-1){/*portuguese*/
        line = line.replace(/Fixos/gi,                                                   "Fixed");
        line = line.replace(/Micro/gi,                                                   "Micro");
        line = line.replace(/Mini/gi,                                                    "Mini");
        line = line.replace(/Prolongados/gi,                                             "Extended");
        line = line.replace(/Normais/gi,                                                 "Standard");
        line = line.replace(/FixosOR/gi,                                                 "FixedOR");
        line = line.replace(/Cliques creditados dos referidos directos/gi,               "Direct referrals clicks credited");
        line = line.replace(/Cliques creditados dos referidos alugados/gi,               "Rented referrals clicks credited");
        line = line.replace(/Valor da reciclagem/gi,                                     "Recycle value");
        line = line.replace(/Reciclagem Automática/gi,                                   "Automatic Recycling");
        line = line.replace(/Valor de renovação/gi,                                      "Extension value");
        line = line.replace(/Valor do AutoPagamento/gi,                                  "AutoPay value");
        line = line.replace(/Transferências para Saldo de Aluguer/gi,                    "Transfers to Rental Balance");
        line = line.replace(/Transferências para Saldo de Pack Golden/gi,                "Transfers to Golden Pack Balance");
        line = line.replace(/Ganhos com Mini Trabalhos nos últimos 30 dias/gi,           "Mini Jobs earnings in the last 30 days");
      }
      else if (line.indexOf("Jumlah daur-ulang")!=-1){/**/
        line = line.replace(/Fixed/gi,                                                   "Fixed");
        line = line.replace(/Micro/gi,                                                   "Micro");
        line = line.replace(/Mini/gi,                                                    "Mini");
        line = line.replace(/Extended/gi,                                                "Extended");
        line = line.replace(/Standard/gi,                                                "Standard");
        line = line.replace(/FixedOR/gi,                                                 "FixedOR");
        line = line.replace(/Klik referal langsung yang terkredit/gi,                    "Direct referrals clicks credited");
        line = line.replace(/Klik referal sewaan yang terkredit/gi,                      "Rented referrals clicks credited");
        line = line.replace(/Jumlah daur-ulang/gi,                                       "Recycle value");
        line = line.replace(/Daur Ulang Otomatis/gi,                                     "Automatic Recycling");
        line = line.replace(/Jumlah perpanjangan/gi,                                     "Extension value");
        line = line.replace(/Jumlah AutoPay/gi,                                          "AutoPay value");
        line = line.replace(/Transfer ke Saldo Rental/gi,                                "Transfers to Rental Balance");
        line = line.replace(/Transfer ke Saldo Paket Golden/gi,                          "Transfers to Golden Pack Balance");
        line = line.replace(/Mini Jobs earnings in the last 30 days/gi,                  "Mini Jobs earnings in the last 30 days");
      }
      else if (line.indexOf("Kierrätyskulut")!=-1){/**/
        line = line.replace(/Kiinteät/gi,                                                "Fixed");
        line = line.replace(/Micro/gi,                                                   "Micro");
        line = line.replace(/Mini/gi,                                                    "Mini");
        line = line.replace(/Laajennetut/gi,                                             "Extended");
        line = line.replace(/Vakio/gi,                                                   "Standard");
        line = line.replace(/KiinteätOR/gi,                                              "FixedOR");
        line = line.replace(/Hyvitetyt suorien referaalien klikkaukset/gi,               "Direct referrals clicks credited");
        line = line.replace(/Hyvitetyt vuokrareferaalien klikkaukset/gi,                 "Rented referrals clicks credited");
        line = line.replace(/Kierrätyskulut/gi,                                          "Recycle value");
        line = line.replace(/Automaattinen kierrätys/gi,                                 "Automatic Recycling");
        line = line.replace(/Pidennysarvo/gi,                                            "Extension value");
        line = line.replace(/AutoPay arvo/gi,                                            "AutoPay value");
        line = line.replace(/Siirrot vuokratilille/gi,                                   "Transfers to Rental Balance");
        line = line.replace(/Siirrot Golden Pack tilille/gi,                             "Transfers to Golden Pack Balance");
        line = line.replace(/Minityö ansiot viimeiset 30 päivää/gi,                      "Mini Jobs earnings in the last 30 days");
      }
      else if (line.indexOf("Recylingskostnader")!=-1){/**/
        line = line.replace(/Fasta/gi,                                                   "Fixed");
        line = line.replace(/Micro/gi,                                                   "Micro");
        line = line.replace(/Mini/gi,                                                    "Mini");
        line = line.replace(/Förlängda/gi,                                               "Extended");
        line = line.replace(/Standard/gi,                                                "Standard");
        line = line.replace(/FastaOR/gi,                                                 "FixedOR");
        line = line.replace(/Krediterade klick av direkta referaler/gi,                  "Direct referrals clicks credited");
        line = line.replace(/Krediterade klick av hyrda referaler/gi,                    "Rented referrals clicks credited");
        line = line.replace(/Recylingskostnader/gi,                                      "Recycle value");
        line = line.replace(/Automatiskt referalbyte/gi,                                 "Automatic Recycling");
        line = line.replace(/Förlängningsvärde/gi,                                       "Extension value");
        line = line.replace(/AutoPay-värde/gi,                                           "AutoPay value");
        line = line.replace(/Överföringar till hyreskonto/gi,                            "Transfers to Rental Balance");
        line = line.replace(/Gireringar till Golden Pack kontot/gi,                      "Transfers to Golden Pack Balance");
        line = line.replace(/Minijobb förtjänster senaste 30 dagar/gi,                   "Mini Jobs earnings in the last 30 days");
      }
      else if (line.indexOf("Recycle Betrag")!=-1){/**/
        line = line.replace(/Fixierte/gi,                                                "Fixed");
        line = line.replace(/Micro/gi,                                                   "Micro");
        line = line.replace(/Mini/gi,                                                    "Mini");
        line = line.replace(/Verlängerte/gi,                                             "Extended");
        line = line.replace(/Standard/gi,                                                "Standard");
        line = line.replace(/FixierteOR/gi,                                              "FixedOR");
        line = line.replace(/Gutgeschriebene Klicks der direkten Referrals/gi,           "Direct referrals clicks credited");
        line = line.replace(/Gutgeschriebene Klicks der gemieteten Referrals/gi,         "Rented referrals clicks credited");
        line = line.replace(/Recycle Betrag/gi,                                          "Recycle value");
        line = line.replace(/Automatisches Recycling/gi,                                 "Automatic Recycling");
        line = line.replace(/Verlängerungswert/gi,                                       "Extension value");
        line = line.replace(/AutoPay Betrag/gi,                                          "AutoPay value");
        line = line.replace(/Transfers zum Mietguthaben/gi,                              "Transfers to Rental Balance");
        line = line.replace(/Transfers zum Paket Guthaben/gi,                            "Transfers to Golden Pack Balance");
        line = line.replace(/Mini Job Verdienste in den letzten 30 Tagen/gi,             "Mini Jobs earnings in the last 30 days");
      }
      else if (line.indexOf("Valeur de recyclage")!=-1){ /**/
        line = line.replace(/Fixes/gi,                                                   "Fixed");
        line = line.replace(/Micro/gi,                                                   "Micro");
        line = line.replace(/Mini/gi,                                                    "Mini");
        line = line.replace(/Étendues/gi,                                                "Extended");
        line = line.replace(/Standard/gi,                                                "Standard");
        line = line.replace(/FixesOR/gi,                                                 "FixedOR");
        line = line.replace(/Clics de filleuls directs crédités/gi,                      "Direct referrals clicks credited");
        line = line.replace(/Clics de filleuls loués crédités/gi,                        "Rented referrals clicks credited");
        line = line.replace(/Valeur de recyclage/gi,                                     "Recycle value");
        line = line.replace(/Recyclage Automatique/gi,                                   "Automatic Recycling");
        line = line.replace(/Valeur de prolongement/gi,                                  "Extension value");
        line = line.replace(/Valeur Autopay/gi,                                          "AutoPay value");
        line = line.replace(/Transferts vers le solde location/gi,                       "Transfers to Rental Balance");
        line = line.replace(/Transferts au solde du Golden Pack/gi,                      "Transfers to Golden Pack Balance");
        line = line.replace(/Les profits de Petits Boulots au cours de 30 derniers jours/gi,  "Mini Jobs earnings in the last 30 days");
      }
    }
    else {
      if (line.indexOf("Today")!=-1 || line.indexOf("Yesterday")!=-1 || line.indexOf("No clicks yet")!=-1){/*english*/
        return line;
      }
      else if (line.indexOf("Hoy")!=-1 || line.indexOf("Ayer")!=-1 || line.indexOf("Sin clics aún")!=-1){/*spanish*/
        line = line.replace(/Hoy/gi,            "Today");
        line = line.replace(/Ayer/gi,           "Yesterday");
        line = line.replace(/Sin clics aún/gi,  "No clicks yet");
        line = line.replace(/días/gi,           "days");
      }
      else if (line.indexOf("Hoje")!=-1 || line.indexOf("Ontem")!=-1 || line.indexOf("Sem cliques")!=-1){/*portugese*/
        line = line.replace(/Hoje/gi,           "Today");
        line = line.replace(/Ontem/gi,          "Yesterday");
        line = line.replace(/Sem cliques/gi,    "No clicks yet");
        line = line.replace(/dias/gi,           "days");
      }
      else if (line.indexOf("Hari ini")!=-1 || line.indexOf("Kemarin")!=-1 || line.indexOf("Belum ada klik")!=-1){/**/
        line = line.replace(/Hari ini/gi,       "Today");
        line = line.replace(/Kemarin/gi,        "Yesterday");
        line = line.replace(/Belum ada klik/gi, "No clicks yet");
        line = line.replace(/hari/gi,           "days");
      }
      else if (line.indexOf("Tänään")!=-1 || line.indexOf("Eilen")!=-1 || line.indexOf("Ei klikkejä")!=-1){/**/
        line = line.replace(/Tänään/gi,         "Today");
        line = line.replace(/Eilen/gi,          "Yesterday");
        line = line.replace(/Ei klikkejä/gi,    "No clicks yet");
        line = line.replace(/päivää/gi,           "days");
      }
      else if (line.indexOf("Idag")!=-1 || line.indexOf("I går")!=-1 || line.indexOf("Inga klick")!=-1){/**/
        line = line.replace(/Idag/gi,           "Today");
        line = line.replace(/I går/gi,          "Yesterday");
        line = line.replace(/Inga klick/gi,     "No clicks yet");
        line = line.replace(/dagar/gi,           "days");
      }
      else if (line.indexOf("Heute")!=-1 || line.indexOf("Gestern")!=-1 || line.indexOf("Keine Klicks")!=-1){/**/
        line = line.replace(/Heute/gi,          "Today");
        line = line.replace(/Gestern/gi,        "Yesterday");
        line = line.replace(/Keine Klicks/gi,   "No clicks yet");
        line = line.replace(/Tage/gi,           "days");
      }
      else if (line.indexOf("Aujourd'hui")!=-1 || line.indexOf("Hier")!=-1 || line.indexOf("Pas de clics")!=-1){/**/
        line = line.replace(/Aujourd'hui/gi,    "Today");
        line = line.replace(/Hier/gi,           "Yesterday");
        line = line.replace(/Pas de clics/gi,   "No clicks yet");
        line = line.replace(/jours/gi,           "days");
      }
    }
    return line;
  }
//[/funciones auxiliares]

function exportarReferidosAlquilados(DOMDeLista)// exportar lista de referidos alquilados**********************************************************
{
  console.log('inciando exportarReferidosAlquilados');
  var tabla = document.getElementById('mnTb'); //.getElementsByTagName('table') [2].childNodes[0];
  var filas = tabla.rows;
  var cantColumns = 7;

  for (i = 2; i <= filas.length - 3; i = i + 2) {
    var acumuladorreferido = [
    ];
    for (e = 0; e <= cantColumns; e++) {
      var datos = filas[i].childNodes[e].innerHTML;
      //individualiza bandera
      if (e == 1) {
        datos = datos.slice(datos.indexOf('flag'), datos.indexOf('flag') + 5);
        //quita $nbsp
      } else if (e > 1 && e <= cantColumns) {
        puntoDeCorte = datos.indexOf('&nbsp');
        //console.log(datos)
        datos = datos.slice(0, puntoDeCorte);
        if (e == 4) /*change date's format*/
          datos = formatize_date(datos, true);
        if (e == 3)
          datos = formatize_date(datos, false);
        else if (datos.indexOf('-.---') !== - 1) /*cambia formato de media si muestra guiones*/
          datos = '0.000'
      }
      acumuladorreferido.push(datos);
    }
    acumuladorreferido = acumuladorreferido.join(';');
    acumulador = acumulador + acumuladorreferido + String.fromCharCode(13, 10);
  }
  acumulador = acumulador.substring(0, acumulador.length - 2); //quita el ultimo cambio de linea
  acumulador = translate(acumulador,3);
  var dat = document.createTextNode(acumulador);
  DOMDeLista.appendChild(dat);
}

function exportarReferidosDirectos(DOMDeLista) //exportar lista de referidos directos************************************************************
{
  var tabla = document.getElementById('tblprp').getElementsByTagName('table') [2].childNodes[0];
  var filas = tabla.rows;
  var cantColumns = 6;
  for (i = 2; i <= filas.length - 3; i = i + 1) {
    if (filas[i].innerHTML.indexOf("<td colspan") != -1) continue;
    var acumuladorreferido = [];
    for (e = 0; e <= cantColumns; e++) {
      var datos = filas[i].childNodes[e].innerHTML;
      if (e > 0 && e <= cantColumns) {
        puntoDeCorte = datos.indexOf('&nbsp');
        datos = datos.slice(0, puntoDeCorte)
        if (e == 3) datos = formatize_date(datos, false)
        //cambia formato de media si muestra guiones
        if (datos.indexOf('-.---') !== - 1) {
          datos = '0.000'
        }
      }
      if (datos == "") continue;
      acumuladorreferido.push(datos);
    }
    acumuladorreferido = acumuladorreferido.join(';');
    acumulador = acumulador + acumuladorreferido + String.fromCharCode(13, 10);
  }
  acumulador = acumulador.substring(0, acumulador.length - 2); //quita el ultimo cambio de linea
  acumulador = translate(acumulador,3);
  var dat = document.createTextNode(acumulador);
  DOMDeLista.appendChild(dat);
}

function exportarDatosDeUsuario(DOMDeLista) //EXPORTAR DATOS DE USUARIO***********************************************************************
{
  var filas = document.getElementById('c_dir').getElementsByClassName('mbx') [0].childNodes[1].rows;
  for (i = 0; i <= filas.length - 1; i++) {
    var datos = filas[i].textContent;
    //eliminar espacios en blanco
    if (datos.indexOf(':') === - 1) {
      continue
    }
    //eliminar sobrantes de mk_tt que vienen de botones

    if (datos.indexOf('mk_tt') !== - 1) {
      var puntoCorte = datos.indexOf('mk_tt') - 1;
      datos = datos.substring(0, puntoCorte);
    }
    //eliminar "=" innecesarios

    if (datos.indexOf('=') !== - 1) {
      datos = datos.substring(0, datos.indexOf('='));
    }
    if (datos.indexOf('&nbsp;') !== - 1) {
      datos.replace('&nbsp;', '');
    }
    //eliminar espacios blancos al principio y fin del string

    datos = datos.trim();
    //distingue entre golden de 1er anio y posteriores
    if (datos.indexOf('Golden') != - 1 && datos.indexOf('/') != - 1)
    {
      if (getCookie('goldenStatus') !== '')
      {
        datos = getCookie('goldenStatus') + datos.substring(7, 50);
      }
      else
      {
        var message;
        if(ebp_Idioma == 'es')
          {
            message = 'CoAzExporter dice: \n ¿Es tu primer año como golden? Puedes cambiar esta opcion mas adelante en la pagina de opciones \n Aceptar para SI \n Cancelar para NO'
          }
        else
          {
            message = 'CoAzExporter says: \n Is this your first year as golden? Later you can change this option on the options page \n Accept for YES \n Cancel for NO'
          }

        if (!confirm(message))
        {
          datos = 'Golden2' + datos.substring(7, 50);
          setCookie('goldenStatus', 'Golden2');
        }
        else
        {
          datos = 'Golden1' + datos.substring(7, 50);
          setCookie('goldenStatus', 'Golden1');
        }
      }
    }
    acumulador = acumulador + datos + String.fromCharCode(13, 10);
  }
  var idiom = document.getElementById("bandNav").childNodes[0].getElementsByTagName("div")[0].getAttribute('class').substring(3,8);
  acumulador = retornaFecha(0) + " " + "f-us" + String.fromCharCode(13, 10) + acumulador;

  //obtener cookies de adprize
  var adpHoy = 0;
  var adpAye = 0;
  if (getCookie('adpM|' + retornaFecha(0)) != '') {
    adpHoy = getCookie('adpM|' + retornaFecha(0))
  }
  if (getCookie('adpM|' + retornaFecha( - 1)) != '') {
    adpAye = getCookie('adpM|' + retornaFecha(-1))
  }

  var adpHoyP = 0;
  var adpAyeP = 0;
  if (getCookie('adpP|' + retornaFecha(0)) != '') {
    adpHoyP = getCookie('adpP|' + retornaFecha(0))
    adpHoyP = adpHoyP.substring(0,adpHoyP.indexOf('P'))
  }
  if (getCookie('adpP|' + retornaFecha( - 1)) != '') {
    adpAyeP = getCookie('adpP|' + retornaFecha(-1))
    adpAyeP = adpAyeP.substring(0,adpAyeP.indexOf('P'))
  }

  acumulador = acumulador + 'Adprize $T:' + adpHoy + String.fromCharCode(13, 10) + 'Adprize $Y:' + adpAye + String.fromCharCode(13, 10) + 'Adprize PT:' + adpHoyP + String.fromCharCode(13, 10) + 'Adprize PY:' + adpAyeP ; //no estoy seguro de si funcionaran las cookies
  acumulador = translate(acumulador, 0);
  var dat = document.createTextNode(acumulador);
  DOMDeLista.appendChild(dat);
}

function extraeEstadisticas(DOMDeLista) //EXPORTAR PAGINA DE ESTADISTICAS******************************************************************
{
  borrarInnecesarios() //quita el atributo class a los paneles de extencion automatico y manual para que no interfieran
  //------Tomado de NeobuxOx, de Proxen----------------------------------------------------------------------------------------------------
    var EBP_scharts = document.evaluate('//script[contains(.,\'eval(w(\')]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent.split(' ');
  //------Tomado de NeobuxOx, de Proxen----------------------------------------------------------------------------------------------------
  var acumulador = '---' + String.fromCharCode(13, 10) //el separador
  var e = 0
  for (i = 0; EBP_scharts[i]; i++) {
    var codigo = atob(EBP_scharts[i].split('\'') [1]) //decodifica la informacion
    //i 0 es el grafico de clicks propios
    if (i == 0) {
      for (r = 0; r <= 6; r++) {
        //division crea un array con los datos decodificados
        var division = codigo.split('[{') [1].split('}]') [0].split('}, {') [r]
        var datos = division.split('data:[') [1].split(']') [0].split(',').reverse()
        var nombre = decodeURIComponent(escape(division.split('name:decodeURIComponent(escape(\'') [1].split('\'))') [0]))
        if (datos[0] == '') {
          datos.shift()
        }
        if (r == 6) {
          nombre = nombre + 'OR'
        }
        var linea = nombre + ':' + datos.join(';')
        acumulador = acumulador + linea + String.fromCharCode(13, 10) //charcode es el cambio de linea
      }
    } else {
      var nombre = buscaNombres(i - e)
      var datos = codigo.split('data:[') [1].split(']') [0].split(',').reverse()
      if (datos[0] == '') {
        datos.shift()
      }
      datos = datos.splice(0, 10)
      //schedule son los graficos de futuras expiraciones. Esos se saltean
      if (codigo.indexOf('schedule') == - 1) {
        linea = nombre + ':' + datos.join(';')
        acumulador = acumulador + linea + String.fromCharCode(13, 10)
      } else {
        //cuenta los schedule para que el buscaNombre tambien se los salte
        e = e + 1
      }
    }
  }
  acumulador = translate(acumulador,1) + '---' //el separador
  var dat = document.createTextNode(acumulador);
  DOMDeLista.appendChild(dat);
}

function buscaNombres(i) //implementado en funcion extraeEstadisticas
{
  var definirDOM = document.querySelectorAll('div.f_b') [i];
  var nombre = definirDOM.textContent;
  return nombre;
}

function borrarInnecesarios() //implementado en funcion extraeEstadisticas
{
  //al quitar la class evita que sea reconocido pero aun se puede utilizar
  document.getElementById('panel-ext-aut').childNodes[0].removeAttribute('class');
  document.getElementById('panel-ext-man').childNodes[0].removeAttribute('class');
}

function creaTablaCostado()//CREA VENTANA PARA EXPORTAR DATOS*****************************************************************
{
  //crea elemento tabla para poner datos a un lado
  var tablaCostado = document.createElement('div');
  tablaCostado.setAttribute('id', 'CoAzFloater');
  tablaCostado.setAttribute('align', 'center');
  tablaCostado.style.display = 'none';
  tablaCostado.style.position = 'absolute';
  tablaCostado.style.width = '420px'
  tablaCostado.style.top = '80px'
  tablaCostado.style.left = '40%'
  //crea elemento para poner los datos exportar
  var DOMDeLista = document.createElement('textarea');
  DOMDeLista.setAttribute('id', 'CoAzExporter');
  DOMDeLista.setAttribute('onMouseOver', 'this.select()');
  DOMDeLista.style.borderColor = 'rgba(0, 50, 255, 0.5)';
  DOMDeLista.style.borderWidth = 'thick';
  DOMDeLista.style.borderStyle = 'double';
  DOMDeLista.style.backgroundColor = 'white';
  DOMDeLista.style.textAlign = 'left';
  DOMDeLista.style.verticalAlign = 'top';
  DOMDeLista.style.padding = '5px';
  DOMDeLista.style.width = '500px';
  DOMDeLista.style.height = '300px';
  DOMDeLista.style.overflow = 'auto';
  document.body.appendChild(tablaCostado);
  tablaCostado.appendChild(DOMDeLista);
  //Decide que extractor aplicar segun la URL
  if (direccion.indexOf('.com/c/?vl') != -1) {
    exportarDatosDeUsuario(DOMDeLista)
  };
  if (direccion.indexOf('.com/c/rs/?vl') != -1) {
    extraeEstadisticas(DOMDeLista)
  };
  if (direccion.indexOf('.com/c/rl/?') != -1 || direccion.indexOf('.com/c/rl/?sp') != -1)
  {
    if (direccion.indexOf('ss3=1') != - 1)
    {
      exportarReferidosDirectos(DOMDeLista)
    }
    else
    {
      exportarReferidosAlquilados(DOMDeLista)
    }
  }
}

function creaBoton() //CREA BOTON PARA ABRIR Y CERRAR*******************************************************************
{
  var texto;

  var boton = document.createElement('div'); //cuadro que contiene a los botones y la descripcion
  boton.setAttribute('id', 'CoAzExporterBoton');
  boton.style.borderColor = 'rgba(0, 50, 255, 0.5)';
  boton.style.borderWidth = 'thick';
  boton.style.borderStyle = 'double';
  boton.style.backgroundColor = 'rgba(30, 50, 200, 0.3)';
  boton.style.textAlign = 'center';
  boton.style.padding = '2px';
  boton.style.display = 'block';
  boton.style.cursor = 'pointer';

  var testo = document.createElement('div'); //parte superior del cuadro
  testo.setAttribute('id', 'CoAzTexto');
  testo.innerHTML = 'CoAzExporter';
  testo.style.textAlign = 'center';

  var under = document.createElement('div'); //parte inferior del cuadro

  var tab = document.createElement('table');
  tab.style.textAlign = 'center';

  var right = document.createElement('td');
  right.style.width = '64px';

  var left = document.createElement('td');
  left.style.width = '70px';

  if(ebp_Idioma == 'es') {texto = 'Guardar'}
  else {texto = 'Save'}
  var guardar = document.createElement('div')
  guardar.setAttribute('id', 'CoAzGuardar')
  guardar.style.borderColor = 'rgba(60, 150, 255, 0.3)';
  guardar.style.borderWidth = 'thick';
  guardar.style.borderStyle = 'double';
  guardar.style.backgroundColor = 'rgba(30, 50, 100, 0.5)';
  guardar.innerHTML = texto;
  guardar.setAttribute('onMouseOver', 'this.style.backgroundColor =\'rgba(30, 50, 200, 0.1)\'');
  guardar.setAttribute('onMouseOut', 'this.style.backgroundColor =\'rgba(30, 50, 100, 0.5)\'');
  guardar.setAttribute('onClick', 'this.style.backgroundColor =\'rgba(250, 50, 50, 0.5)\'');
  guardar.addEventListener('click', saveDatos);

  if(ebp_Idioma == 'es') {texto = 'Ver'}
  else {texto = 'See'}
  var mostrar = document.createElement('div')
  mostrar.setAttribute('id', 'CoAzMostrar')
  mostrar.style.borderColor = 'rgba(60, 150, 255, 0.3)';
  mostrar.style.borderWidth = 'thick';
  mostrar.style.borderStyle = 'double';
  mostrar.style.backgroundColor = 'rgba(30, 50, 100, 0.5)';
  mostrar.innerHTML = texto;
  mostrar.setAttribute('onMouseOver', 'this.style.backgroundColor =\'rgba(30, 50, 200, 0.1)\'');
  mostrar.setAttribute('onMouseOut', 'this.style.backgroundColor =\'rgba(30, 50, 100, 0.5)\'');
  mostrar.setAttribute('onClick', 'abreCierra()');

  var DOMParaBoton = document.getElementById('menu_w');
  boton.appendChild(testo);
  boton.appendChild(under)
  under.appendChild(tab)
  tab.appendChild(left)
  tab.appendChild(right)
  left.appendChild(guardar)
  right.appendChild(mostrar)
  DOMParaBoton.appendChild(boton);
}

function abreCierra() //CREA script para ABRIR Y CERRAR******************************************************************
{
  var scriptElemento = document.createElement('script');
  var scriptTexto = 'function abreCierra() {if(document.getElementById(\'CoAzFloater\').style.display === \'none\') {document.getElementById(\'CoAzFloater\').style.display = \'block\'} else {document.getElementById(\'CoAzFloater\').style.display = \'none\'};document.getElementById(\'CoAzMostrar\').style.backgroundColor = \'rgba(30, 250, 100, 0.5)\';}';
  scriptElemento.innerHTML = scriptTexto;
  document.body.appendChild(scriptElemento);
}

function checkForFirstPageRD(url){
    console.log("call to checkForFirstPageRD");
    var first = false;
    if (url.indexOf("sp=") != -1) {
       console.log("found")
       var pos = url.indexOf("sp=");
       var sub1 = url.substr(pos+3,1);
       var sub2 = url.substr(pos+4,1);
          if (sub1 == "1"){
              first = isNaN(sub2);
          }
          else{
              first = false;
          }
    }
    else {
       first = true;
       console.log("not found")
    }
    return first;
}

function saveDatos() //Implementada mediante eventListener en boton de guardar
{
  document.getElementById('CoAzGuardar').style.backgroundColor = 'rgba(230, 50, 100, 0.5)'; //por defecto el boton se pone rojo, si sale bien se vuelve verde
  var exportacion = document.getElementById('CoAzExporter').value;
  var nombreStorage;
  var pos_finLinea = exportacion.indexOf(String.fromCharCode(13, 10), 0);
  var primerLinea = exportacion.substring(0, pos_finLinea);
  var fechaHoy = retornaFecha(0);
  var direccion = document.URL; /* variable global*/
  var maxPagRR = 0;
  var maxPagRD = 0;
  if (direccion.indexOf('.com/c/?vl') != -1)
  {
    localStorage.setItem('usuario', exportacion);
    if (localStorage.getItem('usuario'))
    {
      document.getElementById('CoAzGuardar').style.backgroundColor = 'rgba(30, 250, 100, 0.5)'; /*si el registro es exitoso el boton se pone verde*/
    }
  }
  else if (direccion.indexOf('.com/c/rs/?vl') != -1)
  {
    localStorage.setItem('estadisticas', exportacion);
    if (localStorage.getItem('estadisticas'))
    {
      document.getElementById('CoAzGuardar').style.backgroundColor = 'rgba(30, 250, 100, 0.5)'; /*si el registro es exitoso el boton se pone verde*/
    }
  }
  else if (direccion.indexOf('c/rl', 0) != - 1 && direccion.indexOf('ss3=2') != -1)
  {
    console.log("pagina RR");
      var pagina;
      if (document.getElementsByClassName('branco_bt_p').length == 0){ //this doesn't fail as in RD because there's no "+" symbol for increasing limit
        pagina = 1;
      }
      else {
        var pag_modal = document.getElementById("pagina").childNodes;
        for (var i = 0; i < pag_modal.length; i++){
            if (pag_modal[i].selected) pagina = i+1;
          }
      }
    console.log("pagina N°: " + pagina)

      nombreStorage = 'RR_pag' + pagina;
      localStorage.setItem(nombreStorage, exportacion);
      if (localStorage.getItem(nombreStorage))
      {
        document.getElementById('CoAzGuardar').style.backgroundColor = 'rgba(30, 250, 100, 0.5)'; /*si el registro es exitoso el boton se pone verde*/
      }
      if (document.getElementsByClassName('branco_bt_p').length == 0 || (document.getElementsByClassName('branco_bt_p').length != 0 &&  document.getElementsByClassName('cinza_bt_p') [1].outerHTML.indexOf('&gt') != - 1) )
      {
        /*si no existe la flecha azul branco, solo tiene una pagina. Si existe, pero la flecha gris cinza contiene el caracter > (&gt), esta en la ultima pagina*/
        maxPagRR = pagina;
      }
  }
  else if (direccion.indexOf('c/rl', 0) != - 1 && direccion.indexOf('ss3=1') != -1)
  {
    console.log("pagina RD");
      var pagina;
      if (document.getElementsByClassName('branco_bt_p').length < 2 || document.getElementById("pagina") == undefined || checkForFirstPageRD(document.URL)){
        pagina = 1;
      }
      else {
        var pag_modal = document.getElementById("pagina").childNodes;
        for (var i = 0; i < pag_modal.length; i++){
          if (pag_modal[i].selected) pagina = i+1;
        }
      }
      nombreStorage = 'RD_pag' + pagina;
      localStorage.setItem(nombreStorage, exportacion);
      if (localStorage.getItem(nombreStorage))
      {
        document.getElementById('CoAzGuardar').style.backgroundColor = 'rgba(30, 250, 100, 0.5)'; /*si el registro es exitoso el boton se pone verde*/
      }
      if (document.getElementsByClassName('branco_bt_p').length == 1 /*RD page always has at least 1 branco, the "+" symbol for increasing the limit*/ || (document.getElementsByClassName('branco_bt_p').length != 0 &&  document.getElementsByClassName('cinza_bt_p') [1].outerHTML.indexOf('&gt') != - 1) )
      {
        /*si no existe la flecha azul branco, solo tiene una pagina. Si existe, pero la flecha gris cinza contiene el caracter > (&gt), esta en la ultima pagina*/
        setCookie("maxRD", pagina, 0.05);
      }
  }
  else
  {
    console.log('pagina no reconocida');
  }

  /*[Recupera los registros si esta en la ultima pagina de RR]*/
      /*[adverencias sobre falta de datos]*/
          var boolusuario = false;
          var boolestadisticas = false;
          var boolrr = true;
          var boolrd = true;
          var errorMsg = '';
          if (maxPagRR !== 0)
          {
            var maxPagRD = parseInt(getCookie("maxRD"));
            console.log("maxpagRR = " + maxPagRR)
            if (!localStorage.getItem('usuario'))
            {
              errorMsg = errorMsg + 'falta pagina de usuario' + String.fromCharCode(13, 10);
            } else {
              boolusuario = true;
            }
            if (!localStorage.getItem('estadisticas'))
            {
              errorMsg = errorMsg + 'falta pagina de estadisticas' + String.fromCharCode(13, 10);
            } else {
              boolestadisticas = true;
            }
            for (e = 1; e <= maxPagRR; e++)
            {
              nombreStorage = 'RR_pag' + e;
              if (!localStorage.getItem(nombreStorage))
              {
                errorMsg = errorMsg + 'falta la pagina de RR numero ' + e + String.fromCharCode(13, 10);
                boolrr = false;
              }
            }
            for (e = 1; e <= maxPagRD; e++)
            {
              nombreStorage = 'RD_pag' + e;
              if (!localStorage.getItem(nombreStorage))
              {
                errorMsg = errorMsg + 'falta la pagina de RD numero ' + e + String.fromCharCode(13, 10);
                boolrd = false;
              }
            }
          }
      /*[/adverencias sobre falta de datos]*/

      /*[extrae y une los localStorage]*/
          var acumulante = '';
          if (boolusuario && boolestadisticas && boolrr && boolrd)
          {
            for (e = 1; e <= maxPagRR; e++)
            {
              nombreStorage = 'RR_pag' + e;
              acumulante = acumulante + String.fromCharCode(13, 10) + localStorage.getItem(nombreStorage);
              localStorage.removeItem(nombreStorage);
            }
            acumulante = acumulante + String.fromCharCode(13, 10) + '---';
            var pagsRD = 1;
            nombreStorage = 'RD_pag' + pagsRD;
            while (localStorage.getItem(nombreStorage) != null)
            {
              acumulante = acumulante + String.fromCharCode(13, 10) + localStorage.getItem(nombreStorage);
              localStorage.removeItem(nombreStorage);
              pagsRD = pagsRD+1;
              nombreStorage = 'RD_pag' + pagsRD;
            }

            acumulante = localStorage.getItem('usuario') + String.fromCharCode(13, 10) + localStorage.getItem('estadisticas') + acumulante;
            document.getElementById('CoAzExporter').value = acumulante;
            document.getElementById('CoAzFloater').style.display = 'block';

            /*[borrar los local storage]*/
                localStorage.removeItem('usuario');
                localStorage.removeItem('estadisticas');
          }
          else if ((document.getElementsByClassName('branco_bt_p').length == 0 || (document.getElementsByClassName('branco_bt_p').length != 0 &&  document.getElementsByClassName('cinza_bt_p') [1].outerHTML.indexOf('&gt') != - 1)) && direccion.indexOf('ss3=2') != -1) /*es la clase que seniala a las flechas nulas de cambio de pagina. '&gt' es el simbolo '>'*/ /*ss3=2 identifica las paginas de RR*/
          {
            window.alert(errorMsg);
          }
      /*[extrae y une los localStorage]*/
  /*[/Recupera los registros si esta en la ultima pagina de RR]*/
}

function crea_CookieAdp() // implementada mediante intervalo en seccion de implementaciones
{
  var premioGanadoText = document.getElementById('prm_o1o').innerHTML;
  if (premioGanadoText.indexOf('$') !== - 1)
  {
    var fecha = retornaFecha(0);
    var nombre = 'adpM|' + fecha;
    setCookie(nombre, premioGanadoText, 4);
    clearInterval(timer);
    console.log('generada cookie mone')
  }
  else if (premioGanadoText.indexOf('P') !== - 1)
  {
    var fecha = retornaFecha(0);
    var nombre = 'adpP|' + fecha;
    setCookie(nombre, premioGanadoText, 4);
    clearInterval(timer);
    console.log('generada cookie puntos')
  }
  else if (premioGanadoText != '')
  {
    var fecha = retornaFecha(0);
    var nombre = 'adpP|' + fecha + 'loquesea';
    setCookie(nombre, premioGanadoText, 4);
    console.log('generada cookie lo que sea')
  }
}

function resetF()
{
    var message;
    if(ebp_Idioma == 'es')
    {message = 'CoAzExporter dice: \n ¿Es tu primer año como golden? \n Aceptar para SI \n Cancelar para NO'}
    else
    {message = 'CoAzExporter says: \n Is this your first year as golden? \n Accept for YES \n Cancel for NO'}

    if (!confirm(message))
    {
      setCookie('goldenStatus', 'Golden2', 360);
      console.log("2do ano")
    }
    else
    {
      setCookie('goldenStatus', 'Golden1', 360);
      console.log("1er ano")
    }
}

function gestionaOpciones()
{
    var boton;
    if(ebp_Idioma == 'es') {boton = 'Reiniciar CoAzExporter'}
    else {boton = 'Reset CoAzExporter'}

    if (getCookie('goldenStatus') !== '')
    {
      var reset = document.createElement('div'); //cuadro que contiene a los botones y la descripcion
          reset.setAttribute('id', 'CoAzExporterBoton');
          reset.style.borderColor = 'rgba(0, 50, 255, 0.5)';
          reset.style.borderWidth = 'thick';
          reset.style.borderStyle = 'double';
          reset.style.backgroundColor = 'rgba(30, 50, 200, 0.3)';
          reset.style.textAlign = 'center';
          reset.style.padding = '2px';
          reset.style.display = 'block';
          reset.style.cursor = 'pointer';
          reset.innerHTML = boton;
          reset.addEventListener('click', resetF);

      var DOMParaBoton = document.getElementById('menu_w');
      DOMParaBoton.appendChild(reset)
    }
}

//[implementaciones]
console.log('iniciando script coazexporter');
  if (direccion.indexOf('xc') !== - 1)
  {
      var timer = setInterval(function () {crea_CookieAdp()}, 500) //no hay ningun metodo fiable de saber cuando sera accesible el mensaje y por eso uso intervalo. onbeforeunload parece ejecutarse demasiado temprano
  }
  else if (direccion.indexOf('/c/d/?vl') != -1)
  {
      gestionaOpciones();
  }
  else
  {
      abreCierra();
      creaBoton();
      creaTablaCostado();
  }
//[/implementaciones]