RD STATION - Form Validation - Organization

Form Validation dor RD STATION

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// @match SISTEL
// @match Sistel
// @match sistel
// @match RD STATION
// @match RDSTATION
// @name RDSTATION
// @namespace crm.rdsation.com
// @description SISTEL - RD STATION validation form for Create and Edit Organiaztion
// @require
// @license      Sistel
// ==UserScript==
// @name        RD STATION - Form Validation - Organization
// @author      Vinicius Branco
// @namespace   Vinicius Branco
// @version     1.2
// @copyright   Copyright 2024 SISTEL - Vinicius Branco
// @license     BSD-3-Clause
// @description Form Validation dor RD STATION
// @include     http*://crm.rdstation.com/*
// ==/UserScript==

!function(){"use strict";var e=!1;function t(t){const l=window.location.href;var n=2;l.includes("crm.rdstation.com/app/deals/")&&(n=1);var v=document.querySelectorAll('[id="6435aecc7c08100017448f98"]'),s=1;v.forEach((function(l){if(s===n&&"input"===l.tagName.toLowerCase()&&"text"===l.type&&(null===l.value||""===l.value||0===l.value.trim().length))return console.log("Preencher Razao Social"),alert("Preencher Razao Social"),l.style.backgroundColor="#FF7F50",e=!0,t.preventDefault(),!1;s+=1}));var p=document.querySelectorAll('[id="6419f0dd2f532800162b807d"]');s=1,p.forEach((function(l){if(s===n&&"input"===l.tagName.toLowerCase()&&"text"===l.type){if(null===l.value||""===l.value||0===l.value.trim().length)return alert("Preencher CNPJ ou CPF"),e=!0,t.preventDefault(),!1;{const r=d(l.value);if(!r)return alert("CPF ou CNPJ inválido."),l.style.backgroundColor="#FF7F50",e=!0,t.preventDefault(),!1;if("CPF"===r&&console.log("${tipo} válido."),"CPF"===r){o("6419f0dd2f532800162b807d");c("6419f0dd2f532800162b807d",i(l.value))}if("CNPJ"===r){o("6419f0dd2f532800162b807d");c("6419f0dd2f532800162b807d",f(l.value))}}}s+=1})),document.querySelectorAll('[id="6419f36a18bc6b000d009fb1"]').forEach((function(l){if(""===l.value)return alert("Campo Pessoa (Física, Jurídica) não foi selecionado."),e=!0,t.preventDefault(),!1})),document.querySelectorAll('[id="64df6cc91fb2ec001a75d1ca"]').forEach((function(l){if(""===l.value)return alert("Campo Tipo Cliente [A, B, C, D] não foi selecionado."),e=!0,t.preventDefault(),!1})),document.querySelectorAll('[id="6419ee058e63af000c05a9b6"]').forEach((function(l){if(""===l.value)return alert("Campo Fase [Lead, Cliente] não foi selecionado."),e=!0,t.preventDefault(),!1}));var g=document.querySelectorAll('[id="642f0dc2571ff9001a53ce11"]');s=1,g.forEach((function(l){if(s===n&&"input"===l.tagName.toLowerCase()&&"text"===l.type)if(null===l.value||""===l.value||0===l.value.trim().length)console.log("Preencher Email NF-E");else if(!a(l.value))return alert("Email '"+l.value+"' é inválido"),l.style.backgroundColor="#FF7F50",e=!0,t.preventDefault(),!1;s+=1}));var m=document.querySelectorAll('[id="6419f11df15e9a000c2bf1ce"]');s=1,m.forEach((function(l){if(s===n&&"input"===l.tagName.toLowerCase()&&"text"===l.type){if(null===l.value||""===l.value||0===l.value.trim().length)return console.log("Preencher Email"),!1;if(!a(l.value))return alert("Email '"+l.value+"' é inválido"),l.style.backgroundColor="#FF7F50",e=!0,t.preventDefault(),!1}s+=1}));var h=document.querySelectorAll('[id="6419f10216ac70001a45ccf1"]');s=1,h.forEach((function(l){if(s===n&&"input"===l.tagName.toLowerCase()&&"text"===l.type){if(null===l.value||""===l.value||0===l.value.trim().length)return alert("Preencher Telefone"),e=!0,t.preventDefault(),!1;if(!u(l.value))return alert("Telefone '"+l.value+"' é inválido"),l.style.backgroundColor="#FF7F50",e=!0,t.preventDefault(),!1}s+=1}));var F=document.querySelectorAll('[id="6419f26d8e63af001105bb5c"]');s=1,F.forEach((function(l){if(s===n&&"input"===l.tagName.toLowerCase()&&"text"===l.type){if(null===l.value||""===l.value||0===l.value.trim().length)return alert("Preencher Estado (UF)"),console.log("Estado (UF) não preenchido"),l.style.backgroundColor="#FF7F50",e=!0,t.preventDefault(),!1;if(!r(l.value))return alert("Estado '"+l.value+"' é inválido"),l.style.backgroundColor="#FF7F50",e=!0,t.preventDefault(),!1;l.value}s+=1}));var C=document.querySelectorAll('[id="642f0d737267220017c9f866"]');return s=1,C.forEach((function(l){if(s===n&&"input"===l.tagName.toLowerCase()&&"text"===l.type){if(null===l.value||""===l.value||0===l.value.trim().length)return alert("Preencher Inscrição Estadual"),console.log("Incrição Estadual não preenchido"),l.style.backgroundColor="#FF7F50",t.preventDefault(),e=!0,!1;var r=l.value.replace(/[^\d]/g,"");if(r.length<8&&r.length>14&&"Isento"!==r)return alert("Inscrição Estadual  '"+l.value+"' é inválido"),l.style.backgroundColor="#FF7F50",e=!0,t.preventDefault(),!1}s+=1})),e&&(t.preventDefault(),e=!1),!1}function l(t){var l=document.querySelectorAll('[id="6435aecc7c08100017448f98"]'),n=1;l.forEach((function(l){if(1===n&&"input"===l.tagName.toLowerCase()&&"text"===l.type&&(null===l.value||""===l.value||0===l.value.trim().length))return alert("Preencher Razao Social"),console.log("Razão Social não preenchido"),l.style.backgroundColor="#FF7F50",e=!0,t.preventDefault(),!1;n+=1}));var v=document.querySelectorAll('[id="6419f0dd2f532800162b807d"]');n=1,v.forEach((function(l){if(1===n&&"input"===l.tagName.toLowerCase()&&"text"===l.type){if(null===l.value||""===l.value||0===l.value.trim().length)return alert("Preencher CNPJ ou CPF"),l.style.backgroundColor="#FF7F50",e=!0,t.preventDefault(),!1;{const r=d(l.value);if(!r)return alert("CPF ou CNPJ inválido."),l.style.backgroundColor="#FF7F50",e=!0,t.preventDefault(),!1;if("CPF"===r&&console.log("${tipo} válido."),"CPF"===r){o("6419f0dd2f532800162b807d");c("6419f0dd2f532800162b807d",i(l.value))}if("CNPJ"===r){o("6419f0dd2f532800162b807d");c("6419f0dd2f532800162b807d",f(l.value))}}}n+=1})),document.querySelectorAll('[id="6419f36a18bc6b000d009fb1"]').forEach((function(l){if(""===l.value)return alert("Campo Pessoa (Física, Jurídica) não foi selecionado."),e=!0,t.preventDefault(),!1})),document.querySelectorAll('[id="64df6cc91fb2ec001a75d1ca"]').forEach((function(l){if(""===l.value)return alert("Campo Tipo Cliente [A, B, C, D] não foi selecionado."),e=!0,t.preventDefault(),!1})),document.querySelectorAll('[id="6419ee058e63af000c05a9b6"]').forEach((function(l){if(""===l.value)return alert("Campo Fase [Lead, Cliente] não foi selecionado."),e=!0,t.preventDefault(),!1}));var s=document.querySelectorAll('[id="642f0dc2571ff9001a53ce11"]');n=1,s.forEach((function(l){if(1===n&&"input"===l.tagName.toLowerCase()&&"text"===l.type)if(null===l.value||""===l.value||0===l.value.trim().length)console.log("Preencher Email NF-E");else if(!a(l.value))return alert("Email '"+l.value+"' é inválido"),l.style.backgroundColor="#FF7F50",e=!0,t.preventDefault(),!1;n+=1}));var p=document.querySelectorAll('[id="6419f11df15e9a000c2bf1ce"]');n=1,p.forEach((function(l){if(1===n&&"input"===l.tagName.toLowerCase()&&"text"===l.type)if(null===l.value||""===l.value||0===l.value.trim().length)console.log("Preencher Email"),alert("Preencher Email");else if(!a(l.value))return alert("Email '"+l.value+"' é inválido"),l.style.backgroundColor="#FF7F50",e=!0,t.preventDefault(),!1;n+=1}));var g=document.querySelectorAll('[id="6419f10216ac70001a45ccf1"]');n=1,g.forEach((function(l){if(1===n&&"input"===l.tagName.toLowerCase()&&"text"===l.type){if(null===l.value||""===l.value||0===l.value.trim().length)return alert("Preencher Telefone"),e=!0,t.preventDefault(),!1;if(!u(l.value))return alert("Telefone '"+l.value+"' é inválido"),e=!0,t.preventDefault(),!1}n+=1}));var m=document.querySelectorAll('[id="6419f26d8e63af001105bb5c"]');n=1,m.forEach((function(l){if(1===n&&"input"===l.tagName.toLowerCase()&&"text"===l.type){if(null===l.value||""===l.value||0===l.value.trim().length)return alert("Preencher Estado (UF)"),console.log("Estado (UF) não preenchido"),l.style.backgroundColor="#FF7F50",e=!0,t.preventDefault(),!1;if(!r(l.value))return alert("Estado '"+l.value+"' é inválido"),l.style.backgroundColor="#FF7F50",e=!0,t.preventDefault(),!1;l.value}n+=1}));var h=document.querySelectorAll('[id="642f0d737267220017c9f866"]');return n=1,h.forEach((function(l){if(1===n&&"input"===l.tagName.toLowerCase()&&"text"===l.type){if(null===l.value||""===l.value||0===l.value.trim().length)return console.log("Inscrição Estadual não preenchida"),l.style.backgroundColor="#FF7F50",t.preventDefault(),e=!0,!1;var r=l.value.replace(/[^\d]/g,"");if(r.length<8&&r.length>14&&"Isento"!==r)return alert("Inscrição Estadual  '"+l.value+"' é inválido"),l.style.backgroundColor="#FF7F50",e=!0,t.preventDefault(),!1}n+=1})),console.log(e),e&&(t.preventDefault(),e=!1),!1}function r(e){return["AC","AL","AP","AM","BA","CE","DF","ES","GO","MA","MT","MS","MG","PA","PB","PR","PE","PI","RJ","RN","RS","RO","RR","SC","SP","SE","TO"].includes(e.toUpperCase())}function a(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function n(){for(var e=document.getElementsByClassName("ButtonBase__Root-sc-1nywgwg-0 eZvGpo Button__Root-sc-rktc57-0 mWaHm undefined button-group__child"),l=0;l<e.length;l++)e[l].innerHTML.includes("Criar Empresa")&&e[l].addEventListener("click",t)}function o(e){const t=document.querySelectorAll("label");for(const l of t)if(l.textContent.trim()===e)return l.getAttribute("for");return null}function u(e){var t=/^\(?\d{2}\)?[\s-]?\d{4,5}-?\d{4}$/.test(e),l=e.replace(/\D/g,"");return t&&("1430115757"===l&&(t=!1),t&&/^(\d)\1*$/.test(e)&&(t=!1)),t}function c(e,t){document.querySelectorAll('[id="'+e+'"]').forEach((function(e){if("input"===e.tagName.toLowerCase()&&"text"===e.type){e.select(),e.setAttribute("value",""),e.value="",e.defaultValue="",e.setAttribute("value",""),e.value=t,e.defaultValue=t,e.setAttribute("value",t),e.innerHTML=t,e.style.display="block",e.style.backgroundColor="#E6FFC7";var l=new Event("input",{bubbles:!0});e.dispatchEvent(l)}}))}function i(e){return e.replace(/^(\d{3})(\d{3})(\d{3})(\d{2})$/,"$1.$2.$3-$4")}function f(e){return(e=e.replace(/\D/g,"")).replace(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/,"$1.$2.$3/$4-$5")}function d(e){return 11===(e=e.replace(/\D/g,"")).length?!!function(e){if(e=e.replace(/[\.-]/g,""),/^(\d)\1*$/.test(e))return!1;let t=0;for(let l=0;l<9;l++)t+=parseInt(e.charAt(l))*(10-l);let l=11-t%11,r=10===l||11===l?0:l;if(parseInt(e.charAt(9))!==r)return!1;t=0;for(let l=0;l<10;l++)t+=parseInt(e.charAt(l))*(11-l);return l=11-t%11,r=10===l||11===l?0:l,parseInt(e.charAt(10))===r}(e)&&"CPF":14===e.length&&(!!function(e){if(e=e.replace(/[\.-]/g,"").trim(),/^(\d)\1*$/.test(e))return!1;var t=0,l=2;for(let r=11;r>=0;r--)t+=parseInt(e.charAt(r))*l,l=9===l?2:l+1;var r=t%11,a=r<2?0:11-r;if(parseInt(e.charAt(12))!==a)return!1;t=0,l=2;for(let r=12;r>=0;r--)t+=parseInt(e.charAt(r))*l,l=9===l?2:l+1;return a=(r=t%11)<2?0:11-r,parseInt(e.charAt(13))===a}(e)&&"CNPJ")}new MutationObserver((function(e){e.forEach((function(e){n(),function(){for(var e=document.getElementsByClassName("ButtonBase__Root-sc-1nywgwg-0 eZvGpo Button__Root-sc-rktc57-0 mWaHm undefined button-group__child"),t=0;t<e.length;t++)e[t].innerHTML.includes("Criar Negociação")&&e[t].addEventListener("click",l)}()}))})).observe(document.body,{childList:!0,subtree:!0}),n()}();