Update EditUsers.plugin.js

This commit is contained in:
Mirco Wittrien 2019-07-18 15:09:53 +02:00
parent 892aa49696
commit 34518b8be9
1 changed files with 5 additions and 9 deletions

View File

@ -907,7 +907,7 @@ class EditUsers {
if (avatar.tagName == "IMG") avatar.setAttribute("src", data.removeIcon ? null : (data.url || BDFDB.getUserAvatar(info.id))); if (avatar.tagName == "IMG") avatar.setAttribute("src", data.removeIcon ? null : (data.url || BDFDB.getUserAvatar(info.id)));
else { else {
let url = data.removeIcon ? null : ("url(" + (data.url || BDFDB.getUserAvatar(info.id)) + ")"); let url = data.removeIcon ? null : ("url(" + (data.url || BDFDB.getUserAvatar(info.id)) + ")");
if (url && BDFDB.containsClass(avatar, BDFDB.disCN.avatarmaskprofile) && url.search(/discordapp\.com\/avatars\/[0-9]*\/a_/) > -1) url = url.replace(".webp)", ".gif)"); if (url && BDFDB.getParentEle(BDFDB.dotCN.userprofile, avatar) && url.search(/discordapp\.com\/avatars\/[0-9]*\/a_/) > -1) url = url.replace(".webp)", ".gif)");
avatar.style.setProperty("background-image", url); avatar.style.setProperty("background-image", url);
if (data.url && !data.removeIcon) { if (data.url && !data.removeIcon) {
avatar.style.setProperty("background-position", "center"); avatar.style.setProperty("background-position", "center");
@ -916,14 +916,10 @@ class EditUsers {
} }
if (data.url || data.removeIcon) { if (data.url || data.removeIcon) {
avatar.setAttribute("changed-by-editusers", true); avatar.setAttribute("changed-by-editusers", true);
avatar.EditUsersChangeObserver = new MutationObserver((changes, _) => { avatar.EditUsersChangeObserver = new MutationObserver((changes, _) => {changes.forEach((change, i) => {
changes.forEach( avatar.EditUsersChangeObserver.disconnect();
(change, i) => { this.changeAvatar(info, avatar);
avatar.EditUsersChangeObserver.disconnect(); });});
this.changeAvatar(info, avatar);
}
);
});
avatar.EditUsersChangeObserver.observe(avatar, {attributes:true}); avatar.EditUsersChangeObserver.observe(avatar, {attributes:true});
} }
else avatar.removeAttribute("changed-by-editusers"); else avatar.removeAttribute("changed-by-editusers");