-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
88 lines (74 loc) · 2.78 KB
/
index.tsx
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
/*
* Vencord, a Discord client mod
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { sleep } from "@utils/index";
import definePlugin from "@utils/types";
import { settings } from "./settings";
export default definePlugin({
name: "Maxwell :3",
description: "Silly Silly Silly",
authors: [{ name: "antipollyanna", id: 1297622889473904642n }],
dependencies: ["CommandsAPI"],
settings,
async start() {
await sleep(5);
for (let i = 0; i < settings.store.concurrentMaxwells ; i +=1) {
addGifToScreen();
}
},
stop() {
let gifElement = document.querySelector(".moving-gif");
while (gifElement) {
if (gifElement) {
gifElement.remove();
}
gifElement = document.querySelector(".moving-gif");
}
}
});
export async function addGifToScreen() {
// Make Maxwell happy spot :3
const gifElement = document.createElement("img");
gifElement.src = settings.store.gifLink2; // Start with spinny car
gifElement.className = "moving-gif";
gifElement.style.position = "fixed";
gifElement.style.bottom = "10px";
gifElement.style.left = "0px";
gifElement.style.width = settings.store.gifSize + "px";
gifElement.style.zIndex = "9999";
gifElement.style.transition = "all ease";
// Maxwell approves of directly modifying the DOM
document.body.appendChild(gifElement);
const getRandTime = (min: number, max: number) => Math.random() * (max - min) + min;
// Where will Maxwell be silly next?
const getRandPos = () => {
const screenW = window.innerWidth;
const screenH = window.innerHeight;
const gifW = gifElement.offsetWidth;
const gifH = gifElement.offsetHeight;
return {
x: Math.max(0, Math.random() * (screenW - gifW)),
y: Math.max(0, Math.random() * (screenH - gifH))
};
};
const timeToGetReallySilly = async () => {
while (true) {
// spinny spinny spinny spinny spinny spinny spinny
gifElement.src = settings.store.gifLink2;
gifElement.style.transition = "none";
await new Promise(resolve => setTimeout(resolve, getRandTime(4000, 8000)));
// dancy dancy dancy dancy dancy dancy dancy
const { x, y } = getRandPos();
gifElement.src = settings.store.gifLink1;
gifElement.style.transition = `all ${getRandTime(4, 8)}s ease`;
gifElement.style.left = `${x}px`;
gifElement.style.bottom = `${y}px`;
await new Promise(resolve => {
gifElement.addEventListener("transitionend", resolve, { once: true });
});
}
};
timeToGetReallySilly();
}