// ==UserScript== // @name Comunicados Inteligentes IDEMEFA // @namespace http://tampermonkey.net/ // @version 1.7 // @description Versión que se auto-elimina en impresiones y PDFs para no tapar contenido // @author Admin IDEMEFA // @match https://system.admcloud.net/* // @exclude *://system.admcloud.net/Reports/* // @exclude *://system.admcloud.net/Pdf/* // @grant GM_xmlhttpRequest // @connect gist.githubusercontent.com // @updateURL https://raw.githubusercontent.com/afemedi-cloud/scripts-idemefa/main/comunicados.user.js // @downloadURL https://raw.githubusercontent.com/afemedi-cloud/scripts-idemefa/main/comunicados.user.js // ==/UserScript== (function() { 'use strict'; // 1. Filtro de URL para evitar ejecución en páginas de documentos const path = window.location.pathname.toLowerCase(); const search = window.location.search.toLowerCase(); if (path.includes('report') || path.includes('pdf') || search.includes('print')) return; // Tu URL de Gist para los datos JSON const URL_GIST = "https://gist.githubusercontent.com/afemedi-cloud/614cf47c8f111eb2f64485ed90b903d0/raw/comunicados.json"; GM_xmlhttpRequest({ method: "GET", url: URL_GIST + "?t=" + new Date().getMinutes(), onload: function(response) { try { const data = JSON.parse(response.responseText); const hoy = new Date(); const dia = hoy.getDate(); const mes = hoy.getMonth() + 1; let msg = "", tipo = "info", activo = false; if (data.anuncio_especial?.activo) { msg = data.anuncio_especial.mensaje; tipo = data.anuncio_especial.estilo; activo = true; } else { const cumple = data.cumpleanios.find(c => c.mes === mes && c.dia === dia); if (cumple) { msg = `🎉 ¡Feliz Cumpleaños ${cumple.nombre}! Todo el equipo IDEMEFA te desea lo mejor. 🎂`; tipo = "celebracion"; activo = true; } } if (activo) { inyectarEstilosImpresion(); inyectarBanner(msg, tipo); } } catch(e) { console.error("IDEMEFA Error:", e); } } }); function inyectarEstilosImpresion() { const style = document.createElement('style'); style.innerHTML = ` @media print { #banner-idemefa-v15 { display: none !important; visibility: hidden !important; } body { padding-top: 0 !important; margin-top: 0 !important; } } `; document.head.appendChild(style); } function inyectarBanner(texto, tipo) { const colores = { celebracion: "linear-gradient(90deg, #8E2DE2, #4A00E0)", urgente: "linear-gradient(90deg, #cb2d3e, #ef473a)", info: "linear-gradient(90deg, #00c6ff, #0072ff)", exito: "linear-gradient(90deg, #11998e, #38ef7d)" }; const b = document.createElement('div'); b.id = "banner-idemefa-v15"; b.innerHTML = texto; Object.assign(b.style, { position: 'fixed', top: '0', left: '0', width: '100%', zIndex: '2147483647', background: colores[tipo] || colores.info, color: 'white', textAlign: 'center', padding: '12px 0', fontWeight: 'bold', fontSize: '15px', fontFamily: 'Segoe UI, sans-serif', boxShadow: '0 2px 10px rgba(0,0,0,0.3)', pointerEvents: 'none' }); document.documentElement.appendChild(b); document.body.style.paddingTop = "45px"; } })();