Download src/x/auto_extractor.js from codebydante/detector-de-enlaces-copia: direct link, hf CLI and curl.
- Browser
- Download file 7.5 kB
-
https://huggingface.co/datasets/codebydante/detector-de-enlaces-copia/resolve/main/src/x/auto_extractor.js
- Command line
-
hf download hf://datasets/codebydante/detector-de-enlaces-copia/src/x/auto_extractor.js
-
curl -L -o auto_extractor.js https://huggingface.co/datasets/codebydante/detector-de-enlaces-copia/resolve/main/src/x/auto_extractor.js
7.5 kB
| (() => { | |
| if (window.__xExtractorActive) return; | |
| window.__xExtractorActive = true; | |
| const collectedVideos = new Map(); // url -> { url, title, thumb } | |
| const container = document.createElement('div'); | |
| container.id = 'x-extractor-ui'; | |
| container.style.cssText = ` | |
| position: fixed; | |
| bottom: 20px; | |
| right: 20px; | |
| background: #000; | |
| color: #fff; | |
| padding: 15px; | |
| border-radius: 10px; | |
| border: 1px solid #333; | |
| z-index: 999999; | |
| font-family: sans-serif; | |
| box-shadow: 0 4px 12px rgba(255,255,255,0.2); | |
| display: flex; | |
| flex-direction: column; | |
| gap: 10px; | |
| min-width: 250px; | |
| `; | |
| const titleDisplay = document.createElement('div'); | |
| titleDisplay.innerHTML = '<b>Extractor de Videos X</b>'; | |
| titleDisplay.style.textAlign = 'center'; | |
| titleDisplay.style.fontSize = '15px'; | |
| const countDisplay = document.createElement('div'); | |
| countDisplay.textContent = '0 videos encontrados'; | |
| countDisplay.style.fontWeight = 'bold'; | |
| countDisplay.style.textAlign = 'center'; | |
| countDisplay.style.fontSize = '18px'; | |
| countDisplay.style.color = '#1da1f2'; | |
| const statusDisplay = document.createElement('div'); | |
| statusDisplay.textContent = 'Listo para escanear.'; | |
| statusDisplay.style.textAlign = 'center'; | |
| statusDisplay.style.fontSize = '12px'; | |
| statusDisplay.style.color = '#888'; | |
| const autoScanBtn = document.createElement('button'); | |
| autoScanBtn.textContent = 'Iniciar Búsqueda Automática (Scroll)'; | |
| autoScanBtn.style.cssText = ` | |
| background: #1da1f2; | |
| color: white; | |
| border: none; | |
| padding: 10px; | |
| border-radius: 6px; | |
| cursor: pointer; | |
| font-weight: bold; | |
| `; | |
| const copyBtn = document.createElement('button'); | |
| copyBtn.textContent = 'Copiar Enlaces'; | |
| copyBtn.style.cssText = ` | |
| background: #8b5cf6; | |
| color: white; | |
| border: none; | |
| padding: 10px; | |
| border-radius: 6px; | |
| cursor: pointer; | |
| font-weight: bold; | |
| `; | |
| const closeBtn = document.createElement('button'); | |
| closeBtn.id = 'x-close-btn'; | |
| closeBtn.textContent = 'Cerrar Extractor'; | |
| closeBtn.style.cssText = ` | |
| background: #27272a; | |
| color: white; | |
| border: 1px solid #3f3f46; | |
| padding: 8px; | |
| border-radius: 6px; | |
| cursor: pointer; | |
| font-size: 13px; | |
| `; | |
| container.appendChild(titleDisplay); | |
| container.appendChild(countDisplay); | |
| container.appendChild(statusDisplay); | |
| container.appendChild(autoScanBtn); | |
| container.appendChild(copyBtn); | |
| container.appendChild(closeBtn); | |
| document.body.appendChild(container); | |
| let scanInterval = null; | |
| let isScanning = false; | |
| let maxRetries = 10; // Aumentar reintentos antes de rendirse | |
| autoScanBtn.onclick = () => { | |
| if (isScanning) { | |
| clearInterval(scanInterval); | |
| isScanning = false; | |
| autoScanBtn.textContent = 'Continuar Búsqueda'; | |
| autoScanBtn.style.background = '#1da1f2'; | |
| statusDisplay.textContent = 'Búsqueda pausada.'; | |
| return; | |
| } | |
| isScanning = true; | |
| autoScanBtn.textContent = 'Detener Búsqueda'; | |
| autoScanBtn.style.background = '#e0245e'; | |
| statusDisplay.textContent = 'Haciendo scroll y buscando videos...'; | |
| let lastHeight = 0; | |
| let retries = 0; | |
| scanInterval = setInterval(() => { | |
| // Scroll progresivo en lugar de ir directo al fondo para no atascar React | |
| window.scrollBy(0, 1000); | |
| // Buscar enlaces a videos o tweets que parezcan videos | |
| const links = document.querySelectorAll('a[href*="/status/"]'); | |
| links.forEach(a => { | |
| let cleanUrl = a.href.split('?')[0]; | |
| // Es un video si tiene /video/ en la URL, o si tiene un div indicando duración (ej. "4:13") | |
| let isVideo = cleanUrl.includes('/video/'); | |
| if (!isVideo && a.innerText && /^\d+:\d+$/.test(a.innerText.trim())) { | |
| isVideo = true; | |
| } | |
| // Si el link de la cuadricula no termina en /video/1, se lo agregamos si estamos seguros que es video | |
| if (isVideo && !cleanUrl.includes('/video/')) { | |
| if (!cleanUrl.endsWith('/')) cleanUrl += '/'; | |
| cleanUrl += 'video/1'; | |
| } | |
| if (isVideo && !collectedVideos.has(cleanUrl)) { | |
| collectedVideos.set(cleanUrl, true); | |
| // Feedback visual (borde verde y opacidad) | |
| a.style.outline = '4px solid #10b981'; | |
| a.style.opacity = '0.8'; | |
| a.style.position = 'relative'; | |
| // Agregar marca de verificación visual si no la tiene | |
| if (!a.querySelector('.x-check-mark')) { | |
| const check = document.createElement('div'); | |
| check.className = 'x-check-mark'; | |
| check.innerHTML = '✓'; | |
| check.style.cssText = 'position:absolute; top:10px; right:10px; background:#10b981; color:white; border-radius:50%; width:30px; height:30px; display:flex; align-items:center; justify-content:center; font-weight:bold; font-size:16px; z-index:20; box-shadow:0 2px 5px rgba(0,0,0,0.5);'; | |
| a.appendChild(check); | |
| } | |
| } | |
| }); | |
| countDisplay.textContent = collectedVideos.size + ' videos encontrados'; | |
| let currentScroll = window.scrollY || document.documentElement.scrollTop; | |
| if (currentScroll === lastHeight) { | |
| retries++; | |
| // Darle un pequeño empujón hacia arriba y abajo por si se atascó | |
| if (retries === 3) window.scrollBy(0, -500); | |
| if (retries === 4) window.scrollBy(0, 800); | |
| if (retries >= maxRetries) { | |
| clearInterval(scanInterval); | |
| isScanning = false; | |
| autoScanBtn.textContent = 'Búsqueda finalizada'; | |
| autoScanBtn.style.background = '#1da1f2'; | |
| autoScanBtn.disabled = true; | |
| statusDisplay.textContent = 'Llegaste al final de la página.'; | |
| } | |
| } else { | |
| retries = 0; | |
| } | |
| lastHeight = currentScroll; | |
| }, 1000); | |
| }; | |
| copyBtn.onclick = () => { | |
| if (collectedVideos.size === 0) return; | |
| const urls = Array.from(collectedVideos.keys()); | |
| const text = urls.join('\n'); | |
| navigator.clipboard.writeText(text).then(() => { | |
| const ogText = copyBtn.textContent; | |
| copyBtn.textContent = '¡Copiados!'; | |
| copyBtn.style.background = '#10b981'; | |
| setTimeout(() => { | |
| copyBtn.textContent = ogText; | |
| copyBtn.style.background = '#8b5cf6'; | |
| }, 2000); | |
| }); | |
| }; | |
| closeBtn.onclick = () => { | |
| if (scanInterval) clearInterval(scanInterval); | |
| isScanning = false; | |
| container.remove(); | |
| window.__xExtractorActive = false; | |
| }; | |
| })(); | |