-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrsvAvatarChange.js
More file actions
32 lines (26 loc) · 935 Bytes
/
crsvAvatarChange.js
File metadata and controls
32 lines (26 loc) · 935 Bytes
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
// ==UserScript==
// @name Craftserve Website Avatar Change
// @namespace https://greasyfork.org/pl/users/416294-patrykcholewa
// @version 1.0.2
// @description Changes Steve emoji of user avatars to premium nick ones
// @author PatrykCholewa
// @include http://*.csrv.pl/*
// @grant none
// ==/UserScript==
(function() {
function changeAvatars() {
var ul = document.querySelector(".lista-top+ul");
var imgs = ul.querySelectorAll(".gracz > img");
for (var img of imgs) {
var currentUrl = img.getAttribute("src");
var urlParts = currentUrl.split("/");
var nick = urlParts[urlParts.length - 2];
if (nick.match(/^[0-9a-zA-Z_-]+$/)) {
var newUrl = "https://minotar.net/helm/" + nick;
img.setAttribute("src", newUrl);
}
}
}
var observer = new MutationObserver(changeAvatars);
observer.observe(document.querySelector('.lista-top+ul'), {childList: true});
})()