mirror of https://github.com/jkjoy/sunpeiwen.git
更新部分文章
This commit is contained in:
parent
9e92f8b3bc
commit
687ab3c751
|
@ -14,71 +14,25 @@ cover:
|
|||
|
||||
[给Memos添加Twikoo评论](/2023/507a5d86.html)
|
||||
|
||||
- 2023.10.23更新以适用于memos v0.16.1版本
|
||||
把'.resource-wrapper'替换为'.gap-2'
|
||||
|
||||
- 2023.10.17更新memos0.16版本
|
||||
|
||||
## 自定义脚本
|
||||
```
|
||||
// Artalk comments 2023.10.18更新
|
||||
// 适用于0.15以上版本
|
||||
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('.resource-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', '<div id="Comments"></div>');
|
||||
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();
|
||||
```
|
||||
把'.resource-wrapper'替换为'.memo-wrapper'
|
||||
|
||||
## 自定义样式
|
||||
隐藏评论数
|
||||
```
|
||||
.text-sm.text-gray-500.ml-1{display:none !important;}
|
||||
```
|
||||
|
||||
- 2023.9.26更新提醒: memos升级到0.15.1后版本,以下方法失效
|
||||
- 2023.9.26更新提醒:适用于 memos 0.15.1版本以下
|
||||
|
||||
## 自定义脚本
|
||||
|
||||
```
|
||||
// Artalk comments 适用于0.15以下版本
|
||||
// 用 JS 向页面中插入 JS
|
||||
function addArtalkJS() {
|
||||
var memosArtalk = document.createElement("script");
|
||||
|
|
|
@ -11,6 +11,48 @@ title: 给Memos添加Twikoo评论
|
|||
updated: '2023-6-13T13:53:48.150+8:0'
|
||||
cover:
|
||||
---
|
||||
代码来自于@[林木木](https://immmmm.com/memos-with-twikoo/)
|
||||
|
||||
2023.10.23更新脚本以适用于memos v0.16.1
|
||||
|
||||
## 自定义脚本
|
||||
```
|
||||
// Memos v0.16.1 单条页面插入 Twikoo 评论
|
||||
var twikooENV = 'https://你的.com/'
|
||||
function addTwikooJS() {
|
||||
var memosTwikoo = document.createElement("script");
|
||||
memosTwikoo.src = `https://cdn.staticfile.org/twikoo/1.6.22/twikoo.all.min.js`;
|
||||
var tws = document.getElementsByTagName("script")[0];
|
||||
tws.parentNode.insertBefore(memosTwikoo, tws);
|
||||
};
|
||||
function startTwikoo() {
|
||||
startTW = setInterval(function(){
|
||||
var nowHref = window.location.href;
|
||||
var twikooDom = document.querySelector('#twikoo') || '';
|
||||
if( nowHref.replace(/^.*\/(m)\/.*$/,'$1') == "m"){
|
||||
if(!twikooDom){
|
||||
addTwikooJS()
|
||||
setTimeout(function() {
|
||||
var memoTw = document.querySelector('.gap-2') || '';
|
||||
memoTw.insertAdjacentHTML('afterend', '<div id="mtcomment"></div>');
|
||||
twikoo.init({
|
||||
envId: twikooENV,
|
||||
el: '#mtcomment',
|
||||
path: nowHref.replace(/^.*=?(http.*\/m\/[0-9]+).*$/,'$1'),
|
||||
onCommentLoaded: function () {
|
||||
startTwikoo();
|
||||
}
|
||||
})
|
||||
}, 1500)
|
||||
}else{
|
||||
clearInterval(startTW)
|
||||
}
|
||||
}
|
||||
}, 2000)
|
||||
}
|
||||
startTwikoo();
|
||||
```
|
||||
|
||||
2023.10.17更新脚本
|
||||
## 自定义脚本
|
||||
适用于0.16版本
|
||||
|
@ -59,7 +101,6 @@ startTwikoo();
|
|||
|
||||
2023.9.26 更新.memos升级0.15.1版本后以下无法使用
|
||||
|
||||
代码来自于@[林木木](https://immmmm.com/memos-with-twikoo/)
|
||||
|
||||
## 自定义脚本
|
||||
|
||||
|
|
Loading…
Reference in New Issue