Skip to content

Instantly share code, notes, and snippets.

@willguitaradmfar
Last active June 2, 2020 16:38
Show Gist options
  • Save willguitaradmfar/c8fac0e3eb821566e3d0b6db32c901dc to your computer and use it in GitHub Desktop.
Save willguitaradmfar/c8fac0e3eb821566e3d0b6db32c901dc to your computer and use it in GitHub Desktop.
Leilão de carros
// https://virtusmotaleiloes.com/
var run = (meuLogin = 'seuLogin', tempoRestanteSegundos = 30, valorLimite = 30000) => {
document.querySelector('#box_info_leilao li:nth-child(2) a').click()
let history = Array.from(document.querySelectorAll('#box_info_leilao li:nth-child(5) tbody tr'))
if(!history.length) return
history = history
.map(tr => Array.from(tr.querySelectorAll('td')))
.map(line => ({ login: line[1].innerText, valor: line[4].innerText}))
.map(line => {
line.valor = line.valor.replace('R$', '').replace('.', '').replace(',', '.')
line.valor = parseFloat(line.valor)
return line
})
let limitDate = document.querySelector('.p20.back_F6F6F6.quadrado .LL_data_fim .dib:nth-child(2)')
let limitTime = document.querySelector('.p20.back_F6F6F6.quadrado .LL_data_fim .dib:nth-child(3)')
const [dia, mes, ano] = limitDate.innerText.split('/')
const date = new Date(`${ano}-${mes}-${dia}T${limitTime.innerText}:00`)
const diffTimeSegundos = (date.getTime() - Date.now()) / 1000
const popHistory = history.length ? history.pop() : undefined
if(popHistory.login !== meuLogin && diffTimeSegundos <= tempoRestanteSegundos && popHistory.valor <= valorLimite) {
console.log('dar lance')
const url = location.href.split('/')
let code
while(true) {
code = url.pop()
if(code) break
}
dar_lance(code, document.querySelector('li.wr6.wr12_700.mb10.p0_700.pr10 a'))
} else {
console.log(`
Login: ${meuLogin}, Tempo restante: ${diffTimeSegundos.toFixed(0)}s
Ultimo lance: ${popHistory.login}
Valor atual: ${popHistory.valor.toFixed(2)} (Limite: ${valorLimite.toFixed(2)})
`)
}
};
setTimeout(() => run(), 1000 * 10)
setInterval(() => {
if(!document.querySelector('#box_info_leilao li:nth-child(2) a')) return
location.reload()
}, 1000 * 15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment