Skip to content

Instantly share code, notes, and snippets.

@lucaslgr
Created July 4, 2020 19:21
Show Gist options
  • Save lucaslgr/58f4a75ec582b0d90c4e1197e1c2bbbc to your computer and use it in GitHub Desktop.
Save lucaslgr/58f4a75ec582b0d90c4e1197e1c2bbbc to your computer and use it in GitHub Desktop.
//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