Skip to content

Instantly share code, notes, and snippets.

@adamyonk
Last active October 18, 2018 15:58
Show Gist options
  • Save adamyonk/6a881d61564a14a1000bcc147c8293f0 to your computer and use it in GitHub Desktop.
Save adamyonk/6a881d61564a14a1000bcc147c8293f0 to your computer and use it in GitHub Desktop.
$ npm i -g puppeteer
$ NODE_PATH=$(npm -g root) node uhk.js
> 20 days
#!/usr/bin/env node
const puppeteer = require("puppeteer");
// Replace this with your own ID, not including any # symbol
const ID = 62180;
const run = async () => {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.goto("https://ultimatehackingkeyboard.com/delivery-status");
await page.waitFor("#app tr");
let nodes = await page.$$eval("#app tr", nodes =>
nodes.map(n => n.innerText)
);
let date = nodes.filter(t => t.match(` #?${ID} `))[0].match(/[^ ]*/)[0];
if (date !== "shipped") {
date = Math.ceil((new Date(date) - new Date()) / 60 / 60 / 24 / 1000);
date += " days";
}
console.log(date);
await browser.close();
};
try {
run();
} catch (error) {
console.warn(error);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment