Skip to content

Instantly share code, notes, and snippets.

@reggi
Last active April 14, 2021 16:41
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 reggi/97287e8a89bdee59f80b85074148076e to your computer and use it in GitHub Desktop.
Save reggi/97287e8a89bdee59f80b85074148076e to your computer and use it in GitHub Desktop.
This records keypresses in google voice and will add in 2 second pauses via ",".
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;
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment