From 0b99f48e7de18fdc5568744efc161784ad25a351 Mon Sep 17 00:00:00 2001 From: XPoet Date: Tue, 26 Jan 2021 09:34:31 +0800 Subject: [PATCH] perf: optimize Valine comment plugin --- layout/_partial/comment/valine.ejs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/layout/_partial/comment/valine.ejs b/layout/_partial/comment/valine.ejs index 1bfe114..817f478 100755 --- a/layout/_partial/comment/valine.ejs +++ b/layout/_partial/comment/valine.ejs @@ -35,14 +35,15 @@ const getValineDomTimer = setInterval(() => { const vcards = document.querySelectorAll('#vcomments .vcards .vcard'); if (vcards.length > 0) { - let author = '<%= theme.base_info.author || config.author %>'; - author && (author = author.toLocaleLowerCase()); - for (let vcard of vcards) { - const vnick = vcard.querySelector('.vhead .vnick'); - if (vnick.innerHTML.toLocaleLowerCase() === author) { - vnick.innerHTML = `${author} ${getAuthor(KEEP.hexo_config.language)}` + if (author) { + for (let vcard of vcards) { + const vnick_dom = vcard.querySelector('.vhead .vnick'); + const vnick = vnick_dom.innerHTML; + if (vnick === author) { + vnick_dom.innerHTML = `${vnick} ${getAuthor(KEEP.hexo_config.language)}` + } } } clearInterval(getValineDomTimer);