Spaces:
Running
Running
File size: 9,783 Bytes
9b3d6e1 d2bd0f6 9b3d6e1 d2bd0f6 9b3d6e1 d2bd0f6 9b3d6e1 d2bd0f6 9b3d6e1 d2bd0f6 9b3d6e1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | // 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')`;
} |