100% found this document useful (1 vote)
38 views2 pages

Open

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
38 views2 pages

Open

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

// ==UserScript==

// @name Open Calendrier Date and timeslot


// @namespace http://tampermonkey.net/
// @version 2,9
// @author ouahid
// @match
https://algeria.blsspainglobal.com/*/blsAppointment/ManageAppointment*
// @downloadURL none
// ==/UserScript==
'use strict';

var containerDiv = document.createElement('div');


containerDiv.style.display = 'flex';

var openButton = document.createElement('button');


openButton.textContent = 'OpenCalendar';
openButton.id = 'openCalendar';
openButton.className = 'open-and-choose';

openButton.addEventListener('click', function () {
var therightslot = ""; // Define therightslot variable
var idPatterns = ["AppointmentDate1", "AppointmentDate2", "AppointmentDate3",
"AppointmentDate4", "AppointmentDate5"];
var selectedDivs = [];
idPatterns.forEach(function (idPattern) {
var divsWithInput = document.querySelectorAll("div:has(input#" + idPattern +
")");
selectedDivs = selectedDivs.concat(Array.from(divsWithInput));
});
var visibleDivs = selectedDivs.filter(function (div) {
return getComputedStyle(div).display !== "none";
});
visibleDivs.sort(function (a, b) {
var indexA = Array.from(a.parentNode.children).indexOf(a);
var indexB = Array.from(b.parentNode.children).indexOf(b);
return indexB - indexA;
});
var highestIndexDiv = visibleDivs[0];
var foundInput = highestIndexDiv.querySelector('input');
var appdateid = foundInput.id;
$('#' + appdateid).data("kendoDatePicker").open();
var dates = document.querySelectorAll('a.k-link');
dates.forEach((date) => {
if (date.title == "Monday, october 23, 2023") date.click();
});

// Simulate a delay of one second before running the slot button functionality
setTimeout(function () {
var slotids = ['AppointmentSlot1', 'AppointmentSlot2', 'AppointmentSlot3',
'AppointmentSlot4', 'AppointmentSlot5'];
slotids.forEach(function (slotid) {
var slotelement = $(".k-widget.k-dropdown.form-control[aria-owns='" + slotid
+ "_listbox']");
if (slotelement.is(":visible")) {
therightslot = "AppointmentSlot" + slotid.slice(15);
}
});
var slotval = document.getElementById(therightslot);
slotval.style.display = 'block';
slotval.value = '08:30-09:30';
}, 1000); // Delay of one second
});

containerDiv.appendChild(openButton);

var targetDiv = document.querySelector("#appointmentDetailsDiv > div.card-body");


targetDiv.insertBefore(containerDiv, targetDiv.firstChild);

You might also like