Merge pull request #985 from therealsuss/main

chaos.js
This commit is contained in:
slweeb 2025-02-06 13:50:49 -05:00 committed by GitHub
commit 3828320a81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 32 additions and 0 deletions

32
mods/chaos.js Normal file
View File

@ -0,0 +1,32 @@
function getRandomSize(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function randomizeall() {
const elements = document.querySelectorAll('*');
elements.forEach(element => {
const randomFontSize = getRandomSize(1, 150);
element.style.fontSize = `${randomFontSize}px`;
if (element.offsetWidth > 0 && element.offsetHeight > 0) {
const randomWidth = getRandomSize(1, 500);
const randomHeight = getRandomSize(1, 500);
element.style.width = `${randomWidth}px`;
element.style.height = `${randomHeight}px`;
}
if (window.getComputedStyle(element).position === 'absolute' || window.getComputedStyle(element).position === 'relative') {
const randomTop = getRandomSize(1, window.innerHeight - 1);
const randomLeft = getRandomSize(1, window.innerWidth - 1);
element.style.position = 'absolute';
element.style.top = `${randomTop}px`;
element.style.left = `${randomLeft}px`;
}
const randomRotation = getRandomSize(-360, 360);
element.style.transform = `rotate(${randomRotation}deg)`;
});
}
setTimeout(randomizeall, 15000);