Kalendár pre "Vakcinácia"

Pridá kalendár na stránku Vakcinácia/NCZI

目前為 2021-06-27 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Kalendár pre "Vakcinácia"
// @namespace    Ambee & Vakcinácia
// @version      0.1
// @description  Pridá kalendár na stránku Vakcinácia/NCZI
// @author       MartinV
// @require      https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js
// @match        https://vakcinacia.nczisk.sk/*
// @match        https://vakcinacia-portal.nczisk.sk/*
// @icon         https://www.google.com/s2/favicons?domain=nczisk.sk
// @grant        none
// ==/UserScript==

(function() {

    var scriptInput = document.createElement("input");
    scriptInput.type = 'text';
    scriptInput.id = 'datepicker';
    scriptInput.style = 'position:relative;left:14px';
    document.getElementsByClassName('idsk-header__container govuk-width-container')[0].appendChild(scriptInput);

    var script = document.createElement("script");
    var scriptBody =
        `$(function() {
		$("#datepicker").datepicker({
        firstDay: 1,
        dayNames: ["Nedeľa", "Pondelok", "Utorok", "Streda", "Štvrtok", "Piatok", "Sobota"],
        dayNamesMin: ["Ne", "Po", "Ut", "St", "Št", "Pi", "So"],
        dateFormat: "yy-mm-dd"
        });


		$("#datepicker").on("change", function(event) {
            var datePattern = /(\d{4}-\d{2}-\d{2})/,
                newDate = event.target.value,
                currentURL = window.location.href,
                newURL = currentURL.replace(datePattern, newDate);
            //alert(newURL);
            window.location.href = newURL;
            // https://vakcinacia-portal.nczisk.sk
		});
	});`;

    script.appendChild(document.createTextNode(scriptBody));
    (document.body || document.head || document.documentElement).appendChild(script);

})();