1doc

mod 1doc!

当前为 2021-08-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name 1doc
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4
  5. // @description mod 1doc!
  6. // @author Dione
  7. // @match https://rolandia.1doc.com.br/?pg=doc/*
  8. // @match https://rolandia.1doc.com.br/?pg=painel/*
  9. // @require https://cdnjs.cloudflare.com/ajax/libs/PapaParse/4.3.3/papaparse.min.js
  10. // @resource csv https://drive.google.com/uc?export=download&id=1CcJqb-Fk-AG4iN46oNrGtDWk0ECmN0Q5
  11. // @grant GM_getResourceURL
  12. // ==/UserScript==
  13.  
  14. // contats alt. com wp https://drive.google.com/uc?export=download&id=1WLdEKU5roDkJN_KGaJUKsu-6-0t_nJbj
  15. //identificador nome email email2 cpf_cnpj funcao data_nasc telefone telefone2
  16.  
  17. (function() {
  18. 'use strict';
  19. var paginaAtual = window.location.href;
  20.  
  21. var divFixa = $(".tit:first")
  22. document.onscroll = function() {
  23. if (window.scrollY > 800) {
  24. divFixa.appendTo(".envolucro");
  25. } else {
  26. divFixa.appendTo(".div_em_titulo:first");
  27. }
  28. };
  29.  
  30. $(".link_voltar").css('top', '140px');
  31. if (paginaAtual.search(/pg=painel\/listar/g) > 1) {
  32. var btn86 = document.createElement('a');
  33. btn86.className = "btn btn_nav btn-mini";
  34. btn86.id = "btn86";
  35. btn86.onclick = verificaAssinaturas;
  36. btn86.innerHTML = "<i class='icon-fire'></i>"
  37. var ref = document.querySelectorAll('.navega_caixa_refresh')[0]
  38. ref.insertAdjacentElement('afterend', btn86)
  39. }else if(paginaAtual.search(/pg=doc\/ver/g) > 1){
  40. var elmAss;
  41. agrupaAssinaturas();
  42. setInterval(function() {
  43. if (paginaAtual != window.location.href) {
  44. paginaAtual = window.location.href
  45. if (paginaAtual.search(/pg=doc\/ver/g) > 1) {
  46. agrupaAssinaturas();
  47. } else {
  48. document.getElementById('ass86').remove();
  49. }
  50. }
  51. }, 500);
  52.  
  53. Papa.parse(GM_getResourceURL("csv"), {
  54. download: true,
  55. header: true,
  56. complete: function(results) {
  57. var divinfo = document.getElementsByClassName('media-heading-user-info');
  58. for (let index = 0; index < divinfo.length; index++) {
  59.  
  60. var nome = divinfo[index].firstElementChild.dataset.content
  61. var contato = results.data.find(function(contato) { return contato.nome == nome; })
  62. var pai = divinfo[index].parentNode.parentNode;
  63. //elmInfo.append("telefone:",contato.telefone2)
  64. var elmInfo = document.createElement("span");
  65. elmInfo.class = 'inf86';
  66. if(contato?.fone == undefined)continue
  67. elmInfo.append("Telefone:", contato?.fone)
  68. pai.append(elmInfo)
  69. }
  70. }
  71. });
  72. }
  73.  
  74. function verificaAssinaturas() {
  75. let obj = document.querySelectorAll('.link_emissao_a');
  76. for (let p of obj) {
  77. if(p.parentElement.parentElement.children[4].lastElementChild.nodeName == 'SMALL')continue
  78. let xhr = new XMLHttpRequest();
  79. xhr.open('GET', p.href);
  80. xhr.responseType = 'document';
  81. xhr.onload = function() {
  82. var local = p.parentElement.parentElement.lastElementChild.previousElementSibling;
  83. if (xhr.status == 200) {
  84. var assinados = xhr.response.querySelectorAll('.badge-success');
  85. var pendentes = xhr.response.querySelectorAll('.badge-warning');
  86. if (pendentes.length > 0) {
  87. local.innerHTML += "<span style='color: #f3581c'><b>" + `Assinaturas:${assinados.length}/${pendentes.length+assinados.length}` + "<b></span>";
  88. } else {
  89. local.innerHTML += "<span style='color: #1b901b'><b>" + `Assinaturas:${assinados.length}/${pendentes.length+assinados.length}` + "<b></span>";
  90. }
  91.  
  92. for (let n = 0; n < pendentes.length; n++) {
  93. local.innerHTML += "<br>" + pendentes[n].title.replace(" ainda", '');
  94. }
  95. } else {
  96. alert(`Error ${xhr.status}: ${xhr.statusText}`);
  97. }
  98. };
  99. xhr.onerror = function() {
  100. alert("Request failed");
  101. };
  102. xhr.send();
  103. }
  104. verificaAssinaturas = undefined
  105. }
  106.  
  107. function agrupaAssinaturas(t) {
  108. if(elmAss){return}
  109. elmAss = document.createElement("div");
  110. elmAss.id = 'ass86';
  111. var ook = document.getElementsByClassName('badge-success');
  112. var not = document.getElementsByClassName('badge-warning');
  113. var linha = [];
  114. document.body.append(elmAss);
  115.  
  116. not.forEach(function(val) {
  117. linha.push("<span class='badge badge_env badge-warning tt' data-placement='left'><i class='icon-certificate'></i> Pendente </span>");
  118. linha.push(val.dataset.originalTitle);
  119. });
  120. ook.forEach(function(val) {
  121. linha.push("<span class='badge badge_env badge-success tt' data-placement='left'><i class='icon-certificate'></i> Assinado</span>");
  122. linha.push(val.dataset.originalTitle);
  123. });
  124.  
  125. for (let li of linha) {
  126. elmAss.innerHTML += (li);
  127. }
  128.  
  129. elmAss.style.setProperty('font-weight', 'initial');
  130. elmAss.style.setProperty('font-size', '12px');
  131. elmAss.style.setProperty('display', 'flex');
  132. elmAss.style.setProperty('position', 'fixed');
  133. elmAss.style.setProperty('top', '240px');
  134. elmAss.style.setProperty('right', '70px');
  135. elmAss.style.setProperty('flex-direction', 'column');
  136.  
  137. };
  138.  
  139.  
  140.  
  141. })();