Commit 32c9f8e1 authored by absturztaube's avatar absturztaube

improve performance?

parent 15d97ae4
......@@ -102,13 +102,18 @@ function PleromaCat (handle) {
return "USER____" + this.handle.replace(/@/g, "_AT_").replace(/\./g, "_");
},
function makeCat () {
var posts = document.querySelectorAll("." + this.getClassName());
this.makeCatByClassName("user-info");
this.makeCatByClassName("basic-user-card", "basic-user-card-screen-name");
for (const currentPost of posts) {
this.makeCatByElement(currentPost);
this.nyaByPost(currentPost);
function makeCat (element) {
if (!element) {
element = document;
}
if (element.querySelectorAll) {
var posts = element.querySelectorAll("." + this.getClassName());
this.makeCatByClassName("user-info");
this.makeCatByClassName("basic-user-card", "basic-user-card-screen-name");
for (const currentPost of posts) {
this.makeCatByElement(currentPost);
this.nyaByPost(currentPost);
}
}
},
......@@ -258,7 +263,9 @@ function PleromaModCatify () {
mutation.target.classList.remove("cat");
}
this.detectCats();
this.catify();
for (const element of mutation.addedNodes) {
this.catify(element);
}
},
function onReady () {
......@@ -333,9 +340,9 @@ function PleromaModCatify () {
this.detectCatsByClassName("basic-user-card", "basic-user-card-user-name-value", "basic-user-card-screen-name");
},
function catify () {
function catify (element) {
for (const catKey in this.cats) {
this.cats[catKey].makeCat();
this.cats[catKey].makeCat(element);
}
}
].forEach((fn) => { PleromaModCatify.prototype[fn.name] = fn; });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment