diff --git a/content.js b/content.js
index 7e2c464..23b0cdf 100644
--- a/content.js
+++ b/content.js
@@ -25,36 +25,85 @@
// Estilos inline para máxima compatibilidad
popup.style.position = 'fixed';
- popup.style.top = '50%';
- popup.style.left = '50%';
- popup.style.transform = 'translate(-50%, -50%)';
- popup.style.width = '450px';
+ popup.style.top = '20px';
+ popup.style.right = '20px';
+ popup.style.width = '320px';
popup.style.background = '#667eea';
popup.style.backgroundImage = 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)';
popup.style.color = 'white';
- popup.style.padding = '30px';
- popup.style.borderRadius = '15px';
- popup.style.boxShadow = '0 10px 50px rgba(0,0,0,0.6)';
+ popup.style.padding = '20px';
+ popup.style.borderRadius = '12px';
+ popup.style.boxShadow = '0 8px 32px rgba(0,0,0,0.5)';
popup.style.zIndex = '999999'; // ¡Muy alto!
popup.style.fontFamily = 'Arial, sans-serif';
popup.style.display = 'block'; // Visible por defecto
popup.style.backdropFilter = 'blur(10px)';
popup.innerHTML = `
-
-
📦 Descargando Manga
-
Preparando...
+
+
📦 Mass Downloader
+
+
+
+
+ Seleccionados: 0
+
+
+
+
+
+
+
+
+
Preparando...
+
+
+ 0 / 0
+ 0%
+
+
+
-
-
- 0 / 0
- 0%
-
-
`;
+ // Agregar event listeners a los botones
+ setTimeout(() => {
+ const btnDownloadSelected = document.getElementById('btn-download-selected');
+ const btnDownloadAll = document.getElementById('btn-download-all');
+ const btnClearSelection = document.getElementById('btn-clear-selection');
+
+ if (btnDownloadSelected) {
+ btnDownloadSelected.addEventListener('click', () => {
+ console.log('🎯 Click: Descargar Seleccionados');
+ // Enviar mensaje al popup.js para ejecutar la descarga
+ chrome.runtime.sendMessage({ action: 'triggerDownloadSelected' });
+ });
+ }
+
+ if (btnDownloadAll) {
+ btnDownloadAll.addEventListener('click', () => {
+ console.log('🎯 Click: Descargar TODOS');
+ chrome.runtime.sendMessage({ action: 'triggerDownloadAll' });
+ });
+ }
+
+ if (btnClearSelection) {
+ btnClearSelection.addEventListener('click', () => {
+ console.log('🎯 Click: Limpiar Selección');
+ selectedMangas.clear();
+ updateSelectedCount();
+ const countEl = document.getElementById('selected-count');
+ if (countEl) countEl.textContent = '0';
+ });
+ }
+
+ // Actualizar contador inicialmente
+ const countEl = document.getElementById('selected-count');
+ if (countEl) countEl.textContent = selectedMangas.size.toString();
+ }, 100);
+
console.log('✅ Popup creado, agregando al DOM...');
document.body.appendChild(popup);
console.log('✅ Popup agregado al DOM:', popup);
@@ -78,6 +127,16 @@
const percent = total > 0 ? Math.round((current / total) * 100) : 0;
console.log(`📈 Porcentaje calculado: ${percent}%`);
+ // Cambiar a panel de progreso
+ const controlPanel = document.getElementById('control-panel');
+ const progressPanel = document.getElementById('progress-panel');
+
+ if (controlPanel && progressPanel) {
+ controlPanel.style.display = 'none';
+ progressPanel.style.display = 'block';
+ console.log('🔄 Cambiado a panel de progreso');
+ }
+
const titleEl = document.getElementById('progress-title');
const countEl = document.getElementById('progress-count');
const percentEl = document.getElementById('progress-percent');
@@ -121,15 +180,28 @@
// Ocultar progreso
function hideProgress() {
+ console.log('🙈 hideProgress() llamado');
+
const popup = document.getElementById('mass-downloader-progress-popup');
if (popup) {
- setTimeout(() => {
- popup.style.opacity = '0';
- popup.style.transition = 'opacity 0.5s ease';
- setTimeout(() => {
- popup.remove();
- }, 500);
- }, 1000);
+ // Cambiar de vuelta al panel de control
+ const controlPanel = document.getElementById('control-panel');
+ const progressPanel = document.getElementById('progress-panel');
+
+ if (controlPanel && progressPanel) {
+ progressPanel.style.display = 'none';
+ controlPanel.style.display = 'block';
+ console.log('🔄 Cambiado a panel de control');
+
+ // Actualizar contador
+ const countEl = document.getElementById('selected-count');
+ if (countEl) {
+ countEl.textContent = selectedMangas.size.toString();
+ console.log('🔢 Contador actualizado:', countEl.textContent);
+ }
+ }
+
+ // NO remover el popup, solo cambiar de panel
}
}
@@ -170,6 +242,22 @@
console.log('🙈 Ocultando progreso');
hideProgress();
sendResponse({ success: true });
+ } else if (request.action === 'updateSelectedCount') {
+ const countEl = document.getElementById('selected-count');
+ if (countEl) {
+ countEl.textContent = request.count.toString();
+ console.log('🔢 Contador actualizado:', countEl.textContent);
+ }
+ sendResponse({ success: true });
+ } else if (request.action === 'triggerDownloadSelected') {
+ console.log('🎯 Trigger: Descargar Seleccionados');
+ // Enviar mensaje al popup.js para ejecutar la descarga
+ chrome.runtime.sendMessage({ action: 'executeDownloadSelected' });
+ sendResponse({ success: true });
+ } else if (request.action === 'triggerDownloadAll') {
+ console.log('🎯 Trigger: Descargar TODOS');
+ chrome.runtime.sendMessage({ action: 'executeDownloadAll' });
+ sendResponse({ success: true });
} else {
console.log('❓ Acción desconocida:', request.action);
}