Created
March 7, 2023 17:43
-
-
Save omarandstuff/8787ed815c6ae6f6747224b8eb01f585 to your computer and use it in GitHub Desktop.
Date checker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Requirements | |
1.- Go make an account in https://www.mynotifier.app/, and get your api token | |
- Install the app in your phone and registr your device in such app | |
- You can use any other notification system but this one send you push notifications to your phone wich is neat | |
2.- You need to be in the proces od scheduling a date and need to be placed in that page at the monent | |
- Open developer tools and replace your credentials | |
- 'x-csrf-token': '<Your csrf token>', get this by spying other request being made in the page | |
or by recognizing the actual request for the dates | |
- Paste this script in the console and press enter | |
*/ | |
let lastGoodDate = '2024-09-25' | |
async function checkDates() { | |
const dates = await getGdlDates() | |
const bestDate = dates[0].date | |
if (bestDate.split('-').join() < lastGoodDate.split('-').join()) { | |
lastGoodDate = bestDate | |
console.log('Best date changed:', bestDate) | |
await pushNotification('Best date changed:', bestDate, 'success') | |
} else { | |
console.log('Best date stayed the same:', bestDate) | |
} | |
delayCheck() | |
} | |
function delayCheck() { | |
const randomTime = 1000 * 30 + 1000 * 30 * Math.random() | |
setTimeout(checkDates, randomTime) | |
} | |
async function getGdlDates() { | |
return await ( | |
await fetch('https://ais.usvisa-info.com/es-mx/niv/schedule/47330413/appointment/days/66.json?appointments[expedite]=false', { | |
headers: { | |
accept: 'application/json, text/javascript, */*; q=0.01', | |
'accept-language': 'en-US,en;q=0.9,es-419;q=0.8,es;q=0.7,de;q=0.6', | |
'if-none-match': 'W/"aa793c00bcbf4300dfe3bb4759fdb322"', | |
'sec-ch-ua': '"Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110"', | |
'sec-ch-ua-mobile': '?0', | |
'sec-ch-ua-platform': '"macOS"', | |
'sec-fetch-dest': 'empty', | |
'sec-fetch-mode': 'cors', | |
'sec-fetch-site': 'same-origin', | |
'x-csrf-token': '<Your csrf token>', | |
'x-requested-with': 'XMLHttpRequest' | |
}, | |
referrer: 'https://ais.usvisa-info.com/es-mx/niv/schedule/47330413/appointment', | |
referrerPolicy: 'strict-origin-when-cross-origin', | |
body: null, | |
method: 'GET', | |
mode: 'cors', | |
credentials: 'include' | |
}) | |
).json() | |
} | |
async function pushNotification(message, description, type) { | |
await fetch(`https://api.mynotifier.app`, { | |
method: 'post', | |
headers: { 'Content-Type': 'application/json' }, | |
body: JSON.stringify({ apiKey: '<your api key>', message, description, body: '', type, project: '' }) | |
}) | |
} | |
checkDates() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment