gogolian / Nazwa.pl autoresponder Helper

// ==UserScript==
// @name        Nazwa.pl autoresponder Helper
// @namespace   https://kamilwezyk.pl
// @include     https://admin.nazwa.pl/accounts/modify/*
// @version     1
// @license MIT

// @require       https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @require       https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js

// ==/UserScript==

function display(msg) {	$("<p>").html(msg).appendTo(document.body); }

$("body").append('<div id="gbox" style="display: block;position: absolute;border: 1px solid grey; border-radius:4px; top: 0;background: white;z-index: 99999; padding: 20px;"></div>');


//FROM
$("#gbox").append('OD:<br/><div id="g-datepicker-from" style="margin: 10px 0;"></div>');

$( "#g-datepicker-from" ).datepicker({
	dateFormat: 'yy-mm-dd',
    onSelect: function(dateText) {
      display("Selected 'from' date: " + dateText + "; input's current value: " + this.value);
	  $("#dateFrom").attr('value', dateText + ' 00:01');
	  $("#dateFrom").val(dateText + ' 00:01');
    }
  }).on("change", function() { display("Got change event from field"); });


$("#gbox").append('DO:<br/><div id="g-datepicker-to" style="margin: 10px 0;"></div>');
$( "#g-datepicker-to" ).datepicker({
	dateFormat: 'yy-mm-dd',
    onSelect: function(dateText) {
      display("Selected 'to' date: " + dateText + "; input's current value: " + this.value);
	  $("#dateTo").attr('value', dateText + ' 23:59');
	  $("#dateTo").val(dateText + ' 23:59');
    }
  }).on("change", function() { display("Got change event from field"); });

  
$("#gbox").append('<button id="g-change-tresc" style="padding: 8px 59px; margin: 10px 0;">USTAW TREŚĆ</button><br/>');
$( "#g-change-tresc" ).button().on("click", function() { setTematAndBody(); });


$("#gbox").append('<button id="g-my-submit" style="padding: 8px 77px; margin: 10px 0;">ZAPISZ</button>');
$( "#g-my-submit" ).button().on("click", function() {
	$( ".button_line #submit" ).click();
});

//alert("Hello World");

function setTematAndBody()
{
    $(".vacation .config_add_form .form_line #subject").attr('value', 'Out of Office / Poza biurem');
	
	var dod = $( "#g-datepicker-from" ).datepicker({ dateFormat: 'yy-mm-dd' }).val();
	var ddo = $( "#g-datepicker-to" ).datepicker({ dateFormat: 'yy-mm-dd' }).val();
	var imie = $( "#realName" ).val();
	
	var txt = 'Dziękuję za wiadomość,\n\nUprzejmie informuję, że ';
	if( dod == ddo )
	{
		txt += 'dnia ' + dod;
	}
	else
	{
		txt += 'od ' + dod;
		txt += ' do ' + ddo;
	}
	txt += ' przebywam poza biurem z ograniczonym dostępem do skrzynki e-mail.\nNa wszystkie wiadomości odpowiem po powrocie.\n\n';
	txt += imie;
	txt += '\n……………………………………………………………………………………………………………………………………………\n\nThank you for your e-mail,\n\nPlease note that ';
	if( dod == ddo )
	{
		txt += dod;
	}
	else
	{
		txt += 'from ' + dod;
		txt += ' till ' + ddo;
	}
	txt += ' I am out of the office with limited access to my email.\n\nI will reply to all the e-mails as soon as I am back in the office.\n\n';
	txt += imie;
	
	$(".vacation .config_add_form .form_line .fullsize_textarea #body").text(txt);
}