GW2 Skill Zh-CN 激战2 技能翻译插件 by Saber Lily

把 激战2 Metabattle, Snowrows, discretize 等攻略网站上面的英文技能描述替换成中文,方便美服/欧服玩家参考。

目前為 2020-09-05 提交的版本,檢視 最新版本

// ==UserScript==
// @name         GW2 Skill Zh-CN 激战2 技能翻译插件 by Saber Lily
// @name:en      GW2 Skill Zh-CN GW2ARMORY Translator by Saber Lily
// @namespace    https://greasyfork.org/zh-CN/scripts/377052
// @version      1.2
// @description  把 激战2 Metabattle, Snowrows, discretize 等攻略网站上面的英文技能描述替换成中文,方便美服/欧服玩家参考。
// @description:en    Show Chinese GW2 Skill Translation which are on Metabattle, Snowrows, discretize and so on.
// @icon         https://wiki.guildwars2.com/favicon.ico
// @author       Saber Lily 莉莉哩哩 Gay哩Gay气
// @run-at       document-start
// @require      https://unpkg.com/ajax-hook@2/dist/ajaxhook.min.js
// @match        https://metabattle.com/wiki/*
// @match        https://snowcrows.com/*
// @match        https://lucky-noobs.com/*
// @match        https://discretize.eu/*
// @match        https://www.godsofpvp.net/*
// @match        https://fast.farming-community.eu/*
// @grant        none
// @license      GPL-v3
// ==/UserScript==

// 作者简介
// Saber Lily.1960 Current in WSR EU Server
// 莉莉哩哩 Gay哩Gay气,一个天天划水的休闲 激战2 欧服玩家。
// 如果你觉得该脚本对你有所帮助,欢迎赞助我!

// 脚本原理
// 1. 通过 GW2A_EMBED_OPTIONS 选项,调整及修改 GW2ARMORY 的请求参数
// 2. 通过劫持 Metabattle, Snowrows, discretize 的 Ajax Api 请求,篡改其访问地址,使其返回中文数据。

// 版权申明
// 本脚本为 Saber Lily.1960 原创,未经作者授权禁止转载,禁止转载范围包括但不仅限于:贴吧、NGA论坛等。

// 已知 Bug,不会修复
// 1. Metabattle 没有食物、扳手等的翻译
// 2. Metabattle 武器组、法印及部分武器技能没有翻译
// 3. 燃火 F1、F2 及 F3 后的技能没有翻译

console.log('GW2 Skill Zh-CN 激战2技能翻译插件 by Saber Lily 已启用!')

document.GW2A_EMBED_OPTIONS = {
    lang: "zh"
};

ah.proxy({
    onRequest: (config, handler) => {
        if (config.url.startsWith('https://api.guildwars2.com/')) {
            config.url = config.url.replace('&lang=en', '&lang=zh');
        }
        handler.next(config);
    },
    onError: (err, handler) => {
        handler.next(err)
    },
    onResponse: (response, handler) => {
        handler.next(response)
    }
})