Spaces:
Running
Running
Download script.js from bro445454548/viewboost-pro: direct link, hf CLI and curl.
- Browser
- Download file 9.78 kB
-
https://huggingface.co/spaces/bro445454548/viewboost-pro/resolve/main/script.js
- Command line
-
hf download hf://spaces/bro445454548/viewboost-pro/script.js
-
curl -L -o script.js https://huggingface.co/spaces/bro445454548/viewboost-pro/resolve/main/script.js
9.78 kB
| // ViewBoost Pro - Main JavaScript functionality | |
| class ViewBoostPro { | |
| constructor() { | |
| this.isRunning = false; | |
| this.currentView = 0; | |
| this.totalViews = 0; | |
| this.watchDuration = 0; | |
| this.videoUrl = ''; | |
| this.popupWindows = []; | |
| this.timeoutIds = []; | |
| this.initializeEventListeners(); | |
| } | |
| initializeEventListeners() { | |
| const form = document.getElementById('generationForm'); | |
| const stopButton = document.getElementById('stopButton'); | |
| form.addEventListener('submit', (e) => this.handleFormSubmit(e)); | |
| stopButton.addEventListener('click', () => this.stopGeneration()); | |
| // Input validation | |
| this.setupInputValidation(); | |
| } | |
| setupInputValidation() { | |
| const viewCountInput = document.getElementById('viewCount'); | |
| const durationInput = document.getElementById('watchDuration'); | |
| viewCountInput.addEventListener('input', (e) => { | |
| let value = parseInt(e.target.value); | |
| if (value > 100) { | |
| e.target.value = 100; | |
| this.showNotification('Для стабильной работы рекомендуется не более 100 просмотров за сессию', 'warning'); | |
| } | |
| }); | |
| durationInput.addEventListener('input', (e) => { | |
| let value = parseInt(e.target.value); | |
| if (value < 15) { | |
| e.target.value = 15; | |
| this.showNotification('Минимальная длительность просмотра - 15 секунд', 'warning'); | |
| } | |
| }); | |
| } | |
| handleFormSubmit(e) { | |
| e.preventDefault(); | |
| const videoUrl = document.getElementById('videoUrl').value; | |
| const viewCount = parseInt(document.getElementById('viewCount').value); | |
| const watchDuration = parseInt(document.getElementById('watchDuration').value); | |
| // Validate inputs | |
| if (!this.validateInputs(videoUrl, viewCount, watchDuration)) { | |
| return; | |
| } | |
| this.startGeneration(videoUrl, viewCount, watchDuration); | |
| } | |
| validateInputs(videoUrl, viewCount, watchDuration) { | |
| // Validate YouTube URL | |
| if (!this.isValidYouTubeUrl(videoUrl)) { | |
| this.showNotification('Пожалуйста, введите корректную ссылку на YouTube видео', 'error'); | |
| return false; | |
| } | |
| // Validate view count | |
| if (viewCount < 1 || viewCount > 100) { | |
| this.showNotification('Количество просмотров должно быть от 1 до 100', 'error'); | |
| return false; | |
| } | |
| // Validate watch duration | |
| if (watchDuration < 15) { | |
| this.showNotification('Длительность просмотра должна быть не менее 15 секунд', 'error'); | |
| return false; | |
| } | |
| return true; | |
| } | |
| isValidYouTubeUrl(url) { | |
| const youtubeRegex = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/.+$/; | |
| return youtubeRegex.test(url); | |
| } | |
| startGeneration(videoUrl, viewCount, watchDuration) { | |
| this.isRunning = true; | |
| this.currentView = 0; | |
| this.totalViews = viewCount; | |
| this.watchDuration = watchDuration; | |
| this.videoUrl = videoUrl; | |
| // Show progress section | |
| document.getElementById('progressSection').classList.remove('hidden'); | |
| document.getElementById('progressSection').classList.add('fade-in'); | |
| // Update UI | |
| this.updateProgress(); | |
| // Start the first view | |
| this.openNextView(); | |
| } | |
| openNextView() { | |
| if (!this.isRunning || this.currentView >= this.totalViews) { | |
| this.completeGeneration(); | |
| return; | |
| } | |
| this.currentView++; | |
| this.updateProgress(); | |
| // Open popup window using progressive approach | |
| this.openPopupWindow(); | |
| } | |
| openPopupWindow() { | |
| const popupWidth = 854; | |
| const popupHeight = 480; | |
| const left = (screen.width - popupWidth) / 2; | |
| const top = (screen.height - popupHeight) / 2; | |
| // Create a user gesture to improve popup success rate | |
| const openPopup = () => { | |
| try { | |
| const popup = window.open( | |
| '', | |
| `viewboost_${Date.now()}_${this.currentView}`, | |
| `width=${popupWidth},height=${popupHeight},left=${left},top=${top},resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,location=no` | |
| ); | |
| if (popup) { | |
| // Navigate to the video URL after popup is opened | |
| popup.location.href = this.videoUrl; | |
| this.popupWindows.push(popup); | |
| // Set timeout to close popup and open next one | |
| const timeoutId = setTimeout(() => { | |
| this.closeCurrentPopup(); | |
| // Small delay before opening next view for better user experience | |
| setTimeout(() => { | |
| this.openNextView(); | |
| }, 500); | |
| }, this.watchDuration * 1000); | |
| this.timeoutIds.push(timeoutId); | |
| } else { | |
| this.handlePopupBlocked(); | |
| } | |
| } catch (error) { | |
| this.handlePopupError(error); | |
| } | |
| }; | |
| // Try to open popup with user gesture context | |
| openPopup(); | |
| } | |
| closeCurrentPopup() { | |
| if (this.popupWindows.length > 0) { | |
| const popup = this.popupWindows.shift(); | |
| if (popup && !popup.closed) { | |
| popup.close(); | |
| } | |
| } | |
| } | |
| handlePopupBlocked() { | |
| this.showNotification('Всплывающие окна заблокированы! Пожалуйста, разрешите их для этого сайта.', 'error'); | |
| this.stopGeneration(); | |
| } | |
| handlePopupError(error) { | |
| console.error('Popup error:', error); | |
| this.showNotification('Ошибка при открытии окна. Попробуйте снова.', 'error'); | |
| this.stopGeneration(); | |
| } | |
| updateProgress() { | |
| const progressBar = document.getElementById('progressBar'); | |
| const progressText = document.getElementById('progressText'); | |
| const currentStatus = document.getElementById('currentStatus'); | |
| const percentage = (this.currentView / this.totalViews) * 100; | |
| progressBar.style.width = `${percentage}%`; | |
| progressText.textContent = `${this.currentView}/${this.totalViews}`; | |
| if (this.isRunning) { | |
| currentStatus.textContent = `Запуск просмотра ${this.currentView} из ${this.totalViews}`; | |
| } else { | |
| currentStatus.textContent = 'Процесс завершен'; | |
| } | |
| } | |
| stopGeneration() { | |
| this.isRunning = false; | |
| // Clear all timeouts | |
| this.timeoutIds.forEach(timeoutId => clearTimeout(timeoutId)); | |
| this.timeoutIds = []; | |
| // Close all popup windows | |
| this.popupWindows.forEach(popup => { | |
| if (popup && !popup.closed) { | |
| popup.close(); | |
| } | |
| }); | |
| this.popupWindows = []; | |
| this.showNotification('Процесс накрутки остановлен', 'info'); | |
| this.updateProgress(); | |
| } | |
| completeGeneration() { | |
| this.isRunning = false; | |
| this.showNotification(`Накрутка завершена! Обработано ${this.totalViews} просмотров.`, 'success'); | |
| this.updateProgress(); | |
| } | |
| showNotification(message, type = 'info') { | |
| // Create notification element | |
| const notification = document.createElement('div'); | |
| notification.className = `fixed top-4 right-4 p-4 rounded-lg shadow-lg transform transition-all duration-300 fade-in ${ | |
| type === 'error' ? 'bg-red-100 border border-red-300 text-red-800' : | |
| type === 'warning' ? 'bg-yellow-100 border border-yellow-300 text-yellow-800' : | |
| type === 'success' ? 'bg-green-100 border border-green-300 text-green-800' : | |
| 'bg-blue-100 border border-blue-300 text-blue-800' | |
| }`; | |
| notification.innerHTML = ` | |
| <div class="flex items-center"> | |
| <i data-feather="${ | |
| type === 'error' ? 'alert-circle' : | |
| type === 'warning' ? 'alert-triangle' : | |
| type === 'success' ? 'check-circle' : | |
| 'info' | |
| }" class="w-5 h-5 mr-2"></i> | |
| <span>${message}</span> | |
| </div> | |
| `; | |
| document.body.appendChild(notification); | |
| feather.replace(); | |
| // Remove notification after 5 seconds | |
| setTimeout(() => { | |
| notification.classList.add('opacity-0', 'transform', 'scale-95'); | |
| setTimeout(() => { | |
| if (notification.parentNode) { | |
| notification.parentNode.removeChild(notification); | |
| } | |
| }, 300); | |
| }, 5000); | |
| } | |
| } | |
| // Initialize the application when DOM is loaded | |
| document.addEventListener('DOMContentLoaded', () => { | |
| new ViewBoostPro(); | |
| }); | |
| // Utility function to format seconds into minutes and seconds | |
| function formatDuration(seconds) { | |
| const minutes = Math.floor(seconds / 60); | |
| const remainingSeconds = seconds % 60; | |
| return `${minutes}:${remainingSeconds.toString().padStart(2, '0')`; | |
| } |