Thomas Reggi's Profile Image

@thomasreggi 🌸

How I Automated the Unemployment Call Hotline with JavaScript.

April 14, 2021 (Syndicated From dev.to)

The goal is to get a hold of a representative from New York state’s unemployment office. New York state has an unemployment claim help hotline is a series of prompts that drags then after about 5 minutes, you’re spit out into a ditch on the side of the New Jersey Turnpike, and the call hangs up. Rinse, repeat, rinse, repeat.

These systems are automated, why should we have to repeat the same prompts over and over and over. Most automated call systems allow you to press 0 to speak to a representative, however not the NY unemployment hotline. It seems like they deliberately make the series of prompts very difficult to navigate.

Alas there is a simple way to automate this on our end. Most digital phone apps treat a comma (,) as a two second pause, so we can use and abuse this to our advantage.

I created a browser bookmarklet (piece of code that runs in on any page in the browser) for Google Voice. The script will start “recording” keypresses and append a comma every two seconds and log them to the console.

javascript:console.clear()%0Aconsole.log('Starting Google Voice capture bookmarklet')%3B%0A%0Alet buttons %3D %7B%0A '1'%3A document.querySelector(%60%5Baria-label%3D"1"%5D%60)%2C%0A '2'%3A document.querySelector(%60%5Baria-label%3D"'2' 'a' 'b' 'c'"%5D%60)%2C%0A '3'%3A document.querySelector(%60%5Baria-label%3D"'3' 'd' 'e' 'f'"%5D%60)%2C%0A '4'%3A document.querySelector(%60%5Baria-label%3D"'4' 'g' 'h' 'i'"%5D%60)%2C%0A '5'%3A document.querySelector(%60%5Baria-label%3D"'5' 'j' 'k' 'l'"%5D%60)%2C%0A '6'%3A document.querySelector(%60%5Baria-label%3D"'6' 'm' 'n' 'o'"%5D%60)%2C%0A '7'%3A document.querySelector(%60%5Baria-label%3D"'7' 'p' 'q' 'r' 's'"%5D%60)%2C%0A '8'%3A document.querySelector(%60%5Baria-label%3D"'8' 't' 'u' 'v'"%5D%60)%2C%0A '9'%3A document.querySelector(%60%5Baria-label%3D"'9' 'w' 'x' 'y' 'z'"%5D%60)%2C%0A '0'%3A document.querySelector(%60%5Baria-label%3D"'0'"%5D%60)%0A%7D%0A%0Alet recording %3D ""%0Aconsole.log(%60Recording is "%24%7Brecording%7D"%60)%0A%0Afunction startComma () %7B%0A setInterval(() %3D> %7B%0A recording %3D recording %2B '%2C'%0A console.log(%60Recording is "%24%7Brecording%7D"%60)%0A %7D%2C 2000)%0A%7D%0A%0Aconsole.log('Looping through keypad buttons')%3B%0Aconst buttonKeys %3D Object.keys(buttons)%3B%0Aconsole.log(%60The button keys are %24%7BbuttonKeys.join('%2C')%7D%60)%3B%0A%0AbuttonKeys.map(number %3D> %7B%0A console.log(%60Setting handler for button %24%7Bnumber%7D%60)%3B%0A let selector %3D buttons%5Bnumber%5D%3B%0A if (!selector) throw new Error('Select for "%24%7Bnumber%7D" was null check the query')%0A selector.addEventListener('click'%2C function (event) %7B%0A if (recording %3D%3D%3D "") startComma()%3B%0A recording %3D recording %2B number%3B%0A %7D)%0A%7D)
console.clear()
console.log('Starting Google Voice capture bookmarklet');
let buttons = {
'1': document.querySelector(`[aria-label="1"]`),
'2': document.querySelector(`[aria-label="'2' 'a' 'b' 'c'"]`),
'3': document.querySelector(`[aria-label="'3' 'd' 'e' 'f'"]`),
'4': document.querySelector(`[aria-label="'4' 'g' 'h' 'i'"]`),
'5': document.querySelector(`[aria-label="'5' 'j' 'k' 'l'"]`),
'6': document.querySelector(`[aria-label="'6' 'm' 'n' 'o'"]`),
'7': document.querySelector(`[aria-label="'7' 'p' 'q' 'r' 's'"]`),
'8': document.querySelector(`[aria-label="'8' 't' 'u' 'v'"]`),
'9': document.querySelector(`[aria-label="'9' 'w' 'x' 'y' 'z'"]`),
'0': document.querySelector(`[aria-label="'0'"]`)
}
let recording = ""
console.log(`Recording is "${recording}"`)
function startComma () {
setInterval(() => {
recording = recording + ','
console.log(`Recording is "${recording}"`)
}, 2000)
}
console.log('Looping through keypad buttons');
const buttonKeys = Object.keys(buttons);
console.log(`The button keys are ${buttonKeys.join(',')}`);
buttonKeys.map(number => {
console.log(`Setting handler for button ${number}`);
let selector = buttons[number];
if (!selector) throw new Error('Select for "${number}" was null check the query')
selector.addEventListener('click', function (event) {
if (recording === "") startComma();
recording = recording + number;
})
})

To add this bookmarklet to your bookmark bar, follow these steps:

  1. Copy the minified / formatted code below
  2. Right click on the bar, click “Add Page”
  3. Paste the code in the “URL” field.
  4. Click “Save”

Now, go to https://voice.google.com/, open “Developer tools” and then click on the bookmarklet you created.

Then all you need to do is copy the output from the browser’s console, you may need to add some beginning commas for the initial prompt, as commas only start appending after the first keypress.

‪(888) 209-8124‬,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9,,,,,,,,,,,,,,2,,,,,,,,,,,<SOCIAL-SECURITY-NUMBER>,,,,,,1,,<FOUR-DIGIT-PIN>,,,,,,2,,2,,2,,,,,,,,,,,5,,,,,,1

From there you would need to replace <SOCIAL-SECURITY-NUMBER> and <FOUR-DIGIT-PIN> with your own personal information. Be careful when automating anything with your personal information, be cautious when finding phone numbers and make sure they come from the businesses website directly.

Caveats, if the hotline changes the prompts, the generated number will break, so keep tabs with updates to the hotline.