-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHacking the browser.js
38 lines (27 loc) · 1.11 KB
/
Hacking the browser.js
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
// creating a loop for moving around all elements:
function drifting () {
const makeRandColor = () => {
const r = Math.floor(Math.random() * 255)
const g = Math.floor(Math.random() * 255)
const b = Math.floor(Math.random() * 255)
return `rgb(${r},${g},${b})`
}
var everything = document.querySelectorAll('*'), i;
for (i = 0; i < everything.length; ++i) {
everything[i].style.position = "absolute";
everything[i].style.top = Math.random() * 100 + 'px';
everything[i].style.left = Math.random() * 100 + 'px';
everything[i].style.transition = "1s ease-in-out";
document.body.style.backgroundColor = makeRandColor();
}
}
setInterval(drifting, 2000)
const makeRandColor = () => {
const r = Math.floor(Math.random() * 255)
const g = Math.floor(Math.random() * 255)
const b = Math.floor(Math.random() * 255)
return `rgb(${r},${g},${b})`
}
setInterval(() => {
document.body.style.backgroundColor = makeRandColor();
},1000)