// ==UserScript==
// @name Dates VFS France Bra Kherroubi
// @namespace http://tampermonkey.net/
// @version 0.2
// @description try to take over the world!
// @author You
// @match https://online.vfsglobal.dz/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function formatAMPM(date) {
var hours = date.getHours();
var minutes = date.getMinutes();
var ampm = hours >= 12 ? 'pm' : 'am';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0'+minutes : minutes;
var sec = date.getSeconds();
var strTime = hours + ':' + minutes + ':' + sec + ' ' + ampm;
return strTime;
}
var token = $('[name=__RequestVerificationToken]').val();
var headers = {};
headers["__RequestVerificationToken"] = token;
var MonNames =
['0','Janvier','F�vrier','Mars','Avril','Mai','Juin','Juillet','Aout','Septembre','
Octobre','Novembre','Decembre'];
var d = new Date();
var nextMon = d.getMonth()+1;
var myMonth = nextMon+1;
var datetime = (d.getMonth()+1) + "/" + d.getDate() + "/" + d.getFullYear() +
" " + formatAMPM(d);
function switchDate(x){
if(x=='+'){
myMonth++;
if(myMonth>12){
myMonth = 1;
}
GetDates(myMonth);
}
if(x=='-'){
myMonth--;
if(myMonth<1){
myMonth = 12;
}
GetDates(myMonth);
}
$('#monthName').text(MonNames[myMonth]);
}
//$("#PrimaryEmailId").val("[email protected]");
//setInterval(function(){console.log($('form').serialize());},2000);
console.error('------------------------------------------------
TECHEKTECHOUKAAAAA-------------------------------------------------------------');
//$('.leftNav-ul').append('<li class="inactive-link"><a href="/Global-
Appointment/Home/LocationLocked">Under Configuration</a></li> <!--Schedule =
Dahmane Elkerwachi -->');
$('.leftNav-ul').append('<li class="inactive-link" style="margin-top:
20px;"><div style="width: 100%;height: 42px;font-size: 18px;"><button type="button"
id="monMinus" style="width: 20%; height: 42px;background: #00305d">-
</button><button type="button" id="monthName" style="width:60%;height: 42px; color:
#000" disabled>'+MonNames[myMonth]+'</span><button type="button" id="monPlus"
style="width: 20%; height: 42px; background:#00305d">+</button></div></li> <!--
Schedule = Dahmane Elkerwachi -->'); $('.leftNav-ul').append('<li
class="inactive-link"><select id="AvDates" style="width: 100%;height: 42px;color:
#000;font-size: 18px;"></select></li> <!--Schedule = Dahmane Elkerwachi -->');
$('.leftNav-ul').append('<li class="inactive-link"><select id="AvTime"
style="width: 100%;height: 42px;color: #000;font-size: 18px;"></select></li> <!--
Schedule = Dahmane Elkerwachi -->');
$('.leftNav-ul').append('<li class="inactive-link"><button type="button"
style="width: 100%;height: 42px;background:#00305d;"
id="Cheg3assen">Confirmer</button></li> <!--Schedule = Dahmane Elkerwachi -->');
$('.leftNav-ul').append('<li class="inactive-link"><input type="checkbox"
id="Azegdouf" value="1"/> Auto Refresh</li> <!--Schedule = Dahmane Elkerwachi
-->');
$('#monMinus').on('click',function(){switchDate('-')});
$('#monPlus').on('click',function(){switchDate('+')});
$('#Cheg3assen').on('click',function(){$('#TheForm').submit();});
//Get Earliest Date
/*$.ajax({
type: 'POST',
url: '/Global-Appointment/Account/GetEarliestVisaSlotDate', // calling
json method
headers: headers,
dataType: 'JSON',
data: {
countryId: 1,
missionId: 19,
LocationId: 281,
VisaCategoryId: 782
},
cache: false,
success: function (data) {
console.error(data);
}
});*/
//Get Dates
var i,daysav;
function AvTime(){
daysav = calDays[$('#AvDates').val()]['TimeBands'];
i = daysav.length-1;
$("#AvTime").html('');
while(i>=0){
$("#AvTime").append('<option value="'+daysav[i]['AllocationId']
+'">'+daysav[i]['StartTime']+' - '+daysav[i]['EndTime']+' - '+daysav[i]
['RemainingSlots']+' Slots</option>');
i--;
}
AllocationId()
}
function AllocationId(){
$('#AllocationId').val($('#AvTime').val());
}
$('#AvDates').on('change',function(){
AvTime();
});
$('#AvTime').on('change',function(){
AllocationId();
});
function myFunction(item, index) {
if(item['IsHoliday']==false && item['IsWeekend']==false){
$("#AvDates").append('<option value="'+index+'">'+item['Date']
+'</option>');
}
}
var calDays;
function GetDates(m){
$.ajax({
url: '/Global-Appointment/Calendar/GetCalendarDaysOnViewChange',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
headers: headers,
data: {
month: m,
year: 2020,
bookingType: 'General'
},
async: false,
success: function (data) {
calDays = JSON.parse(data.CalendarDatesOnViewChange);
$("#AvDates").html('');
calDays.forEach(myFunction);
AvTime();
},
cache: false,
});
}
GetDates(myMonth);
$("#Azegdouf").on('change',function(){
if(document.getElementById('Azegdouf').checked==true){
setInterval(function(){
if(document.getElementById('Azegdouf').checked==true){
GetDates(myMonth);
console.info('Dates Actualis�s!');
}else{
console.info('Dates Toz!');
}
},3000);
}
});
//Create Form
$("#footer").html('<form action="/Global-Appointment/Calendar/FinalCalendar"
method="post" novalidate="novalidate" id="TheForm" style="display: none;"><input
name="__RequestVerificationToken" value="'+token+'"><input
name="AvailableDatesAndSlotsJSON" value="[]"><input
name="EncryptedSelectedAllocationId" id="AllocationId" value=""><input
name="PreviousScheduleDateTimeMessage" value=""><input name="URN" id="TheirURN"
value=""><input name="isPaymentPageRequired" value="False"><input
name="isCriteriaPageRequired" value="False"><input name="VisaCategory" value="Short
Stay"><input name="PurposeOfTravel" value=""><input
name="EnablePaymentGatewayIntegration" value="False"><input
name="NumberOfApplicants" value="1"><input name="applicantList.PassportNumber"
value=""><input name="applicantList.AURN" value=""><input
name="EarliestAllotedMonth" value="2"><input name="EarliestAllotedYear"
value="2020"><input name="LastAllocatedDate" value="3/23/2020 12:00:00 AM"><input
name="LocationDateTime" value="'+datetime+'"><input name="IsPaymentAtBank"
value="True"><input name="IsPaymentAtVac" value="0"><input name="monthsname"
value="January,February,March,April,May,June,July,August,September,October,November
,December"><input name="daysname" value="Sun,Mon,Tue,Wed,Thu,Fri,Sat"><button
type="submit">SEND</button></form>');
$("#footer input").css("color","black");
AllocationId();
$('#TheirURN').val($('b:contains(FRAG)').text());
})();