diff --git a/templates/assets/js/halo.js b/templates/assets/js/halo.js index 2ea13c1e..b93e840f 100644 --- a/templates/assets/js/halo.js +++ b/templates/assets/js/halo.js @@ -270,9 +270,6 @@ let halo = { e.batchSend(t, !0); else { let n = []; - function a(e) { - return e = (e = (e = (e = (e = e.replace(/<\/*br>|[\s\uFEFF\xA0]+/g, "")).replace(//g, "[图片]")).replace(/.*?<\/a>/g, "[链接]")).replace(/.*?<\/pre>/g, "[代码块]")).replace(/<.*?>/g, "") - } if(GLOBAL_CONFIG.source.comments.use == 'Twikoo'){ fetch(GLOBAL_CONFIG.source.twikoo.twikooUrl, { method: "POST", @@ -290,7 +287,7 @@ let halo = { null == e.avatar && (e.avatar = "https://cravatar.cn/avatar/d615d5793929e8c7d70eab5f00f7f5f1?d=mp"), n.push({ avatar: e.avatar, - content: e.nick + ":" + a(e.comment), + content: e.nick + ":" + btf.changeContent(e.comment), href: e.url + '#' + e.id }) @@ -319,7 +316,7 @@ let halo = { t.forEach((e=>{ n.push({ avatar: 'https://cravatar.cn/avatar/' + e.email_encrypted + '?d=mp&s=240', - content: e.nick + ":" + a(e.content_marked), + content: e.nick + ":" + btf.changeContent(e.content_marked), href: e.page_url + '#atk-comment-' + e.id }) @@ -338,7 +335,7 @@ let halo = { }).then(({ comments }) => { const walineArray = comments.map(e => { return { - 'content': e.nick + ":" + a(e.comment), + 'content': e.nick + ":" + btf.changeContent(e.comment), 'avatar': e.avatar, 'href': e.url + '#' + e.objectId, } diff --git a/templates/assets/js/heo.js b/templates/assets/js/heo.js index 887b8fdd..0edeeeea 100644 --- a/templates/assets/js/heo.js +++ b/templates/assets/js/heo.js @@ -22,6 +22,12 @@ var heo = { // 首页bb initIndexEssay: function() { if (document.querySelector("#bber-talk")) + $(".swiper-wrapper .swiper-slide").each(function () { + var text = $(this)[0].innerText; + if (text != 'undefined') { + $(this).text(btf.changeContent(text)); + } + }) new Swiper(".swiper-container",{ direction: "vertical", loop: !0, diff --git a/templates/assets/js/utils.js b/templates/assets/js/utils.js index b2356358..4c4de61e 100644 --- a/templates/assets/js/utils.js +++ b/templates/assets/js/utils.js @@ -331,6 +331,23 @@ var btf = { } return actualTop + }, + //过滤标签 + changeContent: (content,length = null)=>{ + if (content === '') return content + + content = content.replace(/]+>/ig, '[图片]') // replace image link + content = content.replace(/]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[链接]') // replace url + content = content.replace(/
.*?<\/pre>/gi, '[代码]') // replace code
+        content = content.replace(/<[^>]+>/g, "") // remove html tag
+
+        if (length!=null){
+            if (content.length > length) {
+                content = content.substring(0, length) + '...'
+            }
+        }
+
+        return content
     }
 
 }
diff --git a/templates/modules/comment/Artalk.html b/templates/modules/comment/Artalk.html
index 66d704bc..db982857 100644
--- a/templates/modules/comment/Artalk.html
+++ b/templates/modules/comment/Artalk.html
@@ -10,19 +10,6 @@
     
     
 
-    
-
     
 
     
diff --git a/templates/modules/layouts/layout.html b/templates/modules/layouts/layout.html
index db6df69e..964132f7 100644
--- a/templates/modules/layouts/layout.html
+++ b/templates/modules/layouts/layout.html
@@ -56,6 +56,7 @@
 
 
+