42 lines
1.3 KiB
JavaScript
Executable File
42 lines
1.3 KiB
JavaScript
Executable File
window.addEventListener('load', () => {
|
|
const cookieBtn = document.createElement('button');
|
|
cookieBtn.textContent = 'Accept Cookies 🍪';
|
|
cookieBtn.className = 'cookie-btn';
|
|
|
|
cookieBtn.style.position = 'fixed';
|
|
cookieBtn.style.bottom = '20px';
|
|
cookieBtn.style.right = '20px';
|
|
cookieBtn.style.zIndex = '9999';
|
|
|
|
document.body.appendChild(cookieBtn);
|
|
|
|
cookieBtn.addEventListener('click', () => {
|
|
for (let i = 0; i < 100; i++) createCookie();
|
|
});
|
|
|
|
function createCookie() {
|
|
const cookie = document.createElement('div');
|
|
cookie.textContent = '🍪';
|
|
|
|
Object.assign(cookie.style, {
|
|
position: 'fixed',
|
|
fontSize: `${Math.random() * 30 + 20}px`,
|
|
left: `${Math.random() * window.innerWidth}px`,
|
|
top: `-${Math.random() * 50}px`,
|
|
zIndex: '9999',
|
|
pointerEvents: 'none',
|
|
transition: 'transform 5s linear, opacity 5s linear'
|
|
});
|
|
|
|
document.body.appendChild(cookie);
|
|
|
|
setTimeout(() => {
|
|
cookie.style.transform =
|
|
`translateY(${window.innerHeight + 50}px) rotate(${Math.random() * 360}deg)`;
|
|
cookie.style.opacity = '0';
|
|
}, 50);
|
|
|
|
setTimeout(() => cookie.remove(), 5500);
|
|
}
|
|
});
|