Añade un botón para copiar el texto del incidente en mayúsculas
Size
2.5 KB
Version
1.1.3
Created
Dec 23, 2025
Updated
about 1 month ago
1// ==UserScript==
2// @name Copiar Incidente en Mayúsculas
3// @description Añade un botón para copiar el texto del incidente en mayúsculas
4// @version 1.1.3
5// @match https://*.intranet.ejuniper.com/*
6// @icon https://intranet.ejuniper.com/images/favicon.ico
7// ==/UserScript==
8(function() {
9 'use strict';
10
11 function init() {
12 // Buscar el textarea del incidente
13 const incidenteTextarea = document.querySelector('textarea#TemaIncidencia[name="TemaIncidencia"]');
14
15 if (!incidenteTextarea) {
16 console.log('No se encontró el campo de incidente');
17 return;
18 }
19
20 console.log('Campo de incidente encontrado');
21
22 // Crear el botón
23 const copyButton = document.createElement('button');
24 copyButton.textContent = 'Incidencia';
25 copyButton.className = 'ButtonOnPage';
26 copyButton.style.cssText = 'margin-left: 10px; padding: 5px 10px; cursor: pointer; background-color: #007bff; color: white; border: 1px solid #0056b3; border-radius: 3px;';
27
28 // Añadir evento de click
29 copyButton.addEventListener('click', async function(e) {
30 e.preventDefault();
31
32 const textoIncidente = incidenteTextarea.value;
33 const textoMayusculas = textoIncidente.toUpperCase();
34
35 try {
36 await GM.setClipboard(textoMayusculas);
37 // Feedback visual
38 const originalText = copyButton.textContent;
39 copyButton.textContent = '✓ Copiado!';
40 copyButton.style.backgroundColor = '#28a745';
41
42 setTimeout(() => {
43 copyButton.textContent = originalText;
44 copyButton.style.backgroundColor = '#007bff';
45 }, 2000);
46 } catch (error) {
47 copyButton.textContent = '✗ Error';
48 copyButton.style.backgroundColor = '#dc3545';
49
50 setTimeout(() => {
51 copyButton.textContent = 'Incidencia';
52 copyButton.style.backgroundColor = '#007bff';
53 }, 2000);
54 }
55 });
56
57 // Insertar el botón después del textarea
58 incidenteTextarea.parentNode.insertBefore(copyButton, incidenteTextarea.nextSibling);
59
60 }
61
62 // Esperar a que el DOM esté listo
63 if (document.readyState === 'loading') {
64 document.addEventListener('DOMContentLoaded', init);
65 } else {
66 init();
67 }
68})();