Actualizar robot.js
This commit is contained in:
16
robot.js
16
robot.js
@@ -222,6 +222,19 @@ async function runMultiasistencia(ownerId, user, pass, gremiosDB) {
|
||||
const cpOnly = cpMatch ? cpMatch[0] : "";
|
||||
const popOnly = rawCPField.replace(cpOnly, '').replace('-', '').trim();
|
||||
|
||||
// 📞 EXTRAER TELÉFONO REAL (Evita coger el de la oficina)
|
||||
let telefonoReal = "";
|
||||
const titulosDiv = Array.from(document.querySelectorAll('.subtitulo'));
|
||||
const divTelefono = titulosDiv.find(div => div.innerText && div.innerText.includes('Teléfono'));
|
||||
if (divTelefono && divTelefono.nextElementSibling) {
|
||||
const celdaNum = divTelefono.nextElementSibling.querySelector('.tdet');
|
||||
if (celdaNum) telefonoReal = celdaNum.innerText.replace(/[^0-9]/g, '');
|
||||
}
|
||||
// Fallback por si acaso falla, usamos el que tenías antes
|
||||
if (!telefonoReal || telefonoReal.length < 9) {
|
||||
telefonoReal = (document.body.innerText.match(/[6789]\d{8}/) || [])[0] || "";
|
||||
}
|
||||
|
||||
return {
|
||||
"Expediente": findByCab("Número Reparación") || "",
|
||||
"Nombre Cliente": findByCab("Nombre Cliente") || "",
|
||||
@@ -230,7 +243,8 @@ async function runMultiasistencia(ownerId, user, pass, gremiosDB) {
|
||||
"Código Postal": cpOnly,
|
||||
"Compañía": "MULTI - " + (findByCab("Procedencia") || "MULTIASISTENCIA"),
|
||||
"Descripción": cleanDesc,
|
||||
"Teléfono": (document.body.innerText.match(/[6789]\d{8}/) || [])[0] || "",
|
||||
"Teléfono": telefonoReal,
|
||||
"Estado": findByCab("Estado") || "", // 🛑 AÑADIDO EL ESTADO AQUÍ
|
||||
"Urgente": findByCab("Urgente") || "No"
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user