Raw Source
thekeen / BACKOFFICE AUTOCOMPLETE

// ==UserScript==
// @name BACKOFFICE AUTOCOMPLETE
// @namespace BACKOFFICE AUTOCOMPLETE
// @match https://www.satwebportal.cloud/*
// @grant GM_xmlhttpRequest 
// @version     1.2.3
// @author      TheKeenAdvices
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js 
// @downloadURL https://backoffice.okcopy.it/pages/chiamate_chiusura/violentmonkey_connessione_satweb.js
// @description Last update su Contatori: modifica recupero variabili e inserimento valori su campi
// @license MIT
// @copyright 2020, thekeen (https://openuserjs.org/users/thekeen)
// ==/UserScript==
/* NUOVA FUNZIONE
 * data.rilcont1 = CONTATORE BIANCO/NERO
 * data.rilcont2 = CONTATORE COLORE
 * data.rilcont3 = CONTATORE SCANSIONI
 */

$(document).ready(function () {

  var getUrlParameter = function getUrlParameter(sParam) {
    var sPageURL = window.location.search.substring(1),
      sURLVariables = sPageURL.split('&'),
      sParameterName,
      i;

    for (i = 0; i < sURLVariables.length; i++) {
      sParameterName = sURLVariables[i].split('=');

      if (sParameterName[0] === sParam) {
        return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
      }
    }
  };

  $("#Sette60").prepend('<textarea id="autocompile" width=500 height=400>clicca qui per aggiornare</textarea><h2 style="background:#EE5555;">ATTENZIONE SCRIPT MODIFICATO</h2><input type="button" onClick="window.location.reload();" value="AGGIORNA SCRIPT">');
  $('#Testata').css('height', '75px');
  $('#Testata').css('overflow', 'hidden');

  // MOD ESTETICHE
  //$('.Tintervd:nth-of-type(2)').hide();
  //$('.Tintervd:nth-of-type(4)').hide();
  //$('.Tintervd:nth-of-type(5)').hide();
  //$('.Tintervd:nth-of-type(6)').hide();
  //$('.Tintervd:nth-of-type(7)').hide();

  $('.Tintervd:nth-of-type(3)').css('height', 'auto');
  $('.Tintervd:nth-of-type(3) tr:nth-of-type(2) td:nth-of-type(1)').css('max-height', '60px !important');
  $('.Tintervd:nth-of-type(3) td').css('height', '50px');

  $('.desintFF').css('padding', '10px');
  $('.desintFF').css('height', '80px');

  $('.notechiamFF').css('height', '40px');

  if ($('input[name=numdoc]').val() == getUrlParameter('numdoc')) {
    $("#autocompile").val(decodeURIComponent(getUrlParameter('json')));
    $('#autocompile').hide();

    if ($("#autocompile").val() != '') {
      var data = jQuery.parseJSON($("#autocompile").val());
      if (data.datint != '') {

        console.log('INIT COMPILE');
        console.log(data);

        // IMPOSTO DATA ORA
        $('input[name=datint]').val(data.dataint);
        $('input[name=orainih]').val(data.orainih);
        $('input[name=orainim]').val(data.orainim);

        $('input[name=orafinh]').val(data.orafinh);
        $('input[name=orafinm]').val(data.orafinm);
        $('input[name=orafinm]').change();

        $('input[name=oraviagh]').val(data.oraviagh);
        $('input[name=oraviagh]').change();
        $('input[name=oraviagm]').val(data.oraviagm);
        $('input[name=oraviagm]').change();

        $('input[name=kmviag]').val(data.kmviag);
        $('input[name=kmviag]').change();

        // IMPOSTO TARIFFA
        $('select[name=tariffa]').val("Z").change();

        // IMPOSTO CONTATORI
        $(".Tintervd td:contains(CBK )").next().find('input').val(data.rilcont1);
        $(".Tintervd td:contains(CFS )").next().find('input').val(data.rilcont2);
        $(".Tintervd td:contains(SSC )").next().find('input').val(data.rilcont3);

        $('.desintFF').val(data.description);
        console.log('END COMPILE');
        //$('.desintFF').val()
        $('.desintFF').change();
        //$('input[name=bot_invia]').click();

      }
      else {
        console.log('not_set_DATE');

      }

    }
    else {
      console.log('not_set');

    }
  }
  else {

  }
});