Skip to content

Commit

Permalink
2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ybw2016v committed Jun 8, 2023
1 parent d802ffe commit 05a0ca7
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 33 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ location / {

docker方式很简单,首先要有docker全家桶。

```
``` bash
git clone https://github.com/ybw2016v/mkts.git
git pull
docker-compose up -d
Expand All @@ -72,12 +72,13 @@ docker-compose up -d

还可以与misskey共用一个nginx配置,在misskey的配置文件内部添加一个location配置即可。

```
``` nginx
location /translate/ {
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:5002;
}
```

## ChangeLog

2021.03.14 1.0版本,开始支持misskey的`chatui`
Expand All @@ -88,4 +89,6 @@ location /translate/ {

2021.12.04 1.5版本,支持misskey `v12.98.0`

2023.04.29 2.0版本,支持misskey `v13.11.3`,不支持更早版本。
2023.04.29 2.0版本,支持misskey `v13.11.3`,不支持更早版本。

2023.06.08 2.3版本,支持misskey `v13.13.1`
40 changes: 24 additions & 16 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
console.log('Misskey Translate Script v2.0');
console.log('Misskey Translate Script v2.3');
ApiUrl = 'https://test1-api.dogcraft.top/ts/';

var cat = localStorage.getItem('lang');
Expand All @@ -13,28 +13,36 @@ lang_dog = lang_dog.substr(0, 2);

function dog_add_fy(eldog) {
//添加翻译按钮、区域以及绑定点击事件
if (eldog.className=='article') {
if (eldog.className == 'article') {
dog_add_fy_old(eldog);
return;
}
if (eldog.fanyi == 1) {
// console.log('已经添加过了,重复添加。')
} else {
const dogbt=document.createElement("button");
const btclass=Array.from(eldog.getElementsByTagName("footer")).slice(-1)[0].childNodes[0].getAttribute("class")
dogbt.setAttribute("class",btclass);
const nicon = document.createElement("i");
nicon.setAttribute("class", "ti ti-language");
const dogbt = document.createElement('button');
const btclass = Array.from(eldog.getElementsByTagName('footer')).slice(- 1)[0].childNodes[2].getAttribute('class')
dogbt.setAttribute('class', btclass);
const nicon = document.createElement('i');
nicon.setAttribute('class', 'ti ti-language');
dogbt.appendChild(nicon);
Array.from(eldog.getElementsByTagName("footer")).slice(-1)[0].appendChild(dogbt);
dogbt.addEventListener('click', dog_fy);//绑定翻译函数
const ctp = eldog.querySelector('div[style="container-type: inline-size;"]')
const ctix = ctp.getElementsByTagName('div')[0];
// console.log(ctix);
ctix.setAttribute("neko", "fanyi-cont");
const fyc = document.createElement("div");
fyc.setAttribute("class", "fanyi");
fyc.ct=0;
Array.from(eldog.getElementsByTagName('footer')).slice(- 1)[0].appendChild(dogbt);
dogbt.addEventListener('click', dog_fy); //绑定翻译函数
const qhi = eldog.querySelector('div[style="container-type: inline-size;"]');
var ctp;
var ctix;
if (qhi != null) {
ctp = qhi;
ctix = qhi.getElementsByTagName('div')[0];
} else {
const hui = eldog.childNodes[1].querySelector('span[style="white-space: pre-wrap;"]');
ctp = hui.parentElement.parentElement;
ctix = hui.parentElement;
}
ctix.setAttribute('neko', 'fanyi-cont');
const fyc = document.createElement('div');
fyc.setAttribute('class', 'fanyi');
fyc.ct = 0;
ctp.appendChild(fyc);
eldog.fanyi = 1;
}
Expand Down
36 changes: 22 additions & 14 deletions user.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var ApiUrl = 'https://test1-api.dogcraft.top/ts/';
'use strict';


console.log('Misskey Translate Script v2.0');
console.log('Misskey Translate Script v2.3');

var cat = localStorage.getItem('lang');
var vdog = localStorage.getItem('v');
Expand All @@ -36,20 +36,28 @@ var ApiUrl = 'https://test1-api.dogcraft.top/ts/';
if (eldog.fanyi == 1) {
// console.log('已经添加过了,重复添加。')
} else {
const dogbt = document.createElement("button");
const btclass = Array.from(eldog.getElementsByTagName("footer")).slice(-1)[0].childNodes[0].getAttribute("class")
dogbt.setAttribute("class", btclass);
const nicon = document.createElement("i");
nicon.setAttribute("class", "ti ti-language");
const dogbt = document.createElement('button');
const btclass = Array.from(eldog.getElementsByTagName('footer')).slice(- 1)[0].childNodes[2].getAttribute('class')
dogbt.setAttribute('class', btclass);
const nicon = document.createElement('i');
nicon.setAttribute('class', 'ti ti-language');
dogbt.appendChild(nicon);
Array.from(eldog.getElementsByTagName("footer")).slice(-1)[0].appendChild(dogbt);
dogbt.addEventListener('click', dog_fy);//绑定翻译函数
const ctp = eldog.querySelector('div[style="container-type: inline-size;"]')
const ctix = ctp.getElementsByTagName('div')[0];
// console.log(ctix);
ctix.setAttribute("neko", "fanyi-cont");
const fyc = document.createElement("div");
fyc.setAttribute("class", "fanyi");
Array.from(eldog.getElementsByTagName('footer')).slice(- 1)[0].appendChild(dogbt);
dogbt.addEventListener('click', dog_fy); //绑定翻译函数
const qhi = eldog.querySelector('div[style="container-type: inline-size;"]');
var ctp;
var ctix;
if (qhi != null) {
ctp = qhi;
ctix = qhi.getElementsByTagName('div')[0];
} else {
const hui = eldog.childNodes[1].querySelector('span[style="white-space: pre-wrap;"]');
ctp = hui.parentElement.parentElement;
ctix = hui.parentElement;
}
ctix.setAttribute('neko', 'fanyi-cont');
const fyc = document.createElement('div');
fyc.setAttribute('class', 'fanyi');
fyc.ct = 0;
ctp.appendChild(fyc);
eldog.fanyi = 1;
Expand Down

0 comments on commit 05a0ca7

Please sign in to comment.