Skip to content

Instantly share code, notes, and snippets.

@sunmeat
Created May 30, 2025 12:46
Show Gist options
  • Save sunmeat/c4b883b1da1ae890635d07062e1ac585 to your computer and use it in GitHub Desktop.
Save sunmeat/c4b883b1da1ae890635d07062e1ac585 to your computer and use it in GitHub Desktop.
пример блокировки страницы :)
import React, { useState } from 'react';
const BlockingExample = () => {
const [isBlocked, setIsBlocked] = useState(false);
const [inputValue, setInputValue] = useState('');
const [checked, setChecked] = useState(false);
const blockPageForever = () => {
setIsBlocked(true);
console.log('СТРАНИЦА БУДЕТ ЗАМОРОЖЕНА НАВСЕГДА...');
// 100% блокирующий бесконечный цикл
while (true) {
for (let i = 0; i < 1e9; i++) {
Math.sqrt(Math.random() * i);
}
}
};
return (
<div style={{
padding: '40px',
fontFamily: 'Arial, sans-serif',
backgroundColor: isBlocked ? '#ffebee' : '#f5f5f5',
minHeight: '100vh',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center'
}}>
<h1>Тест полной блокировки</h1>
{isBlocked && (
<div style={{
backgroundColor: '#d32f2f',
color: 'white',
padding: '20px',
borderRadius: '10px',
marginBottom: '30px',
fontSize: '18px',
fontWeight: 'bold',
textAlign: 'center'
}}>
🚫 ПОЛНАЯ ЗАМОРОЗКА АКТИВИРОВАНА<br />
Закройте вкладку для выхода
</div>
)}
<div style={{
backgroundColor: 'white',
padding: '30px',
borderRadius: '10px',
boxShadow: '0 4px 8px rgba(0,0,0,0.1)',
width: '100%',
maxWidth: '400px',
marginBottom: '20px'
}}>
<label style={{
display: 'block',
marginBottom: '10px',
fontSize: '16px',
fontWeight: 'bold'
}}>
Введите что-нибудь:
</label>
<input
type="text"
value={inputValue}
onChange={(e) => setInputValue(e.target.value)}
placeholder="Попробуй попечатать..."
style={{
width: '100%',
padding: '12px',
fontSize: '16px',
border: '2px solid #ddd',
borderRadius: '5px',
marginBottom: '20px',
boxSizing: 'border-box'
}}
/>
<label style={{
display: 'flex',
alignItems: 'center',
fontSize: '14px',
color: '#333'
}}>
<input
type="checkbox"
checked={checked}
onChange={(e) => setChecked(e.target.checked)}
style={{ marginRight: '10px' }}
/>
Подтвердите свою беспомощность
</label>
</div>
<div style={{ display: 'flex', gap: '20px', marginBottom: '30px' }}>
<button
onClick={blockPageForever}
style={{
padding: '15px 30px',
fontSize: '18px',
fontWeight: 'bold',
backgroundColor: '#d32f2f',
color: 'white',
border: 'none',
borderRadius: '5px',
cursor: 'pointer'
}}
>
🔒 БЛОКИРОВАТЬ СТРАНИЦУ НАВСЕГДА
</button>
<button
onClick={() => alert('Успел, молодец...')}
style={{
padding: '15px 30px',
fontSize: '18px',
fontWeight: 'bold',
backgroundColor: '#1976d2',
color: 'white',
border: 'none',
borderRadius: '5px',
cursor: 'pointer'
}}
>
🔘 Нажми, если успеешь
</button>
</div>
<div style={{
padding: '20px',
backgroundColor: '#fff3cd',
border: '2px solid #ffc107',
borderRadius: '10px',
maxWidth: '500px',
textAlign: 'center'
}}>
<h3 style={{ color: '#856404', marginTop: 0 }}>⚠️ Предупреждение</h3>
<p style={{ color: '#856404', margin: 0 }}>
После нажатия кнопки страница полностью зависнет.<br />
Ни мышь, ни клавиатура не помогут. Только <strong>закрытие вкладки</strong>.
</p>
</div>
</div>
);
};
export default BlockingExample;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment