NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name AutoLoginGestaoNumerarioProsegurScript // @namespace http://tampermonkey.net/ // @version 0.2 // @description Realiza o login automatico apos o primeiro login manual na solucao de gestao de numerario da Prosegur. // @author Caique Pimenta // @match https://web2.miprosegur.com/corpointweb/* // @grant none // @require http://cdn.jsdelivr.net/jquery/2.1.3/jquery.min.js // ==/UserScript== //debugger; (function ($, undefined) { $(function () { 'use strict'; if ((window.location.href == "https://web2.miprosegur.com/corpointweb/cl/login.mvc") || (window.location.href == "https://web2.miprosegur.com/corpointweb/cl/login.mvc?msg=logout") || (window.location.href == "https://web2.miprosegur.com/corpointweb/") || (window.location.href == "https://web2.miprosegur.com/corpointweb/cl/login.mvc?msg=sessionTimeout")) { if ($("span:contains('Erro')").length > 0) { eraseCookie("userName"); eraseCookie("userPWD"); return; } if (document.forms.namedItem("ext-gen7")) { if (document.forms.namedItem("ext-gen7").elements.namedItem("userName") && document.forms.namedItem("ext-gen7").elements.namedItem("userPWD")) { if (readCookie("userName") !== null) { document.forms.namedItem("ext-gen7").elements.namedItem("userName").value = readCookie("userName"); document.forms.namedItem("ext-gen7").elements.namedItem("userPWD").value = readCookie("userPWD"); document.forms.namedItem("ext-gen7").submit(); } else { var buttons = document.getElementsByClassName("x-btn-text"); for (var i = 0; i < buttons.length; i++) { buttons[i].addEventListener("click", function (ev) { createCookie("userName", document.forms.namedItem("ext-gen7").elements.namedItem("userName").value, 10000); createCookie("userPWD", document.forms.namedItem("ext-gen7").elements.namedItem("userPWD").value, 10000); }); } } } } } } ); //Author: Aurelio De Rosa, https://www.sitepoint.com/how-to-deal-with-cookies-in-javascript/ function createCookie(name, value, days) { var expires = ""; if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); expires = "; expires=" + date.toGMTString(); } document.cookie = name + "=" + value + expires + "; path=/"; } //Author: Aurelio De Rosa, https://www.sitepoint.com/how-to-deal-with-cookies-in-javascript/ function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length); } return null; } //Author: Aurelio De Rosa, https://www.sitepoint.com/how-to-deal-with-cookies-in-javascript/ function eraseCookie(name) { createCookie(name, "", -1); } })(window.jQuery.noConflict(true));