Git Product home page Git Product logo

mkts's Introduction

mkts

A Translation Script for Misskey Note | 一个用于misskey贴文的翻译脚本

后端基于python的UlionTse/translators多后端翻译的库,前端是手写的JavaScript,适用于misskey近期版本。由于未对misskey程序作任何更改,只要misskey的前端结构不发生巨大的变化,该脚本将一直保持可用。

效果图:

效果图

使用方式

下面两种方式任选一种即可。强烈建议自建后端API服务。建好api后端将脚本中的ApiUrl = 'https://test1-api.dogcraft.top/ts/';url换成自建的api地址即可。

  • 浏览器脚本(Tampermonkey)

greasyfork找到mkts,按照提示安装用户端脚本,安装成功后在设置里面的匹配规则里加入自己所在的实例url即可。

  • nginx直接插入

前一种方式仅适用与在可以有Tampermonkey的设备上,某些移动端浏览器并没有这个功能,可以通过nginx的 ngx_http_sub_module 模块在html的头部插入JavaScript脚本,具体可以见这里

首先把server放置在静态文件服务器里(github、nginx、cdn等)然后修改misskey的nginx配置文件,在location下面添加一行sub_filter '<script>' '<script src="https://url/to/your/server.js"></script><script>';

完整的location应该是这样的

location / {
  sub_filter  '<script>'  '<script src="https://www.dogcraft.top/misskey.js"></script><script>';
      proxy_pass http://127.0.0.1:3003;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto https;
      proxy_set_header Accept-Encoding "";
      proxy_http_version 1.1;
      proxy_redirect off;

      # For WebSocket
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $connection_upgrade;

      # Cache settings
      proxy_cache cache1;
      proxy_cache_lock on;
      proxy_cache_use_stale updating;
      add_header X-Cache $upstream_cache_status;
  }

刷新等生效就可以了。

后端翻译API

后端主要是用flask_restful与translators拼接起来,并用redis做缓存。

使用时可用参照flask的文档中的标准部署方式,并把redis的配置url改成自己的就可以了。

如果没有flask等python框架的使用经验,推荐采用docker方式。

docker方式

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

git clone https://github.com/ybw2016v/mkts.git
git pull
docker-compose up -d

即可。

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

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

ChangeLog

2021.03.14 1.0版本,开始支持misskey的chatui

2021.10.17 1.3版本,支持misskey v12.93.0

2021.11.11 1.4版本,支持misskey v12.95.0

2021.12.04 1.5版本,支持misskey v12.98.0

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

2023.06.08 2.3版本,支持misskey v13.13.1

mkts's People

Contributors

ybw2016v avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

tennousuathena

mkts's Issues

翻译无法使用

脚本还是2021年的,现在的misskey版本已经无法使用了,可以麻烦作者更新一下吗。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.