Translate 3rdguide

Automated version of honkai-guide.web.app's translation for 3rdguide's website

Od 01.07.2021.. Pogledajte najnovija verzija.

// ==UserScript==
// @name         Translate 3rdguide
// @namespace    Translate 3rdguide
// @version      0.2
// @description  Automated version of honkai-guide.web.app's translation for 3rdguide's website
// @author       honkai-guide.web.app
// @match        https://www.3rdguide.com/*
// @grant        none
// ==/UserScript==

(function() {
	'use strict';
	/* globals $ */

	// Allow new tab opening of team links
	// https://honkai-guide.web.app/calc/calc.html#/
	// Doesn't allow middle click on FF, mouseup to get around isn't possible because of popup detection,
	// alternative is to just replace div->a in each td but that messes up layout on 2nd col. Meh.
	$('#ct_det tbody').off().on('click', 'tr', function() {
		const urlstr = $(this).find('.tgcol0').data('url');
		if (urlstr != undefined) window.open(urlstr, '_blank');
	});

	// Translations
	const
	tls = {
		// Misc
		'记忆战场':'Memorial Arena',
		'超弦空间':'Superstring',
		'战区:': 'Bracket',
		'终极战区': 'Exalted',
		'高级战区': 'Masters',
		'强敌:': 'Bosses',
		'女武神:': 'Valkyries',
		'阵容':'Line-up',
		'得分':'Score',
		'造价':'Cost',
		'操作难度':'Difficulty',
		'好评数':'Likes',
		'创建时间':'Date',
		'扰动幅度':'Disturbance',
		'红莲':'Red Lotus',
		'寂灭':'Nirvana',
		'苦痛':'Agony',
		'原罪':'Sinful',
		'禁忌':'Forbidden',
		'段位:':'Rank',
		'天气:':'Weather',
		'区域:':'Area',
		'边缘区':'Fringe   ',
		'密集区':'Intensive',
		'高危区':'Perilous ',
		'特异区':'Singular ',
		'恐雷':'Lighning',
		'怯火':'Fire',
		'惧冰':'Ice',
		'量子':'Quantum',
		'畏血':'Physical',
		'狙击':'Ranged',
		'天敌':'Counter',
		'燃素':'Ignited',
		'雷劫':'War?',
		'战意':'Bloodthirsty',
		'机械':'Mecha',
		'异能':'Psychic',
		'生物':'Bio',
		'机械、生物':'Mecha & Bio',
		'异能、生物':'Psychic & Bio',
		'生物、机械':'Bio & Mecha',

		// Bosses
		'托纳提乌·噬日之影':'Tonatiuh',
		'托纳提乌-噬日之影':'Tonatiuh',
		'祸斗':'Huodou',
		'吼姆王':'Homo King',
		'绯狱丸':'Hellmaru',
		'海姆达尔':'Heimdall',
		'湮灭沉灵':'Doom',
		'教父军团':'Padrino Legion',
		'特里波卡':'Mexicatl',
		'贝纳勒斯':'Benares',
		'姬麟·黑':'DXY',
		'MHT-3和平使者':'MHT-3 Pax',
		'MHT-3 和平使者':'MHT-3 Pax',
		'阿湿波':'Assaka',
		'地藏御魂':'Jizo Mitama',
		'赫菲斯托斯':'Hephaestus ',
		'帕凡提':'Parvati',
		'被诅咒的英魂':'Cursed Soul',
		'科亚特尔-复生之影':'Couatl',
		'八重霞':'Kasumi',
		'陨冰之律者':'Rimestar',
		'虚树神骸-虚无主义':'Nihilus Husk',
		'深渊终极区':'Quantum Emperor',
		'虚数神骸-虚无主义II':'Nihilism Husk II',
		'神机-海姆达尔':'Heimdall',
		'迦尼萨':'Ganesha',
		'昆巴卡纳':'Kumbhakarna',
		'特里波卡-混沌之影':'Frost Honkai',
		'娑婆 阿湿波':'Assaka',
		'和平使者':'MHT-3',
		'吼姆魔术师':'Homu King',
		'奔狼的领主':'Andrius',

		// Valkyries
		'符华':'Fu Hua',
		'识之律者':'Herrscher of Sentience',
		'云墨丹心':'Azure Empyrea',
		'雾都迅羽':'Hawk of the Fog',
		'白夜执事':'Night Squire',
		'炽翎':'Phoenix',
		'影骑士·月轮':'Shadow Knight',
		'女武神·迅羽':'Valkyrie Accipiter',

		'明日香':'Asuka',

		'八重樱':'Yae',
		'夜隐重霞':'Darkbolt Jonin',
		'真炎幸魂':'Flame Sakitama',
		'逆神巫女':'Gyakushinn Miko',
		'御神装·勿忘':'Goushinnso Memento',

		'希儿·芙乐艾':'Seele',
		'魇夜星渊':'Starchasm Nyx',
		'彼岸双生':'Stygian Nymph',
		'幻海梦蝶':'Swallowtail Phantasm',

		'幽兰黛尔':'Durandal',
		'女武神·荣光':'Valkyrie Gloria',
		'辉骑士·月魄':'Bright Knight: Excelsis',
		'不灭星锚':'Dea Anchora',

		'德丽莎':'Theresa',
		'暮光骑士·月煌':'Twilight Paladin',
		'月下初拥':'Luna Kindred',
		'神恩颂歌':'Celestial Hymn',
		'处刑装·紫苑':'Violet Executer',
		'樱火轮舞':'Sakura Rondo',
		'女武神·誓约':'Valkyrie Pledge',
		'朔夜观星':'Starlit Astrologos',

		'琪亚娜':'Kiana',
		'天穹游侠':'Void Ranger',
		'空之律者':'Herrscher of the Void',
		'圣女祈祷':'Divine Prayer',
		'女武神·游侠':'Valkyrie Ranger',
		'白骑士·月光':'Knight Moonbeam',
		'领域装·白练':'White Comet',

		'布洛妮娅':'Bronya',
		'迷城骇兔':'Haxxor Bunny',
		'理之律者':'Herrscher of Reason',
		'彗星驱动':'Drive Kometa',
		'异度黑核侵蚀':'Black Nucleus',
		'银狼的黎明': "Wolf's Dawn",
		'次元边界突破':'Dimension Breaker',
		'女武神·战车':'Valkyrie Chariot',
		'驱动装·山吹':'Yamabuki Armor',
		'雪地狙击':'Snowy Sniper',

		'阿琳姐妹':'Twins',
		'狂热蓝调Δ':'Fervent Tempo Delta',
		'樱桃炸弹':'Molotov Cherry',
		'蓝莓特攻':'Blueberry Blitz',

		'芽衣':'Mei',
		'断罪影舞':'Danzai Spectramancer',
		'雷之律者':'Herrscher of Thunder',
		'破晓强袭':'Striker Fulminata',
		'雷电女王的鬼铠':'Lightning Empress',
		'脉冲装·绯红':'Crimson Impulse',
		'女武神·强袭':'Valkyrie Bladestrike',
		'影舞冲击':'Shadow Dash',

		'丽塔':'Rita',
		'失落迷迭':'Fallen Rosemary',
		'苍骑士·月魂':'Argent Knight: Artemis',
		'猎袭装·影铁':'Phantom Iron',
		'黯蔷薇':'Umbral Rose',

		'姬子':'Himeko',
		'真红骑士·月蚀':'Vermilion Knight: Eclipse',
		'极地战刃':'Arctic Kriegsmesser',
		'融核装·深红':'Scarlet Fusion',
		'战场疾风':'Battle Storm',
		'女武神·凯旋':'Valkyrie Triumph',
		'血色玫瑰':'Blood Rose',

		'卡莲':'Kallen',
		'原罪猎人':'Sündenjäger',
		'第六夜想曲':'Sixth Serenade',
		'圣仪装·今样':'Imayoh Ritual',

		'菲谢尔':'Fischl',
		'断罪皇女!!':'Prinzessin der Verurteilung'
	}

	const tl_el = function(tls, el) {
		if (el && tls[el.innerText]) {
			el.innerHTML = el.innerHTML.replace(el.innerText, tls[el.innerText])
		}
	}

	const translate = function() {
		$('th, span, .table-search .label, div.title').each(function() {
			tl_el(tls, this)
		});

    $('.table-search .filter-item .select-item').on('click', 'li', translate);
    $('.el-select-dropdown__item').on('click', 'li', translate);

    $('.table-search .filter-item .select-item').click(function(){setTimeout(function(){translate()}, 10)});
    $('.el-select-dropdown__item').click(function(){setTimeout(function(){translate()}, 10)});

    $('.table-search .filter-item .select-item').click(function(){setTimeout(function(){translate()}, 100)});
    $('.el-select-dropdown__item').click(function(){setTimeout(function(){translate()}, 100)});
	}

	$('.table-search .filter-item .select-item').on('click', 'li', translate);
	$('.el-select-dropdown__item').on('click', 'li', translate);

	$('.table-search .filter-item .select-item').click(function(){setTimeout(function(){translate()}, 10)});
	$('.el-select-dropdown__item').click(function(){setTimeout(function(){translate()}, 10)});

	$('.table-search .filter-item .select-item').click(function(){setTimeout(function(){translate()}, 100)});
	$('.el-select-dropdown__item').click(function(){setTimeout(function(){translate()}, 100)});

	translate()

	function addGlobalStyle(css) {
		var head, style;
		head = document.getElementsByTagName('head')[0];
		if (!head) { return; }
		style = document.createElement('style');
		style.type = 'text/css';
		style.innerHTML = css.replace(/;/g, ' !important;');
		head.appendChild(style);
	}
	
	addGlobalStyle('.table-team-box table .tgcol1 {min-width: 228px;}')
})();