-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
49 lines (41 loc) · 1.44 KB
/
index.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
39
40
41
42
43
44
45
46
47
48
49
import { readdirSync } from 'fs';
import { join } from 'path';
import { getRandomItem } from '@vizality/util/array';
import { Plugin } from '@vizality/entities';
export default class HeyZere extends Plugin {
async start () {
vizality.api.commands.registerCommand({
command: 'heyzere',
description: 'Replaces every image with a random image of Zerebos.',
executor: this.heyZere.bind(this)
});
this.zeres = readdirSync(join(__dirname, 'assets', 'zerebos'), { withFileTypes: true })
.filter(item => !item.isDirectory())
.map(item => item.name);
this.zeres = this.zeres.map(z => `vz-plugin://${this.addonId}/assets/zerebos/${z}`);
}
async stop () {
clearInterval(this.interval);
vizality.api.commands.unregisterCommand('heyzere');
}
heyZere () {
this.interval = setInterval(() => {
document.querySelectorAll('[style*="background-image"]')
.forEach(({ style }) => {
if (!this.zeres.filter(url => style.backgroundImage.includes(url)).length) {
style.backgroundImage = `url(${getRandomItem(this.zeres)})`;
}
});
document.querySelectorAll('img')
.forEach(image => {
if (!this.zeres.includes(image.src)) {
image.src = getRandomItem(this.zeres);
}
});
}, 50);
return {
send: false,
result: `Your Discord has been Zere-fied. To undo this change, you'll have to reload!`
};
}
}