修复Artalk 2.7.3更换函数造成的加载异常

+ 增加向下兼容
This commit is contained in:
HenryZeng 2024-01-09 00:46:07 +08:00
parent 9f6940cca9
commit 5c88a2813a
1 changed files with 25 additions and 4 deletions

View File

@ -11,13 +11,34 @@
countEl: '#ArtalkCount'
}, null))
function versionOld(ctx){
ctx.getCommentList().forEach(comment => {
const $content = comment.getRender().$content
btf.loadLightbox($content.querySelectorAll('img:not([atk-emoticon])'))
})
}
function version_2_7_3_WithUpper(ctx){
ctx.get('list').getCommentNodes().forEach(comment => {
const $content = comment .getRender().$content
btf.loadLightbox($content.querySelectorAll('img:not([atk-emoticon])'))
})
}
function versionCheck(ctx){
if(ctx.getCommentList != undefined){
// Artalk 版本小于于 2.7.3
versionOld(ctx);
}else{
version_2_7_3_WithUpper(ctx);
}
}
if (GLOBAL_CONFIG.lightbox === 'null') return
Artalk.use(ctx => {
ctx.on('list-loaded', () => {
ctx.getCommentList().forEach(comment => {
const $content = comment.getRender().$content
btf.loadLightbox($content.querySelectorAll('img:not([atk-emoticon])'))
})
versionCheck(ctx);
})
})
}