forked from gpt4free/g4f.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.html
More file actions
224 lines (215 loc) · 8.8 KB
/
Copy pathbackground.html
File metadata and controls
224 lines (215 loc) · 8.8 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>G4F - Background</title>
<link rel="icon" href="dist/img/g4f.svg" type="image/svg+xml">
<link rel="shortcut icon" href="dist/img/g4f.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="dist/img/g4f.svg">
<link rel="manifest" href="dist/img/site.webmanifest">
<style>
:root {
--colour-1: #000000;
--colour-2: #ccc;
--colour-3: #e4d4ff;
--colour-4: #f0f0f0;
--colour-5: #181818;
--colour-6: #242424;
--accent: #8b3dff;
--gradient: #1a1a1a;
--background: #16101b;
--size: 70vw;
--top: 50%;
--blur: 40px;
--opacity: 0.6;
}
.gradient {
position: absolute;
left: 50vw;
border-radius: 50%;
background: radial-gradient(circle at center, var(--accent), var(--gradient));
width: var(--size);
height: var(--size);
top: var(--top);
transform: translate(-50%, -50%);
filter: blur(var(--blur)) opacity(var(--opacity));
animation: zoom_gradient 6s infinite alternate;
display: none;
max-height: 100%;
transition: max-height 0.25s ease-in;
}
.gradient.hidden {
max-height: 0;
transition: max-height 0.15s ease-out;
}
@media only screen and (min-width: 40em) {
body .gradient{
display: block;
}
}
/* Animation for the gradient circle */
@keyframes zoom_gradient {
0% {
transform: translate(-50%, -50%) scale(1);
}
100% {
transform: translate(-50%, -50%) scale(1.5);
}
}
/* Body and text color */
body {
background: var(--background);
height: 100vh;
margin: 0;
padding: 0;
overflow: hidden;
}
.hidden {
display: none;
}
#background, #image-feed, #video-feed {
height: 100%;
position: absolute;
object-fit: cover;
object-position: center;
width: 100%;
background: black;
}
</style>
<link rel="stylesheet" href="dist/css/all.min.css">
<script src="dist/js/framework.js"></script>
</head>
<body>
<img id="image-feed" class="hidden" alt="Image Feed">
<video id="video-feed" class="hidden" alt="Video Feed" autoplay muted></video>
<!-- Gradient Background Circle -->
<div class="gradient"></div>
<script>
(async () => {
const videoUrl = window.location.origin == "https://g4f.dev" ? "/background/video_{0}.mp4" : (framework.backendUrl + "/search/video?skip={0}");
const url = "https://image.pollinations.ai/feed";
const imageFeed = document.getElementById("image-feed");
const videoFeed = document.getElementById("video-feed");
const gradient = document.querySelector(".gradient");
const images = [];
let es = null;
let skipVideo = 2;
let skipImage = 0;
let errorVideo = 0;
let errorImage = 0;
let skipRefresh = 0;
videoFeed.onloadeddata = () => {
videoFeed.classList.remove("hidden");
gradient.classList.add("hidden");
};
videoFeed.onerror = (e) => {
videoFeed.classList.add("hidden");
errorVideo += 1;
if (errorVideo > 1) {
gradient.classList.remove("hidden");
return;
}
videoFeed.src = videoUrl.replace("{0}", skipVideo);
skipVideo++;
};
videoFeed.onended = () => {
videoFeed.src = videoUrl.replace("{0}", skipVideo);
skipVideo++;
};
videoFeed.onclick = () => {
videoFeed.src = videoUrl.replace("{0}", skipVideo);
skipVideo++;
};
videoFeed.src = videoUrl.replace("{0}", skipVideo);
skipVideo++;
function initES() {
if (es == null || es.readyState == EventSource.CLOSED) {
const eventSource = new EventSource(url);
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.referrer && !data.referrer.startsWith("https://pollinations.ai"))
console.log(data.referrer);
if (data.nsfw || !data.nologo || data.width < 512 || !data.imageURL || data.isChild || data.status != "end_generating") {
return;
}
const lower = data.prompt.toLowerCase();
const tags = ["nsfw", "timeline", "feet", "blood", "soap", "orally", "heel", "latex", "bathroom", "boobs", "charts", "gel", "logo", "infographic", "warts", " bra ", "prostitute", "curvy", "breasts", "written", "bodies", "naked", "classroom", "malone", "dirty", "shoes", "shower", "banner", "fat", "nipples", "couple", "sexual", "sandal", "supplier", "overlord", "succubus", "platinum", "cracy", "crazy", "hemale", "oprah", "lamic", "ropes", "cables", "wires", "dirty", "messy", "cluttered", "chaotic", "disorganized", "disorderly", "untidy", "unorganized", "unorderly", "unsystematic", "disarranged", "disarrayed", "disheveled", "disordered", "jumbled", "muddled", "scattered", "shambolic", "sloppy", "unkept", "unruly", "bottomless", "18 year"];
for (i in tags) {
if (lower.indexOf(tags[i]) != -1) {
console.log("Skipping image with tag: " + tags[i]);
console.debug("Skipping image:", data.imageURL);
return;
}
}
const landscape = window.innerWidth > window.innerHeight;
if (landscape && data.width >= data.height) {
images.push(data.imageURL);
} else if (landscape) {
images.unshift(data.imageURL);
}
if (!landscape && data.width <= data.height) {
images.push(data.imageURL);
} else if (!landscape) {
images.unshift(data.imageURL);
}
};
eventSource.onerror = (event) => {
eventSource.close();
}
}
}
initES();
let refreshOnHide = true;
document.addEventListener("visibilitychange", () => {
if (document.hidden) {
refreshOnHide = false;
} else {
refreshOnHide = true;
}
});
setInterval(() => {
if ((framework.backendUrl && errorVideo < 2) || !refreshOnHide) {
return;
}
if (skipRefresh > 0) {
skipRefresh -= 1;
return;
}
if (framework.backendUrl && errorImage < 2) {
imageFeed.src = framework.backendUrl + "/search/image+g4f?skip=" + skipImage;
skipImage++;
return;
}
if (images.length > 0) {
imageFeed.classList.remove("hidden");
imageFeed.src = images.pop();
gradient.classList.add("hidden");
} else {
initES();
}
}, 7000);
imageFeed.onerror = () => {
imageFeed.classList.add("hidden");
gradient.classList.remove("hidden");
errorImage++;
};
imageFeed.onload = () => {
imageFeed.classList.remove("hidden");
gradient.classList.add("hidden");
};
imageFeed.onclick = () => {
if (framework.backendUrl) {
imageFeed.src = framework.backendUrl + "/search/image?random=" + Math.random();
}
else if (images.length > 0) {
imageFeed.src = images.pop();
}
if (skipRefresh < 3) {
skipRefresh++;
}
};
})();
</script>
</body>
</html>