把 激战2 Metabattle, Snowrows, discretize 等攻略网站上面的英文技能描述替换成中文,方便美服/欧服玩家参考。
当前为
// ==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.5
// @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/*
// @match https://guildjen.com/*
// @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 后的技能没有翻译
// 4. discretize 网站链接跳转失效
console.log('GW2 Skill Zh-CN 激战2技能翻译插件 by Saber Lily 已启用!')
document.GW2A_EMBED_OPTIONS = {
lang: 'zh'
};
window.onload = function() {
document.body.addEventListener('mousedown', ev => {
const a = event.target.closest('a');
if (a) {
if (a.getAttribute('href').toString().includes('guildwars2.com/wiki/Special:Search/')) {
const b = a.parentNode.parentNode.parentNode;
if (b) {
a.href = 'https://wiki.guildwars2.com/wiki/Special:RunQuery/Search_by_id?title=Special%3ARunQuery%2FSearch_by_id&pfRunQueryFormName=Search+by+id&Search+by+id%5Bid%5D=' + b.getAttribute('data-armory-ids').toString();
};
}
}
});
}
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)
}
})