Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ybw2016v committed May 1, 2023
1 parent 2731a7a commit 8f074bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function dog_add_fy(eldog) {
const ctp = eldog.querySelector('div[style="container-type: inline-size;"]')
const ctix = ctp.getElementsByTagName('div')[0];
// console.log(ctix);
ctix.setAttribute("class", "fanyi-cont");
ctix.setAttribute("neko", "fanyi-cont");
const fyc = document.createElement("div");
fyc.setAttribute("class", "fanyi");
fyc.ct=0;
Expand All @@ -55,7 +55,7 @@ function dog_add_fy_old(eldog) {
dogbt.addEventListener('click', dog_fy);//绑定翻译函数
const ctdog=eldog.getElementsByClassName('content')[0];
const ydog = ctdog.getElementsByClassName('text')[0];
ydog.setAttribute("class", "text fanyi-cont");
ydog.setAttribute("neko", "text fanyi-cont");
const fyc = document.createElement("div");
fyc.setAttribute("class", "fanyi");
fyc.ct=0;
Expand All @@ -76,7 +76,7 @@ async function dog_fy() {
const dog_fy_el = ldog[0];
if (dog_fy_el.ct == 0) {
console.log('还没有翻译');
const hdog = pdog.getElementsByClassName('fanyi-cont')[0].innerText;
const hdog = pdog.querySelector('div[neko="fanyi-cont"]').innerText;
post_dog = { 'c': hdog, 't': lang_dog };
dog_fy_el.innerText = '正在翻译中……';
uiy = await fetch(ApiUrl, {
Expand All @@ -92,7 +92,8 @@ async function dog_fy() {
} else {
res_dog = '接口不对劲';
}
dog_fy_el.innerText = `\n${res_dog}`;
dog_fy_el.innerText = `${res_dog}`;
dog_fy_el.style.cssText=" margin-top: 1em; border: dashed 2px;border-radius: 10px;padding: 16px;";
dog_fy_el.ct = 1
this.childNodes[0].setAttribute("class", "ti ti-language-off");
this.style="color: red;";
Expand Down
10 changes: 5 additions & 5 deletions user.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var ApiUrl = 'https://test1-api.dogcraft.top/ts/';


console.log('Misskey Translate Script v2.0');
ApiUrl = 'https://test1-api.dogcraft.top/ts/';

var cat = localStorage.getItem('lang');
var vdog = localStorage.getItem('v');
Expand Down Expand Up @@ -48,7 +47,7 @@ var ApiUrl = 'https://test1-api.dogcraft.top/ts/';
const ctp = eldog.querySelector('div[style="container-type: inline-size;"]')
const ctix = ctp.getElementsByTagName('div')[0];
// console.log(ctix);
ctix.setAttribute("class", "fanyi-cont");
ctix.setAttribute("neko", "fanyi-cont");
const fyc = document.createElement("div");
fyc.setAttribute("class", "fanyi");
fyc.ct = 0;
Expand All @@ -72,7 +71,7 @@ var ApiUrl = 'https://test1-api.dogcraft.top/ts/';
dogbt.addEventListener('click', dog_fy);//绑定翻译函数
const ctdog = eldog.getElementsByClassName('content')[0];
const ydog = ctdog.getElementsByClassName('text')[0];
ydog.setAttribute("class", "text fanyi-cont");
ydog.setAttribute("neko", "text fanyi-cont");
const fyc = document.createElement("div");
fyc.setAttribute("class", "fanyi");
fyc.ct = 0;
Expand All @@ -93,7 +92,7 @@ var ApiUrl = 'https://test1-api.dogcraft.top/ts/';
const dog_fy_el = ldog[0];
if (dog_fy_el.ct == 0) {
console.log('还没有翻译');
const hdog = pdog.getElementsByClassName('fanyi-cont')[0].innerText;
const hdog = pdog.querySelector('div[neko="fanyi-cont"]').innerText;
post_dog = { 'c': hdog, 't': lang_dog };
dog_fy_el.innerText = '正在翻译中……';
uiy = await fetch(ApiUrl, {
Expand All @@ -109,7 +108,8 @@ var ApiUrl = 'https://test1-api.dogcraft.top/ts/';
} else {
res_dog = '接口不对劲';
}
dog_fy_el.innerText = `\n${res_dog}`;
dog_fy_el.innerText = `${res_dog}`;
dog_fy_el.style.cssText = " margin-top: 1em; border: dashed 2px;border-radius: 10px;padding: 16px;";
dog_fy_el.ct = 1
this.childNodes[0].setAttribute("class", "ti ti-language-off");
this.style = "color: red;";
Expand Down

0 comments on commit 8f074bf

Please sign in to comment.