Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name mercadoflow 17/06/2019
- // @version 1
- // @grant none
- // ==/UserScript==
- var url_atual = window.location.href;
- url_atual = url_atual.substring(8, 39);
- if(url_atual=="www.mercadolivre.com.br/vendas/")
- {
- var telefone, nomeCliente, nomeProduto, conteudo, codmercado, imprime, quant, data;
- var x = document.getElementsByClassName("sc-title-subtitle-action__sublabel");
- telefone = x[2].textContent.split("|");
- telefone = telefone[telefone.length-1];
- telefone = telefone.replace(/\ /g,'')
- if(isNaN(telefone))
- {
- telefone = 0;
- }
- x = document.getElementsByClassName("sc-title-subtitle-action__label");
- nomeCliente = x[1].textContent.split("|");
- nomeCliente = nomeCliente[0];
- nomeProduto = x[2].textContent;
- x = document.getElementsByClassName("sc-quantity");
- quant = x[0].textContent;
- nomeProduto = quant + "+" + nomeProduto;
- x = document.getElementsByClassName("sc-account-title__text");
- data = x[1].textContent.split("|");
- data = data[1].split(" ");
- conteudo = data[3];
- if (conteudo=="Janeiro")
- {
- conteudo="01";
- }
- else if (conteudo=="Fevereiro")
- {
- conteudo='02';
- }
- else if (conteudo=="Março")
- {
- conteudo='03';
- }
- else if (conteudo=="Abril")
- {
- conteudo='04';
- }
- else if (conteudo=="Maio")
- {
- conteudo='05';
- }
- else if (conteudo=="Junho")
- {
- conteudo='06';
- }
- else if (conteudo=="Julho")
- {
- conteudo='07';
- }
- else if (conteudo=="Agosto")
- {
- conteudo='08';
- }
- else if (conteudo=="Setembro")
- {
- conteudo='09';
- }
- else if (conteudo=="Outubro")
- {
- conteudo='10';
- }
- else if (conteudo=="Novembro")
- {
- conteudo='11';
- }
- else if (conteudo=="Dezembro")
- {
- conteudo='12';
- }
- data = data[1] + "/" + conteudo + "/2019";
- x = document.getElementsByClassName("sc-title-subtitle-action__sublabel");
- codmercado = x[0].textContent.split("|");
- codmercado = codmercado[0].split("#");
- codmercado = codmercado[1].trimRight();
- imprime = "http://mercadoflow.ml/cadastrar_usuario?nome_produto=" + nomeProduto + "&data_compra=" + data + "&cliente=" +
- nomeCliente + "&telefone=" +telefone + "&id_compra=" + codmercado;
- //alert(imprime.replace(/\ /g,'+'));
- x = document.getElementsByClassName("sc-title-subtitle-action__label");
- x[0].innerHTML = x[0].textContent + '<a href="' + imprime + '" target="_blank"><button name="button" class = "andes-button andes-button--filled sc-action-button andes-button--small">Copiar Informações</button></a>';
- x = document.getElementsByClassName("sc-account-title__text");
- x[0].innerHTML = x[0].textContent + '<a href="' + imprime + '" target="_blank"><button name="button" class = "andes-button andes-button--filled sc-action-button andes-button--small">Copiar Informações</button></a>';
- function comentario()
- {
- var ajax = new XMLHttpRequest();
- // Seta tipo de requisição: Post e a URL da API
- ajax.open("POST", "https://www.mercadolivre.com.br/vendas/"+codmercado+"/detalhe/api/detail/add-note", true);
- ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- // Seta paramêtros da requisição e envia a requisição
- ajax.send('view"="detail";"rowId"=' + codmercado + ';"content"={"note":"teste"}');
- // Cria um evento para receber o retorno.
- ajax.onreadystatechange = function() {
- // Caso o state seja 4 e o http.status for 200, é porque a requisiçõe deu certo.
- if (ajax.readyState == 4 && ajax.status == 200) {
- var data = ajax.responseText;
- // Retorno do Ajax
- console.log(data);
- }
- }
- }
- /*imprime = '<script>var ajax = new XMLHttpRequest();' +
- 'ajax.open("POST", "https://www.mercadolivre.com.br/vendas/"+codmercado+"/detalhe/api/detail/add-note", true);' +
- 'ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");' +
- 'ajax.onreadystatechange = function() {' +
- 'if (ajax.readyState == 4 && ajax.status == 200) {' +
- 'var data = \'{content: {note: "TEXTO"}: rowId: codmercado, view: "detail"}\';'+
- "alert(data);" +
- "console.log(data);"+
- "}else{alert('erro');}"+
- "}</script>";
- alert(imprime);
- x = document.getElementsByClassName("nav-footer-secondaryinfo");
- x[0].innerHTML = x[0].textContent + "imprime" + imprime;
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement