-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathavatarg.js
66 lines (51 loc) · 2.03 KB
/
avatarg.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
(() => {
'use strict'
function main() {
function generateRandomNumber(i) {
var randomNumber = Math.floor(Math.random() * i); // Generate random number between 0 and 12
return randomNumber.toString().padStart(2, '0'); // Add leading zero if necessary
}
function stackImages(container) {
container.style.position = 'relative';
console.log("wep")
let size = container.getAttribute("size") || "220px";
// Array of image URLs
var scriptElements = document.getElementsByTagName('script');
var currentScript = scriptElements[scriptElements.length - 1];
var baseUrl = currentScript.src.replace(/\/[^/]*$/, '/');
var imageUrls = [
baseUrl + 'head/head-' + generateRandomNumber(16) + '.png',
baseUrl + 'eyes/eyes-' + generateRandomNumber(12) + '.png',
baseUrl + 'mouth/mouth-' + generateRandomNumber(10) + '.png',
baseUrl + 'nose/nose-' + generateRandomNumber(2) + '.png',
baseUrl + 'hh/hh-' + generateRandomNumber(27) + '.png',
baseUrl + 'acc/acc-' + generateRandomNumber(18) + '.png'
];
// Loop through the image URLs and create image elements
for (var i = 0; i < imageUrls.length; i++) {
var image = document.createElement('img');
image.src = imageUrls[i];
image.style.position = 'absolute';
image.style.top = '0';
image.style.left = '0';
image.style.width = size;
image.style.height = size;
container.appendChild(image);
}
container.style.width = size;
container.style.height = size;
if (container.getAttribute("blacked") !== null) {
container.style.filter = "grayscale(100%)";
}
}
// Call the function and pass the ID of the target div
var containers = document.getElementsByTagName("rm");
var containerArray = Array.from(containers);
containerArray.forEach(function(container) {
stackImages(container);
});
}
window.addEventListener('DOMContentLoaded', () => {
main()
})
})()