Advertisement
Guest User

TESTE.js

a guest
Jun 16th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. // ==UserScript==
  2. // @name mercadoflow 17/06/2019
  3. // @version 1
  4. // @grant none
  5. // ==/UserScript==
  6. var url_atual = window.location.href;
  7. url_atual = url_atual.substring(8, 39);
  8. if(url_atual=="www.mercadolivre.com.br/vendas/")
  9. {
  10.  
  11. var telefone, nomeCliente, nomeProduto, conteudo, codmercado, imprime, quant, data;
  12.  
  13. var x = document.getElementsByClassName("sc-title-subtitle-action__sublabel");
  14. telefone = x[2].textContent.split("|");
  15. telefone = telefone[telefone.length-1];
  16. telefone = telefone.replace(/\ /g,'')
  17.  
  18. if(isNaN(telefone))
  19. {
  20. telefone = 0;
  21. }
  22.  
  23. x = document.getElementsByClassName("sc-title-subtitle-action__label");
  24. nomeCliente = x[1].textContent.split("|");
  25. nomeCliente = nomeCliente[0];
  26. nomeProduto = x[2].textContent;
  27.  
  28.  
  29. x = document.getElementsByClassName("sc-quantity");
  30. quant = x[0].textContent;
  31. nomeProduto = quant + "+" + nomeProduto;
  32.  
  33. x = document.getElementsByClassName("sc-account-title__text");
  34. data = x[1].textContent.split("|");
  35. data = data[1].split(" ");
  36.  
  37.  
  38. conteudo = data[3];
  39.  
  40.  
  41. if (conteudo=="Janeiro")
  42. {
  43. conteudo="01";
  44. }
  45. else if (conteudo=="Fevereiro")
  46. {
  47. conteudo='02';
  48. }
  49. else if (conteudo=="Março")
  50. {
  51. conteudo='03';
  52. }
  53. else if (conteudo=="Abril")
  54. {
  55. conteudo='04';
  56. }
  57. else if (conteudo=="Maio")
  58. {
  59. conteudo='05';
  60. }
  61. else if (conteudo=="Junho")
  62. {
  63. conteudo='06';
  64. }
  65. else if (conteudo=="Julho")
  66. {
  67. conteudo='07';
  68. }
  69. else if (conteudo=="Agosto")
  70. {
  71. conteudo='08';
  72. }
  73. else if (conteudo=="Setembro")
  74. {
  75. conteudo='09';
  76. }
  77. else if (conteudo=="Outubro")
  78. {
  79. conteudo='10';
  80. }
  81. else if (conteudo=="Novembro")
  82. {
  83. conteudo='11';
  84. }
  85. else if (conteudo=="Dezembro")
  86. {
  87. conteudo='12';
  88. }
  89.  
  90. data = data[1] + "/" + conteudo + "/2019";
  91.  
  92. x = document.getElementsByClassName("sc-title-subtitle-action__sublabel");
  93. codmercado = x[0].textContent.split("|");
  94. codmercado = codmercado[0].split("#");
  95. codmercado = codmercado[1].trimRight();
  96.  
  97. imprime = "http://mercadoflow.ml/cadastrar_usuario?nome_produto=" + nomeProduto + "&data_compra=" + data + "&cliente=" +
  98. nomeCliente + "&telefone=" +telefone + "&id_compra=" + codmercado;
  99. //alert(imprime.replace(/\ /g,'+'));
  100.  
  101. x = document.getElementsByClassName("sc-title-subtitle-action__label");
  102. 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>';
  103.  
  104.  
  105. x = document.getElementsByClassName("sc-account-title__text");
  106. 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>';
  107.  
  108.  
  109. function comentario()
  110. {
  111.  
  112. var ajax = new XMLHttpRequest();
  113.  
  114.  
  115. // Seta tipo de requisição: Post e a URL da API
  116.  
  117. ajax.open("POST", "https://www.mercadolivre.com.br/vendas/"+codmercado+"/detalhe/api/detail/add-note", true);
  118.  
  119. ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  120.  
  121.  
  122. // Seta paramêtros da requisição e envia a requisição
  123.  
  124. ajax.send('view"="detail";"rowId"=' + codmercado + ';"content"={"note":"teste"}');
  125.  
  126.  
  127. // Cria um evento para receber o retorno.
  128.  
  129. ajax.onreadystatechange = function() {
  130.  
  131.  
  132.  
  133. // Caso o state seja 4 e o http.status for 200, é porque a requisiçõe deu certo.
  134.  
  135. if (ajax.readyState == 4 && ajax.status == 200) {
  136.  
  137.  
  138.  
  139. var data = ajax.responseText;
  140.  
  141.  
  142. // Retorno do Ajax
  143.  
  144. console.log(data);
  145.  
  146. }
  147.  
  148. }
  149. }
  150. /*imprime = '<script>var ajax = new XMLHttpRequest();' +
  151. 'ajax.open("POST", "https://www.mercadolivre.com.br/vendas/"+codmercado+"/detalhe/api/detail/add-note", true);' +
  152. 'ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");' +
  153. 'ajax.onreadystatechange = function() {' +
  154. 'if (ajax.readyState == 4 && ajax.status == 200) {' +
  155. 'var data = \'{content: {note: "TEXTO"}: rowId: codmercado, view: "detail"}\';'+
  156. "alert(data);" +
  157. "console.log(data);"+
  158. "}else{alert('erro');}"+
  159. "}</script>";
  160. alert(imprime);
  161. x = document.getElementsByClassName("nav-footer-secondaryinfo");
  162. x[0].innerHTML = x[0].textContent + "imprime" + imprime;
  163. */
  164.  
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement