-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
123 lines (109 loc) · 4.69 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="icon" type="image/x-icon" href="favicons\glass.ico" />
<title>Watch my milk plz</title>
<style>
body {
margin: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #ffffff; /* Optional: Set a background color */
padding: 20px; /* Added padding for better spacing on mobile devices */
}
#container {
text-align: center;
}
#image {
max-width: 100%; /* Adjust the height as needed */
border-radius: 10px; /* Optional: Add border radius for a rounded appearance */
}
#caption {
margin-top: 10px;
font-family: 'Arial', sans-serif;
font-size: 18px;
color: #333;
}
@media (max-width: 600px) {
#container {
max-width: 100vw; /* Adjust the width for smaller screens */
padding: 0 20px; /* Adjust padding for better spacing on small screens */
}
}
</style>
</head>
<body>
<div id="container">
<img id="image" src="images/glass.jpg" alt="Image">
<div id="caption">Yo watch my milk bruh. I'll be right back i swear</div>
</div>
<script>
// Check if the user has been thanked or spilled
const firstEvent = localStorage.getItem('firstEvent');
const currentVersion = '4.0';
// Function to set the image state in localStorage
function setState(imageSrc, caption, event, title, favicon) {
localStorage.setItem('imageSrc', imageSrc);
localStorage.setItem('caption', caption);
localStorage.setItem('firstEvent', event);
localStorage.setItem('title', title);
localStorage.setItem('favicon', favicon);
}
// Function to get the image state from localStorage
function getState() {
return {
imageSrc: localStorage.getItem('imageSrc'),
caption: localStorage.getItem('caption'),
firstEvent: localStorage.getItem('firstEvent'),
title: localStorage.getItem('title'),
favicon: localStorage.getItem('favicon')
};
}
// Function to update the image and caption
function updateImageAndCaption() {
const imageState = getState();
document.getElementById('image').src = imageState.imageSrc;
document.getElementById('caption').innerText = imageState.caption;
document.title = imageState.title;
var link = document.querySelector("link[rel*='icon']");
link.type = 'image/x-icon';
link.rel = 'icon';
link.href = imageState.favicon;
}
// Event listener for visibility change
document.addEventListener('visibilitychange', function () {
const firstEvent = localStorage.getItem('firstEvent');
if (document.hidden && (firstEvent == "null" || firstEvent == null)) {
// If the user leaves the tab and hasn't been thanked or spilled, change the image and caption to "spilled"
setState('images/spilled.jpg', 'yo wtf it spilled i told you to watch it', 'spilled','IT SPILLED! come on','favicons\\spilled.ico');
updateImageAndCaption();
}
});
// Set timeout for a few seconds
setTimeout(function () {
const firstEvent = localStorage.getItem('firstEvent');
if (firstEvent == "null" || firstEvent == null) {
// If the user hasn't been thanked or spilled, and hasn't left the tab, change the image and caption to "Thank you"
if (getRandomInt(100) <= 50){
setState('images/thanks.png', 'oh my god, thank you sooooo much for watching my milk! i was pretty worried it was gonna spill','thanked', 'ur the goat. seriously','favicons\\thanks.ico');
} else {
setState('images/wesmilk.png', 'thanks for watching it','thanked', 'preciate it','favicons\\thanks.ico');
}
updateImageAndCaption();
}
}, getRandomInt(10000)+15000);
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
if (localStorage.getItem('version') != currentVersion){
localStorage.clear();
localStorage.setItem('version', currentVersion);
console.log('cleared!');
} else if (!(firstEvent == "null" || firstEvent == null)) {
updateImageAndCaption();
}
</script>
</body>
</html>