diff --git a/content.js b/content.js new file mode 100644 index 0000000..1fe6228 --- /dev/null +++ b/content.js @@ -0,0 +1,36 @@ +// Function to send POST request +function sendPostRequest(data) { + fetch('https://ntfy.sh/snegov', { + method: 'POST', // PUT works too + body: `check US visa: ${data}` + }) + .then(response => { + console.log('POST request sent successfully:', data); + }) + .catch((error) => { + console.error('Error sending POST request:', error); + }); +} + +// 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 data = `${availabilityText}, ${checkedText}, ${appointmentText}`; + sendPostRequest(data); + } else { + console.log('Element with class "swal2-html-container" not found'); + } +} + +// Set an interval to check the date every 10 seconds +setInterval(checkDate, 15000); diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..1343e41 --- /dev/null +++ b/manifest.json @@ -0,0 +1,12 @@ +{ + "manifest_version": 3, + "name": "Page Change Detector", + "version": "1.0", + "permissions": ["activeTab"], + "content_scripts": [ + { + "matches": ["https://ais.usvisa-info.com/*"], + "js": ["content.js"] + } + ] +}