惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
博客园 - 司徒正美
I
InfoQ
宝玉的分享
宝玉的分享
G
Google Developers Blog
J
Java Code Geeks
Martin Fowler
Martin Fowler
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
罗磊的独立博客
腾讯CDC
F
Fortinet All Blogs
A
About on SuperTechFans
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
B
Blog RSS Feed
博客园 - 聂微东
D
DataBreaches.Net
Hugging Face - Blog
Hugging Face - Blog
The Cloudflare Blog
L
LangChain Blog
Microsoft Azure Blog
Microsoft Azure Blog
aimingoo的专栏
aimingoo的专栏

遐说

2026第一场日出日落-黄山 [徒步]宁波九龙爱心线 [徒步]仙居公盂徒步+丽人谷溯溪(多图) 文献引用批量标注蓝色-Zotero/EndNote [出差]内蒙草原风光 [徒步]浙东小九寨 [徒步]西湖小猫线 微软Office365家庭版拼车5年180 2024浏阳跨年烟火 一路向北-广西 落日余晖——武汉东湖 博士论文盲审通过 青海出差 我开盒了我自己 hexo-butterfly+artalk无法显示文章PV浏览次数 记某站字体混淆解析方案 记第一次进藏 2024川西大环线 Python读取NetCDF文件-裁剪&计算 2024武汉东湖樱花园 zotero批量修改条目语言解决”等”和”et al”混排问题 torch_geometric_temporal安装报错找不到to_dense_adj 武汉冻雨&乡村春节 云南镇雄县凉水村滑坡:卫星影像解析 博客聚合平台RSS订阅-BlogFinder&博友圈&十年之约 腾讯云CDN正式取消免费10G流量包 2023跨年闲逛武汉 观感|小米SU7技术发布会 【留痕】解密微信聊天记录工具:年度报告、聊天导出一键搞定! 小米电脑管家 vs. MIUI+: 手机与PC协同体验大比拼!
Memos添加utterances评论区
Dorad · 2023-09-09 · via 遐说

发表于|更新于|博客工具

|总字数:751|阅读时长:3分钟|浏览量:|

目前 Memos 官方已支持评论功能,无需再另外配置!

¶更新日志

  • 2023.12.19: 更新适配v0.18.0

  • 2023.09.19: 更新适配v0.15.0

  • 2023.09.09: 初版版本,适配v0.14.4

由于 Twitter 改版,RSSHub无法抓取,以至于之前的瞬间都无法同步过来。

故前些天也整上了Memos,真香。今天折腾一下,给Memos添上评论。

先试了Waline,但略复杂,想和博客共用一套,发现不太行,遂转向utterances评论系统。

¶快速配置

  • GitHub新建一个新的公开仓库。

  • 打开Memos,进入设置→系统,配置自定义CSS自定义脚本,并保存。

配置页面

¶自定义脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const repo = "Doradx/comments";
const issueTerm = "pathname";
const theme = "github-light";

var commentsLoaded = false;
function addUtterances() {
if (document.querySelectorAll('script[label="utterances"]').length > 0) {
console.log("Remove Utterances.");
document
.querySelectorAll('script[label="utterances"]')
.forEach((e) => e.remove());
}
console.log("start to init utterances.");
var js = document.createElement("script");
js.src = "https://utteranc.es/client.js";
js.setAttribute("repo", repo);
js.setAttribute("issue-term", issueTerm);
js.setAttribute("theme", theme);
js.setAttribute("crossorigin", "anonymous");
js.setAttribute("async", true);
js.setAttribute("label", "utterances");
const main = document.querySelector("div.memo-content-wrapper").parentNode
.parentNode;
main.nextElementSibling.hidden = true;
if (main == null || main.childElementCount == 0) {
console.error("main is null");
return false;
}
main.appendChild(js);
return true;
}
var timer = setTimeout(checkMemosPage, 50);
function checkMemosPage() {
if (window.location.href.indexOf("/m/") > 0 && !commentsLoaded) {
console.log("Memos page loaded.");
if (addUtterances()) {
commentsLoaded = true;
console.log("Utterances added.");
} else {
console.error("Failed to add utterances.");
}
return;
}
if (
window.location.href.indexOf("/u/") > 0 ||
window.location.pathname === "/"
) {
addCommentBtn();
console.log("Personal page.");
return;
}
}
var observer = new MutationObserver(function (mutations) {
if (document.querySelectorAll("div.utterances").length > 0) {
return;
} else {
clearTimeout(timer);
timer = setTimeout(checkMemosPage, 100);
}
});
observer.observe(document.body, { childList: true, subtree: true });
function addCommentBtn() {
console.log("Start to add comment btn.");
var memosDivList = document.querySelectorAll("div.memo-wrapper");
if (memosDivList == null) {
return false;
}
console.log(memosDivList);
memosDivList.forEach((div) => {
if (
div.querySelector(".moments-comments-button") != null ||
div.children.length == 0
) {
return;
}
const memos_id = div.classList.item(2).split("-")[1];
var btn = document.createElement("div");
btn.className = "moments-comments-button";
btn.style = "align-self:end;padding-right:10px;padding-top:10px;";
btn.innerHTML = `<a href="/m/${memos_id}"target="_blank">评论💬</a>`;
div.appendChild(btn);
console.log("add btn for " + memos_id);
});
}

仅需将上述脚本的repo参数改为自己的公开仓库即可!

¶效果

评论区效果

¶参考

版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 遐说

请喝果茶

  • Wechat

    Wechat

  • Alipay

    Alipay