Created
July 4, 2020 19:21
-
-
Save lucaslgr/58f4a75ec582b0d90c4e1197e1c2bbbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Encapulando o document.querySelector e o document.querySelectorAll para reutilizar código | |
const $ = document.querySelector.bind(document); | |
const $$ = document.querySelectorAll.bind(document); | |
document.addEventListener('DOMContentLoaded', () => { | |
$('#btn-play').addEventListener('click', () => { | |
$('span').innerText = "Aguarde..."; | |
const urlBling = "https://www.bling.com.br/vendas.lojas.virtuais.php"; | |
// window.location.href = "https://www.bling.com.br/vendas.lojas.virtuais.php"; | |
importPurchases(urlBling); | |
}) | |
}); | |
async function importPurchases(urlBling) { | |
chrome.tabs.update({ url: urlBling }, async () => { | |
(async function () { | |
let btnVisualizar = await $('#btn-visualizar'); | |
btnVisualizar.click(); | |
todosPedidos = await $$('.tabela-listagem > tbody > tr > td:nth-child(6) a.link'); | |
todosPedidos.forEach( | |
(eachItem) => { | |
eachItem.click(); | |
} | |
) | |
$('.ui-dialog button.ui-button').click(); | |
importPurchases(); | |
}()) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment