Skip to content

Instantly share code, notes, and snippets.

@kellbot
Created July 13, 2023 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellbot/9bc4785d1b8a04c633150a3d3fe831c6 to your computer and use it in GitHub Desktop.
Save kellbot/9bc4785d1b8a04c633150a3d3fe831c6 to your computer and use it in GitHub Desktop.
TTP Checker
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