Created
July 13, 2023 22:12
-
-
Save kellbot/9bc4785d1b8a04c633150a3d3fe831c6 to your computer and use it in GitHub Desktop.
TTP Checker
This file contains 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
const puppeteer = require("puppeteer-extra"); | |
//const cheerio = require("cheerio"); | |
const fs = require("fs"); | |
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args)); | |
const StealthPlugin = require('puppeteer-extra-plugin-stealth'); | |
const { Message } = require('@notify.events/nodejs'); | |
puppeteer.use(StealthPlugin()); | |
async function getData(url) { | |
let response = await fetch(url); | |
return response.text(); | |
} | |
async function checkGlobalEntry(data){ | |
let appointments = JSON.parse((await data)); | |
let thursdays = appointments.filter(appointment => { | |
let d = new Date(appointment.startTimestamp); | |
if ([4,6].includes(d.getDay()) && d.getMonth() < 8) return true; | |
}); | |
if (thursdays.length > 0) { | |
console.log('found'); | |
const token = 'NOTIFY.EVENTS TOKEN HERE'; | |
let notice = "Global Entry Appointments Available: \n"; | |
thursdays.forEach(appointment => {notice += appointment.startTimestamp + "\n"}) | |
let message = new Message(notice); | |
message.send(token); | |
} | |
} | |
checkGlobalEntry(getData('https://ttp.cbp.dhs.gov/schedulerapi/slots?orderBy=soonest&limit=100&locationId=5445&minimum=1')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment