Download src/facebook/selector.js from codebydante/detector-de-enlaces-copia: direct link, hf CLI and curl.
- Browser
- Download file 11.4 kB
-
https://huggingface.co/datasets/codebydante/detector-de-enlaces-copia/resolve/main/src/facebook/selector.js
- Command line
-
hf download hf://datasets/codebydante/detector-de-enlaces-copia/src/facebook/selector.js
-
curl -L -o selector.js https://huggingface.co/datasets/codebydante/detector-de-enlaces-copia/resolve/main/src/facebook/selector.js
11.4 kB
| (() => { | |
| if (document.getElementById('fb-floating-ui')) return; | |
| window.__fbSelectorActive = true; | |
| const selectedLinks = new Set(); | |
| const container = document.createElement('div'); | |
| container.id = 'fb-floating-ui'; | |
| container.style.cssText = ` | |
| position: fixed; | |
| bottom: 20px; | |
| right: 20px; | |
| background: #18181b; | |
| color: #fff; | |
| padding: 15px; | |
| border-radius: 10px; | |
| border: 1px solid #27272a; | |
| z-index: 2147483647; | |
| font-family: sans-serif; | |
| box-shadow: 0 4px 12px rgba(0,0,0,0.5); | |
| display: flex; | |
| flex-direction: column; | |
| gap: 10px; | |
| min-width: 200px; | |
| `; | |
| const countDisplay = document.createElement('div'); | |
| countDisplay.textContent = '0 enlaces seleccionados'; | |
| countDisplay.style.fontWeight = 'bold'; | |
| countDisplay.style.textAlign = 'center'; | |
| countDisplay.style.fontSize = '14px'; | |
| const autoScanBtn = document.createElement('button'); | |
| autoScanBtn.textContent = 'Buscar enlaces de videos'; | |
| autoScanBtn.style.cssText = ` | |
| background: #2563eb; | |
| 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 selectAllBtn = document.createElement('button'); | |
| selectAllBtn.textContent = 'Seleccionar Todos'; | |
| selectAllBtn.style.cssText = ` | |
| background: #3f3f46; | |
| color: white; | |
| border: none; | |
| padding: 8px; | |
| border-radius: 6px; | |
| cursor: pointer; | |
| font-weight: 600; | |
| font-size: 13px; | |
| transition: background 0.2s; | |
| `; | |
| selectAllBtn.onmouseover = () => selectAllBtn.style.background = '#52525b'; | |
| selectAllBtn.onmouseout = () => selectAllBtn.style.background = '#3f3f46'; | |
| const closeBtn = document.createElement('button'); | |
| closeBtn.id = 'fb-close-btn'; | |
| closeBtn.textContent = 'Cerrar Selector'; | |
| closeBtn.style.cssText = ` | |
| background: #27272a; | |
| color: white; | |
| border: 1px solid #3f3f46; | |
| padding: 8px; | |
| border-radius: 6px; | |
| cursor: pointer; | |
| font-size: 13px; | |
| `; | |
| container.appendChild(countDisplay); | |
| container.appendChild(autoScanBtn); | |
| container.appendChild(selectAllBtn); | |
| container.appendChild(copyBtn); | |
| container.appendChild(closeBtn); | |
| (document.body || document.documentElement).appendChild(container); | |
| const style = document.createElement('style'); | |
| style.id = 'fb-style'; | |
| style.textContent = ` | |
| .fb-selector-hover { | |
| outline: 3px solid #60a5fa !important; | |
| cursor: crosshair !important; | |
| transition: all 0.2s; | |
| } | |
| .fb-selector-selected { | |
| outline: 4px solid #10b981 !important; | |
| opacity: 0.8; | |
| position: relative; | |
| } | |
| .fb-selector-selected::after { | |
| content: '✓'; | |
| 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: 10; | |
| box-shadow: 0 2px 5px rgba(0,0,0,0.5); | |
| } | |
| `; | |
| (document.head || document.documentElement).appendChild(style); | |
| const getPostCard = (el) => el.closest('a[href*="/reel/"], a[href*="/videos/"], a[href*="/watch/"]'); | |
| let isDragging = false; | |
| let dragMode = null; | |
| const mouseOver = (e) => { | |
| const card = getPostCard(e.target); | |
| if (card) { | |
| if (isDragging) { | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| const url = card.href.split('?')[0]; | |
| if (dragMode === 'select' && !selectedLinks.has(url)) { | |
| selectedLinks.add(url); | |
| card.classList.add('fb-selector-selected'); | |
| card.classList.remove('fb-selector-hover'); | |
| } else if (dragMode === 'deselect' && selectedLinks.has(url)) { | |
| selectedLinks.delete(url); | |
| card.classList.remove('fb-selector-selected'); | |
| } | |
| countDisplay.textContent = selectedLinks.size + ' enlaces seleccionados'; | |
| } else { | |
| if (!card.classList.contains('fb-selector-selected')) { | |
| card.classList.add('fb-selector-hover'); | |
| } | |
| } | |
| } | |
| }; | |
| const mouseOut = (e) => { | |
| const card = getPostCard(e.target); | |
| if (card) { | |
| card.classList.remove('fb-selector-hover'); | |
| } | |
| }; | |
| const mouseDown = (e) => { | |
| const card = getPostCard(e.target); | |
| if (card) { | |
| e.preventDefault(); | |
| isDragging = true; | |
| const url = card.href.split('?')[0]; | |
| if (selectedLinks.has(url)) { | |
| dragMode = 'deselect'; | |
| selectedLinks.delete(url); | |
| card.classList.remove('fb-selector-selected'); | |
| } else { | |
| dragMode = 'select'; | |
| selectedLinks.add(url); | |
| card.classList.add('fb-selector-selected'); | |
| card.classList.remove('fb-selector-hover'); | |
| } | |
| countDisplay.textContent = selectedLinks.size + ' enlaces seleccionados'; | |
| } | |
| }; | |
| const mouseUp = (e) => { | |
| isDragging = false; | |
| dragMode = null; | |
| }; | |
| const dragStart = (e) => { | |
| const card = getPostCard(e.target); | |
| if (card) e.preventDefault(); | |
| }; | |
| const click = (e) => { | |
| const card = getPostCard(e.target); | |
| if (card) { | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| } | |
| }; | |
| document.addEventListener('mouseover', mouseOver, true); | |
| document.addEventListener('mouseout', mouseOut, true); | |
| document.addEventListener('mousedown', mouseDown, true); | |
| window.addEventListener('mouseup', mouseUp, true); | |
| document.addEventListener('dragstart', dragStart, true); | |
| document.addEventListener('click', click, true); | |
| let scanInterval = null; | |
| autoScanBtn.onclick = () => { | |
| if (window.__fbIsScanning) { | |
| clearInterval(scanInterval); | |
| window.__fbIsScanning = false; | |
| autoScanBtn.textContent = 'Buscar enlaces de videos'; | |
| autoScanBtn.style.background = '#2563eb'; | |
| return; | |
| } | |
| window.__fbIsScanning = true; | |
| autoScanBtn.textContent = 'Buscando... (0)'; | |
| autoScanBtn.style.background = '#ef4444'; | |
| let lastHeight = 0; | |
| let retries = 0; | |
| const maxRetries = 5; | |
| scanInterval = setInterval(() => { | |
| window.scrollTo(0, document.body.scrollHeight); | |
| const links = document.querySelectorAll('a[href*="/reel/"], a[href*="/videos/"], a[href*="/watch/"]'); | |
| let addedNew = false; | |
| links.forEach(a => { | |
| let cleanUrl = a.href.split('?')[0]; | |
| if (!selectedLinks.has(cleanUrl)) { | |
| selectedLinks.add(cleanUrl); | |
| a.classList.add('fb-selector-selected'); | |
| a.classList.remove('fb-selector-hover'); | |
| addedNew = true; | |
| } | |
| }); | |
| countDisplay.textContent = selectedLinks.size + ' enlaces seleccionados'; | |
| autoScanBtn.textContent = 'Detener búsqueda (' + selectedLinks.size + ')'; | |
| if (document.body.scrollHeight === lastHeight && !addedNew) { | |
| retries++; | |
| if (retries >= maxRetries) { | |
| clearInterval(scanInterval); | |
| window.__fbIsScanning = false; | |
| autoScanBtn.textContent = 'Buscar enlaces de videos'; | |
| autoScanBtn.style.background = '#2563eb'; | |
| } | |
| } else { | |
| retries = 0; | |
| } | |
| lastHeight = document.body.scrollHeight; | |
| }, 1500); | |
| }; | |
| selectAllBtn.onclick = () => { | |
| const cards = document.querySelectorAll('a[href*="/reel/"], a[href*="/videos/"], a[href*="/watch/"]'); | |
| let allSelected = true; | |
| cards.forEach(card => { | |
| const url = card.href.split('?')[0]; | |
| if (!selectedLinks.has(url)) { | |
| allSelected = false; | |
| } | |
| }); | |
| if (allSelected && selectedLinks.size > 0) { | |
| cards.forEach(card => { | |
| card.classList.remove('fb-selector-selected'); | |
| const url = card.href.split('?')[0]; | |
| selectedLinks.delete(url); | |
| }); | |
| selectAllBtn.textContent = 'Seleccionar Todos'; | |
| } else { | |
| cards.forEach(card => { | |
| const url = card.href.split('?')[0]; | |
| if (!selectedLinks.has(url)) { | |
| selectedLinks.add(url); | |
| card.classList.add('fb-selector-selected'); | |
| card.classList.remove('fb-selector-hover'); | |
| } | |
| }); | |
| selectAllBtn.textContent = 'Deseleccionar Todos'; | |
| } | |
| countDisplay.textContent = selectedLinks.size + ' enlaces seleccionados'; | |
| }; | |
| copyBtn.onclick = () => { | |
| if (selectedLinks.size === 0) return; | |
| const text = Array.from(selectedLinks).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); | |
| window.__fbIsScanning = false; | |
| document.removeEventListener('mouseover', mouseOver, true); | |
| document.removeEventListener('mouseout', mouseOut, true); | |
| document.removeEventListener('mousedown', mouseDown, true); | |
| window.removeEventListener('mouseup', mouseUp, true); | |
| document.removeEventListener('dragstart', dragStart, true); | |
| document.removeEventListener('click', click, true); | |
| container.remove(); | |
| style.remove(); | |
| document.querySelectorAll('.fb-selector-selected').forEach(el => el.classList.remove('fb-selector-selected')); | |
| document.querySelectorAll('.fb-selector-hover').forEach(el => el.classList.remove('fb-selector-hover')); | |
| window.__fbSelectorActive = false; | |
| window.dispatchEvent(new Event('FB_OFF')); | |
| }; | |
| })(); | |