Compare dates
This commit is contained in:
parent
f8f0efd168
commit
8b14b4b2e4
21
content.js
21
content.js
@ -2,7 +2,7 @@
|
||||
function sendPostRequest(data) {
|
||||
fetch('https://ntfy.sh/snegov', {
|
||||
method: 'POST', // PUT works too
|
||||
body: `check US visa: ${data}`
|
||||
body: `US visa: ${data}`
|
||||
})
|
||||
.then(response => {
|
||||
console.log('POST request sent successfully:', data);
|
||||
@ -12,21 +12,26 @@ function sendPostRequest(data) {
|
||||
});
|
||||
}
|
||||
|
||||
// Function to check the date from the specific element
|
||||
function checkDate() {
|
||||
const targetElement = document.querySelector('.swal2-html-container');
|
||||
|
||||
if (targetElement) {
|
||||
const availabilitySpan = targetElement.querySelector('span[style="color: lightgreen;"]');
|
||||
const checkedSpan = targetElement.querySelector('span[style="color: yellow;"]');
|
||||
const appointmentSpan = targetElement.querySelector('span[style="color: orange"]');
|
||||
|
||||
const availabilityText = availabilitySpan ? availabilitySpan.textContent.trim() : null;
|
||||
const checkedText = checkedSpan ? checkedSpan.textContent.trim() : null;
|
||||
const appointmentText = appointmentSpan ? appointmentSpan.textContent.trim() : null;
|
||||
const date_avail = availabilitySpan ? availabilitySpan.textContent.match(/Latest availability: (.*)\./)[1].trim() : null;
|
||||
const date_booked = appointmentSpan ? appointmentSpan.textContent.match(/Your current appointment is on (.*)/)[1].trim() : null;
|
||||
|
||||
const data = `${availabilityText}, ${checkedText}, ${appointmentText}`;
|
||||
sendPostRequest(data);
|
||||
if (date_avail && date_booked) {
|
||||
const date_avail_date = new Date(date_avail);
|
||||
const date_booked_date = new Date(date_booked);
|
||||
|
||||
// Compare the dates
|
||||
if (date_avail_date < date_booked_date) {
|
||||
const message = `available date ${date_avail}; booked on ${date_booked}`;
|
||||
sendPostRequest(message);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('Element with class "swal2-html-container" not found');
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user