给Memos添加Artalk评论

上文提到

给 Memos 添加 Twikoo 评论

2023.10.23 更新以适用于 memos v0.16.1 版本
把 '.resource-wrapper' 替换为 '.gap-2'

2023.10.17 更新 memos0.16 版本

自定义脚本

把 '.resource-wrapper' 替换为 '.memo-wrapper'

自定义样式

隐藏评论数

Copy
.text-sm.text-gray-500.ml-1{display:none !important;}

2023.9.26 更新提醒：适用于 memos 0.15.1 版本以下

自定义脚本

Copy
// 用 JS 向页面中插入 JS
function addArtalkJS() {
var memosArtalk = document.createElement("script");
memosArtalk.src = `https://unpkg.com/artalk/dist/Artalk.js`;
var artakPos = document.getElementsByTagName("script")[0];
artakPos.parentNode.insertBefore(memosArtalk, artakPos);
};
// div
function startArtalk() {
start = setInterval(function(){
var artalkDom = document.getElementById('Comments') || '';
var memoAt = document.querySelector('.memo-wrapper') || '';
var memoLoading = document.querySelector('.action-button-container') || '';
var memoLoadingA = document.querySelector('.action-button-container a') || '';
if(window.location.href.replace(/^.*\/(m)\/.*$/,'$1') == "m" && memoLoadingA){
memoLoading.innerHTML = "评论加载中……"
}
if(window.location.href.replace(/^.*\/(m)\/.*$/,'$1') == "m" && !artalkDom){
addArtalkJS()
if(memoAt){
clearInterval(start)
var cssLink = document.createElement("link");
cssLink.rel = "stylesheet";
cssLink.href = "https://unpkg.com/artalk/dist/Artalk.css";
document.head.appendChild(cssLink);
memoAt.insertAdjacentHTML('afterend', ' ');
setTimeout(function() {
Artalk.init({
el: '#Comments',
pageKey: location.pathname,
pageTitle: document.title,
server: 'https://artalk.loliko.cn',
site: 'memos',
darkMode: 'auto'
});
Artalk.on('list-loaded', function() {
// console.log('评论加载完成');
memoLoading.innerHTML = ''
startArtalk();
});
}, 1000);
}
}
//console.log(window.location.href);
}, 1000)
}
startArtalk();

自定义样式

Copy
a.time-text:after { content: ' 评论 💬 '; }
.atk-main-editor { margin-top: 20px; }