// ==UserScript== // @name nihongoka // @namespace http://nyokki2319.hatenablog.com/entry/2017/11/01/233117 // @match https://pokemonshowdown.com/* // @match https://play.pokemonshowdown.com/* // @match https://replay.pokemonshowdown.com/* // @match https://dex.pokemonshowdown.com/* // @version 2.0.3 // @description showdown translation to japanese // @author Nyokki // @grant none // @require http://code.jquery.com/jquery-2.2.4.min.js // @run-at document-end // @copyright 2017, nyokki (https://openuserjs.org/users/nyokki) // @license GPL-2.0-or-later // @downloadURL https://update.greasyfork.icu/scripts/460164/nihongoka.user.js // @updateURL https://update.greasyfork.icu/scripts/460164/nihongoka.meta.js // ==/UserScript== /* Copyright (c) 2017 Ceca3 / kirliavc Released under the MIT license http://opensource.org/licenses/mit-license.php */ /* Copyright (C) 2018, warehaha (https://warehaha.hatenablog.com/entry/script/psja) */ /* Custom Music PS Edition Based Choon (http://www.smogon.com/forums/members/pikachuun.171701/) https://www.smogon.com/forums/threads/3527641/ */ /* Index 目次 【もくじ】  ※「//;」で検索してジャンプできます! ●翻訳(translations)の定義編  ⦿システムメッセージ  ⦿特性  ⦿わざ  ⦿アイテム  ⦿ポケモン名  ⦿battle.js ●置換編  ⦿置換①  ⦿置換②  ⦿置換③ */ // 【注意】新しいバージョンのスクリプトに更新すると元の内容は消えます。このスクリプトを編集する場合は別名で保存するかバックアップを取ってください。 var i,wikiurl,wikiurl2,opp2,splitted2,target,target2,target3,toggleCustomBgm=0,toggleAdvanceMode=0;// カスタムBGM (1でオン、0でオフ) for( // var splitted, poke_name, text, opp, text1, text2; /* 【メモ】 文のまとまり(要素)ごとに置換する。ブラウザの開発ツール参照 ○置換のパターン ・var translations = {"置換前":"置換後",};  単語や1パターンの文の置換 ・翻訳(translations)の定義を使わないが複雑な文の置換 ・翻訳(translations)の定義を使う複雑な文の置換 */ //document.getElementById("header").style.display="none"; // 特定のidの要素を非表示 document.title+=" (日本語化)",//ページのタイトルを変更 /////////////////////////////////////// // なぜか反映されない target=document.getElementsByClassName("utilichart"),i=0;iが出せない! Pikachu can't use <> after the taunt! if(-1!==tmp.indexOf(" after the taunt!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=(tmp=tmp.slice(0,-17)).split(" can't use "))[0])+"は 挑発されて "+translateText(splitted[1])+"が出せない!"; // は 挑発に 乗ってしまった! Pikachu fell for the taunt! if(-1!==tmp.indexOf(" fell for the taunt!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split(" fell for the taunt!"))[0])+"は 挑発に 乗ってしまった!"; // は 相手を 道連れにしようとしている! The opposing Banette is hoping to take its attacker down with it! if(-1!==tmp.indexOf(" is hoping to take its attacker down with it!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split(" is hoping to take its attacker down with it!"))[0])+"は 相手を 道連れにしようとしている!"; // の 化けの皮がはがれた! The opposing Mimikyu's disguise was busted! if(-1!==tmp.indexOf("'s disguise was busted!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split("'s disguise was busted!"))[0])+"の 化けの皮が はがれた!"; // は Zパワーを身体にまとった! Tapu Fini surrounded itself with its Z-Power! if(-1!==tmp.indexOf(" surrounded itself with its Z-Power!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split(" surrounded itself with its Z-Power!"))[0])+"は Zパワーを 身体にまとった!"; // かたやぶり breaks the mold! if(-1!==tmp.indexOf(" breaks the mold!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split(" breaks the mold!"))[0])+"は かたやぶりだ!"; // は 眠ってしまった!Smeargle fell asleep! if(-1!==tmp.indexOf(" fell asleep!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split(" fell asleep!"))[0])+"は 眠ってしまった!"; // は 目をさました!Smeargle woke up! if(-1!==tmp.indexOf(" woke up!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split(" woke up!"))[0])+"は 目をさました!"; // 空高く とびあがった! Smeargle sprang up! if(-1!==tmp.indexOf(" sprang up!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split(" sprang up!"))[0])+"は 空高く とびあがった!"; // 攻撃を かわした! The opposing Charizard avoided the attack!music.play(); if(-1!==tmp.indexOf(" avoided the attack!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split(" avoided the attack!"))[0])+"は 攻撃を かわした!"; // で もちこたえた! Smeargle hung on using its Focus Sash! if(-1!==tmp.indexOf(" hung on using its "))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=(tmp=tmp.slice(0,-1)).split(" hung on using its "))[0])+"は "+translateText(splitted[1])+"で もちこたえた!"; // まひして 技が 出にくくなった! The opposing Charizard is paralyzed! It may be unable to move! if(-1!==tmp.indexOf(" is paralyzed! It may be unable to move!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split(" is paralyzed! It may be unable to move!"))[0])+"は まひして 技が 出にくくなった!"; // すでにまひ Smeargle is already paralyzed. if(-1!==tmp.indexOf(" is already paralyzed."))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split(" is already paralyzed."))[0])+"は すでに まひしている"; // 体がしびれて 動けない! The opposing Smeargle is paralyzed! It can't move! if(-1!==tmp.indexOf(" is paralyzed! It can't move!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split(" is paralyzed! It can't move!"))[0])+"は 体がしびれて 動けない!"; // 時空をゆがめた! The opposing Smeargle twisted the dimensions! if(-1!==tmp.indexOf(" twisted the dimensions!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split(" twisted the dimensions!"))[0])+"は 時空をゆがめた!"; // The opposing JirachiはHihihiroshiのもとへ戻っていく! The opposing Jirachi went back to Hihihiroshi! if(-1!==tmp.indexOf(" went back to "))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=(tmp=tmp.slice(0,-1)).split(" went back to "))[0])+"は "+translateText(splitted[1])+"のもとへ戻っていく!"; // の 身代わりは 消えてしまった... Ninetales's substitute faded! if(-1!==tmp.indexOf("'s substitute faded!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split("'s substitute faded!"))[0])+"の 身代わりは 消えてしまった..."; // みがわりが現れた Ninetales put in a substitute! if(-1!==tmp.indexOf(" put in a substitute!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split(" put in a substitute!"))[0])+"の 身代わりが現れた!"; // 代わって身代わりが攻撃を受けた! The substitute took damage for Ninetales! if(-1!==tmp.indexOf("The substitute took damage for ")) //console.log("tmp="+tmp); //splitted =tmp.split("The substitute took damage for "); //console.log("splitted[0]="+splitted[0]); return-1!==tmp.indexOf(" the opposing ")?(tmp=tmp.replace(/ the opposing /,""),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText(tmp=(tmp=tmp.slice(0,-1)).slice(31))+"に代わって 身代わりが攻撃を受けた!"; // 能力変化 The opposing Smeargle's evasiveness rose sharply! /rose drastically! if(-1!==tmp.indexOf(" rose")&&-1==tmp.indexOf("moves")||-1!==tmp.indexOf(" fell")&&-1==tmp.indexOf("asleep")&&-1==tmp.indexOf(" for the taunt!")&&-1==tmp.indexOf("perish count")&&-1==tmp.indexOf("the feint!")&&-1==tmp.indexOf("in love!")) //console.log("tmp =" + tmp); return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),-1!==tmp.indexOf(" rose")&&(//console.log("上がった"); -1!==tmp.indexOf(" sharply!")&&(tmp=tmp.slice(0,-14),text1="が ぐーんと上がった!"),-1!==tmp.indexOf(" drastically!")&&(tmp=tmp.slice(0,-18),text1="が ぐぐーんと上がった!"), //if (tmp.indexOf(" sharply!") == -1 && tmp.indexOf(" drastically!") == -1){tmp=tmp.slice(0,-6);text1="が 上がった!";} -1!==tmp.indexOf(" rose!")&&(tmp=tmp.slice(0,-6),text1="が 上がった!")),-1!==tmp.indexOf(" fell")&&(//console.log("下がった"); -1!==tmp.indexOf(" harshly!")?(tmp=tmp.slice(0,-14),text1="が がくっと下がった!"):(tmp=tmp.slice(0,-6),text1="が 下がった!")),opp+translateText(( //console.log("tmp ="+tmp); //console.log("text1 ="+text1); splitted=tmp.split("'s "))[0])+"の "+translateText(splitted[1])+text1; // やけどのダメージを受けている! Smeargle was hurt by its burn! if(-1!==tmp.indexOf(" was hurt by its burn!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText(( //tmp = tmp.slice(0, -1); splitted=tmp.split(" was hurt by its burn!"))[0])+"は やけどのダメージを受けている!"; // どくのダメージを受けている!+"music.play("square", 0.3);" if(-1!==tmp.indexOf(" was hurt by ")&&-1!==tmp.indexOf("poison"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=(tmp=tmp.slice(0,-1)).split(" was hurt by "))[0])+"は "+translateText(splitted[1])+"のダメージを受けている!"; // どく (もうどくは was badly poisoned!) if(-1!==tmp.indexOf(" was poisoned!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split(" was poisoned!"))[0])+"は 毒をあびた!"; // 攻撃から身を守った! if(-1!==tmp.indexOf(" protected itself!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split(" protected itself!"))[0])+"は 攻撃から身を守った!"; // たべのこし if(-1!==tmp.indexOf(" restored a little HP using its Leftovers!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split(" restored a little HP using its Leftovers!"))[0])+"は たべのこしで 少し回復した!"; // 能力変化(ランク変化)//x if(-1!==tmp.indexOf(/.{3}x .{3}/))return translateText(( //console.log("ランク変化 ?.?x 能力"); splitted=tmp.split("x "))[1])+" x"+splitted[0]; // 特性の発動 [(.+)'s (.+)] if(-1!==tmp.indexOf("[")&&-1!==tmp.indexOf("'s ")&&-1==tmp.indexOf("Let's Go")) //console.log("sliced2 tmp =" + tmp); //console.log("splitted =" + splitted); //console.log("特性の発動 tmp =" + tmp); return opp="",-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(14),opp="相手の"):tmp=tmp.slice(1),"["+opp+translateText((splitted=( //console.log("sliced1 tmp =" + tmp); tmp=tmp.slice(0,-1)).split("'s "))[0])+"の"+translateText(splitted[1])+"]"; // .replace(/(.+), come back!/,"$1、戻れ!") if(-1!=tmp.indexOf(", come back!"))return translateText((splitted=tmp.split(", come back!"))[0])+"、戻れ!"; // 味方 倒れた if(-1!=tmp.indexOf(" fainted!")&&-1==tmp.indexOf("The opposing"))return translateText((splitted=tmp.split(" fainted!"))[0])+"は 倒れた!"; // 敵 倒れた if(-1!=tmp.indexOf(" fainted!")&&-1!==tmp.indexOf("The opposing"))// 13文字(The opposing )を削る return(splitted=tmp.split(" fainted!"))[0]=splitted[0].slice(13),"相手の"+translateText(splitted[0])+"は 倒れた!"; // (味方の)ポケモン名 used 技名! if(-1!=tmp.indexOf(" used")&&-1==tmp.indexOf("The opposing"))// tmpをusedで分割 // console.log("(味方の)ポケモン名 used 技名!: tmp = " + tmp); return translateText((// 文字列tmpを左から右へ検索して usedが現れ、かつThe opposingがない場合 splitted=tmp.split(/ used/))[0])+"の "; // 相手の ポケモン名 used 技名! if(-1!=tmp.indexOf(" used")&&-1!=tmp.indexOf("The opposing"))// 13文字(The opposing )を削る //console.log("相手の ポケモン名 used 技名!: splitted[0] = " + splitted[0]); // console.log("相手の ポケモン名 used 技名!: tmp = " + tmp); return(splitted=tmp.split(/ used/))[0]=splitted[0].slice(13),"相手の"+translateText(splitted[0])+"の "; // 命が少し削られた! The opposing Darmanitan lost some of its HP! if(-1!==tmp.indexOf(" lost some of its HP!"))return-1!==tmp.indexOf("The opposing ")?(tmp=tmp.slice(13),opp="相手の"):(tmp=tmp.slice(0),opp=""),opp+translateText((splitted=tmp.split(" lost some of its HP!"))[0])+"の 命が少し削られた!"; // 【playとreplayで文の区切りが異なる? playだと区切りなし?】 //(The opposing Heracross lost 区切り??.?%区切り of its health!) (リプレイ) // (自分の)ポケモン名に ??.?%のダメージ! if(-1!=tmp.indexOf(" lost ")&&-1!==tmp.indexOf("of its health!)")&&-1==tmp.indexOf("The opposing"))return"("+translateText((// この時点でtmpは"Pikachu lost 26%" splitted=(tmp=( //console.log("(自分の)ポケモン名に ??.?%のダメージ! tmp =" + tmp); tmp=tmp.slice(1)).slice(0,-16)).split(" lost "))[0])+"に "+splitted[1]+"のダメージ!)"; // 【区切られていた場合】 (相手または自分の)ポケモン名に ??.?%のダメージ! ←なぜか置換できない!? /*if (tmp.indexOf(/\((.+) lost /) !== -1) { if (tmp.indexOf("The opposing ") !== -1){tmp=tmp.slice(14); opp="相手の";} else{tmp=tmp.slice(1); opp="";} splitted =tmp.split(" lost "); return "(" + opp + translateText(splitted[0]) + "に "; } if (tmp.indexOf(" of its health!)") !== -1) { //console.log(" of its health!"); tmp ="のダメージ!)"; return tmp; } */ // (相手の ポケモン名に ??%のダメージ!) if(-1!=tmp.indexOf(" lost ")&&-1!==tmp.indexOf("of its health!)")&&-1!==tmp.indexOf("The opposing")) //console.log("splitted[0] ="+splitted[0]);console.log("splitted[1] ="+splitted[1]); //console.log("相手の ポケモン名に ??.?%のダメージ! tmp =" + tmp); // この時点でtmpは"Pikachu lost 26%" //console.log("sliced tmp ="+tmp); return(splitted=(// ポケモン名 lost ??.?% of its health!) tmp=(tmp=tmp.slice(14)).slice(0,-16)).split("lost"))[0]=splitted[0].slice(0,-1),splitted[1]=splitted[1].slice(1),"(相手の"+translateText(splitted[0])+"に "+splitted[1]+"のダメージ!)"; //if (tmp.indexOf(/(\(.+) lost /) !== -1){return "$1に ";} if(-1!==tmp.indexOf("!dex "))return"!dex "+translateText((splitted=tmp.split("!dex "))[1]);if(-1!==tmp.indexOf("!data "))return"!data "+translateText((splitted=tmp.split("!data "))[1]); //////////////////////////////////////////////////////////////////////////////////////////////////////////////// if(-1!=tmp.indexOf("will be sent out first")){for(var poke_names=tmp.replace(" will be sent out first.","").split(", "),i=0;i=0) // str1=splitted[pos--]+" "+str1; // var ret="の"; // var trans1=translateText(str1); // var trans2=translateText(str2); // if(trans1) // ret+=trans1; // if(trans2) // ret+=trans2; // ret+="!"; // if(originalStr.indexOf("The opposing")!=-1) // ret+=" 相手の"; // return ret; // } if(originalStr.match(regex_abi_and_item))return originalStr=originalStr.replace(regex_abi_and_item,"特性: "),translateText(RegExp.$1)&&(originalStr+=translateText(RegExp.$1)),originalStr+=" / 持ち物: ",translateText(RegExp.$2)&&(originalStr+=translateText(RegExp.$2)),originalStr;if(originalStr.match(regex_ability))return originalStr=originalStr.replace(regex_ability,"特性: "),translateText(RegExp.$1)&&(originalStr+=translateText(RegExp.$1)),originalStr;if(originalStr.match(regex_possible_ability))return originalStr=originalStr.replace(regex_possible_ability,"特性: "),translateText(RegExp.$1)&&(originalStr+=translateText(RegExp.$1)),originalStr;if(originalStr.match(regex_possible_ability2))return originalStr=originalStr.replace(regex_possible_ability2,"特性: "),translateText(RegExp.$1)&&translateText(RegExp.$2)&&(originalStr=originalStr+translateText(RegExp.$1)+","+translateText(RegExp.$2)),originalStr;if(originalStr.match(regex_possible_ability3))return text="特性: ",translateText(RegExp.$1)&&translateText(RegExp.$2)&&translateText(RegExp.$3)&&(text=text+translateText(RegExp.$1)+","+translateText(RegExp.$2)+","+translateText(RegExp.$3)),text;if(originalStr.match(regex_Item))return originalStr=originalStr.replace(regex_Item,"持ち物: "),translateText(RegExp.$1)&&(originalStr+=translateText(RegExp.$1)),originalStr;if(originalStr.match(regex_preview)){for(var pokes=originalStr.split(" / "),ret=translateText(pokes[0]),pos=1;pokes[pos]&&(ret+=" / "+translateText(pokes[pos]),!(++pos>=6)););return ret}return originalStr.match(regex_start_battle)?RegExp.$1+"と "+RegExp.$2+"の 対戦がはじまった!":originalStr.match(/^\((.*)\)$/)&&translateText(RegExp.$1)?"("+translateText(RegExp.$1)+")":originalStr.match(/(.+) has Mega Evolved into Mega ([A-za-z -']+)!/)&&-1==originalStr.indexOf("The opposing")?translateText(RegExp.$1)+"は メガ"+translateText(RegExp.$2)+"に メガシンカした!":originalStr.match(/(.+) has Mega Evolved into Mega ([A-za-z -']+)!/)&&-1!==originalStr.indexOf("The opposing")?"相手の"+translateText((splitted=(tmp=( // The opposing Salamence has Mega Evolved into Mega Salamence! tmp=tmp.slice(13)).slice(0,-1)).split(" has Mega Evolved into Mega "))[0])+"は メガ"+translateText(splitted[1])+"に メガシンカした!":originalStr.match(/(.+) transformed into ([A-za-z -']+)!/)&&-1==originalStr.indexOf("The opposing ")?(RegExp.$2=RegExp.$2.replace(" its "," "),translateText(RegExp.$1)+"は "+translateText(RegExp.$2)+"になった!"):originalStr.match(/(.+) transformed into ([A-za-z -']+)!/)&&-1!==originalStr.indexOf("The opposing ")?"相手の"+translateText((splitted=(tmp=(tmp=tmp.slice(13)).slice(0,-1)).split(" transformed into "))[0])+"は "+translateText(splitted[1])+"になった!": //if (originalStr.match(regex_uturn)) { // return translateText(RegExp.$1) + "は" + RegExp.$2 + "のもとへ戻っていく!"; //} //if (originalStr.match(regex_hurtby)) { // if (originalStr.indexOf("opposing")){ // return "は" + translateText(RegExp.$1) + "のダメージを受けている!"; // } //} // if(originalStr.match(regex_magic_bounce)){ // return "把"+translateText(RegExp.$1)+"反弹回去了!"; // } // if(originalStr.match(regex_magic_bounce)){ // return "把"+translateText(RegExp.$1)+"反弹回去了!"; // } //if (originalStr.match(/can't use ([A-za-z- ]+) after the taunt!/)) { // return "は挑発されて" + translateText(RegExp.$1) + "が出せない!"; //} originalStr.match(regex_gems)?translateText(RegExp.$1)+"は "+translateText(RegExp.$2)+"の威力を強めた!": //if (originalStr.match(regex_doesnt_affect)) { // opp = (translateText(RegExp.$1) === undefined) ? "" : translateText(RegExp.$1); // return opp + translateText(RegExp.$2) + "には 効果が ないようだ...";//x // return "効果が ないようだ..."; //} originalStr.match(regex_z_prtct)?translateText(RegExp.$1)+"は攻撃を守りきれずにダメージを受けた!":originalStr.match(regex_megastone)&&-1==originalStr.indexOf("The opposing ")?translateText(RegExp.$1)+"の "+translateText(RegExp.$2)+"と キーストーンが反応した!":originalStr.match(regex_megastone)&&-1!==originalStr.indexOf("The opposing ")?"相手の"+translateText((splitted=(tmp=(// The opposing Salamence's Salamencite is reacting to the Key Stone! tmp=tmp.slice(13)).slice(0,-30)).split("'s "))[0])+"の "+translateText(splitted[1])+"と キーストーンが反応した!": //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// originalStr.match(regex_joined)?originalStr.match("You ")?"チャットルームに入室しました。":RegExp.$1+"が参加しました。":originalStr.match(regex_left)&&!originalStr.match(/(.+) has (.+) seconds left./)?RegExp.$1+"が退出しました。":originalStr.match(regex_whatwilldo)?RegExp.$1+"は どうする?":originalStr.match(regex_battleoptions)?"バトル"+RegExp.$1+"オプション":originalStr.match(regex_alreadyinbattle)?RegExp.$1+"は すでに場に出ています":originalStr.match(regex_2users)?RegExp.$1+"人のユーザー":(originalStr.match(/Turn ([0-9]+)/),originalStr.replace(/ won the battle!/,"は 戦いに勝利した!").replace(" withdrew ","引き分け").replace(" forfeited.","は 降参した").replace(/Turn ([0-9]+)/,"ターン$1").replace("Battle timer is ON","バトルタイマーがオン").replace("inactive players will automatically lose when time's up.","時間切れになると負けます。").replace(/requested by (.+)/g,"($1のリクエスト)").replace(/(.+) has ([0-9]+) seconds left./,"$1のタイマー:残り$2秒").replace(/(.+)'s team:/,"$1のチーム:").replace(/(.+) disconnected and has 300 seconds to reconnect!/,"$1がサーバーから切断しました。300秒間は再接続が可能です。").replace(/(.+)'s rating:/,"$1のレート:").replace("What will ","").replace(" do?","は どうする?").replace(/ New (.+) Team/,"$1 の新しいチームを作成").replace(/(.+)wants to battle!/,"$1が勝負をしかけてきた!").replace(/Challenge (.+)\?/,"$1に 戦いを挑みますか?").replace(/Challenging (.+).../,"$1に 戦いを挑んでいます...").replace(/Waiting for (.+).../,"$1の 選択を待っています...").replace(/The challenge was cancelled./,"挑戦はキャンセルされました。").replace(/(before items\u002fabilities\u002fmodifiers)/,"アイテム、特性の補正前").replace(/^(?!.*currently set).*to:/,"の次は どれを出す?").replace(/Generation ([0-9])/,"第$1世代").replace(/No (.+) battles are going on right now./,"$1 の対戦は現在行われていません。").replace(/(.+) disconnected and has a minute to reconnect!/,"$1がサーバーから切断しました。1分間は再接続できます。").replace(/(.+) has (.+) seconds to reconnect!/,"$1の再接続可能時間:残り$2秒").replace(/Your team is valid for (.+)./,"このチームは$1で使用可能です。").replace("Your team was rejected for the following reasons:","あなたのチームは以下の理由により受け付けられませんでした:").replace(/(.+) to (.+) Spe/,"素早さ: $1~$2").replace(/Choose a Pokémon for slot (.+)/,"$1番目のポケモンを選ぶ").replace(/Search results for "(.+)"/,'"$1"の検索結果').replace(/The room "(.+)" does not exist./,'対戦ルーム"$1"は期限が切れて、無くなっています。').replace('The battle you\'re looking for has expired. Battles expire after 15 minutes of inactivity unless they\'re saved.',"保存されなかったバトルは、プレイヤーがいなくなってから15分後に期限が切れます。").replace('In the future, remember to click "Save replay" to save a replay permanently.',"リプレイを永久に保存するには忘れずに「リプレイを保存」を選ぶようにしてください。").replace(/(.+) lost due to inactivity./,"$1は どこかへ いなくなった").replace(/Congratulations, (.+)!/,"おめでとう! $1!!").replace(/(.+) Tournament created./,"トーナメントが作られました:$1 Tournament").replace(/(.+) has won the match (.+) - (.+) against (.+)./,"$1は $4に $2 - $3 で 勝った!").replace(/(.+) has lost the match (.+) - (.+) against (.+)./,"$1は $4に $2 - $3 で 負けた!").replace(/Tournament battle between (.+) and (.+) started./,"$1と $2の トーナメントバトルが始まった!").replace(/The tournament's automatic disqualify timer has been set to (.+) minutes./,"トーナメントを失格になるまでの時間が$1分にセットされました。").replace(/(.+) has been disqualified from the tournament./,"$1は トーナメントを失格になりました。").replace(/Congratulations to (.+) for winning the (.+)!/,"$1が $2で優勝しました!おめでとうございます!").replace(/Runner-up: (.+)/,"準優勝: $1").replace(/L([0-9][0-9]?[0-9]?)/,"Lv.$1"))}// /var t // 単語の置換の実行; function translateText(txt){if(void 0===txt)return!1; //console.log(txt); if(void 0===translations[txt]){ // ポケモンの接尾語判定 他に影響あるかも? let splitSuffix=txt.split('-');return splitSuffix.length>0&&translations[splitSuffix[0]]&&translations['-'+splitSuffix[1]]?translations[splitSuffix[0]]+translations['-'+splitSuffix[1]]:txt}return translations[txt]}function skip(node,elTW){for(node=elTW.nextNode();null==node.nodeValue;)node=elTW.nextNode();return node}function translateElement(element){for(var elTW=document.createTreeWalker(element,NodeFilter.SHOW_Element,null,!1),node=null,translate=t,flag=!0;null!=(node=elTW.nextNode());)if(node.nodeValue&&"textbox"!=node.parentNode.getAttribute("class")){//テキストボックス内を除く(TeambuilderのImport/Exportで一部が置換されるため) //console.log(QQ(node).text()); //QQ(node).text(transl) // console.log(node.nodeValue+" "+node.parentNode.getAttribute("class")); //console.log(); var value=node.nodeValue; // (ポケモン lost /xx.x-yy.y% /of its health!) で区切られる if(/lost\s?$/.test(value)){var arr=[value.trim()];for(flag=!0,node.nodeValue="";flag;){var txt=(node=skip(node,elTW)).nodeValue.trim();arr.push(txt),"of its health!)"==txt&&(flag=!1),node.nodeValue=""}var text=translate(arr.join(" "));node.nodeValue=translate(text)}else{if(-1!=value.indexOf('•')){value=translate(value=value.replace('•',"")),node.nodeValue="• "+value;continue} // else if (value.match(regex_search)) { //ダブルダメージ // var arr = [value.trim()]; // flag = true; // node.nodeValue = ""; // while (flag) { // node = skip(node, elTW); // var txt = node.nodeValue.trim(); // arr.push(txt); // if (txt == "!" || txt == ".") flag = false; // node.nodeValue = ""; // } // var text = translate(arr.join(" ")); // node.nodeValue = translate(arr.join(" ")); // } // else if (value.indexOf("Pointed stones dug into") != -1 || value.indexOf("It doesn't affect") != -1 || value.indexOf("used the move instructed") != -1 ) { // arr = [value.trim()]; // flag = true; // node.nodeValue = ""; // while (flag){ // node = skip(node, elTW); // arr.push(node.nodeValue.trim()); // if (node.nodeValue.indexOf("!") != -1) flag = false; // node.nodeValue = ""; // } // node.nodeValue = translate(arr.join(" ")); // } if(" knocked off "==value||" knocked off the opposing "==value||" copied "==value||" copied the opposing "==value){for( /*var*/ arr=[value.trim()], /*var*/ flag=!0,node.nodeValue="";flag;)node=skip(node,elTW),arr.push(node.nodeValue.trim()),-1!=node.nodeValue.indexOf("'s ")&&(flag=!1),node.nodeValue="";node.nodeValue=translate(arr.join(" "))}else if(" frisked "==value||" frisked the opposing "==value){for( /*var*/ arr=[value.trim()], /*var*/ flag=!0,node.nodeValue="";flag;)node=skip(node,elTW),arr.push(node.nodeValue.trim()),-1!=node.nodeValue.indexOf("and found its ")&&(flag=!1),node.nodeValue="";node.nodeValue=translate(arr.join(" "))}else if(value.match(regex_forme)){var target=node;for(node.nodeValue="",node=elTW.nextNode();null==node.nodeValue;)node=elTW.nextNode();var nn=node.nodeValue;node.nodeValue="",node=skip(node,elTW),target.nodeValue=translate(value+nn+node.nodeValue),node.nodeValue="",(node=elTW.nextNode()).nodeValue=""}else node.nodeValue=translate(node.nodeValue.replace("held by","holder is"))}if(((text=node.nodeValue)&&-1!=text.indexOf('急所に当たった!')&&'battle-history'==QQ(node).parent().parent().attr('class')||'battle'==QQ(node).parent().parent().attr('class'))&&QQ(node).wrap(''),text&&-1!=text.indexOf('日本語 Japanese')&&'ilink'==QQ(node).parent().parent().attr('class')&&QQ(node).wrap(''),text&&text.match(/(!dex)|(!data) (.+)/)){text.match(/!dex (.+)/)&&(text=text.slice(5)),text.match(/!data (.+)/)&&(text=text.slice(6));let wikiurl="https://wiki.ポケモン.com/wiki/"+text;QQ(node).wrap('')}if(/*text.match(translateText(text)) && (*/'statbar lstatbar'==QQ(node).parent().parent().attr('class')||'statbar rstatbar'==QQ(node).parent().parent().attr('class'))/*)*/{ //if(text.indexOf("L") !== -1){console.log(QQ(node).parent().parent().parent().attr('class') + " Lが検出されました!");} let splitted3=text.split("-");"ゲンシグラードン"==splitted3[0]&&splitted3[0],"ゲンシカイオーガ"==splitted3[0]&&splitted3[0],-1!==splitted3[0].indexOf("メガ")&&"メガニウム"!==splitted3[0]&&"メガヤンマ"!==splitted3[0]&&(splitted3[0]=splitted3[0].slice(2)), //console.log("statbar lstatbar splitted[0] =" + splitted[0]); //console.log("text =" + text); //if (splitted3[0].indexOf("Lv.") !== -1){QQ(node).wrap('');} //x splitted3[0].length>=2&&-1==splitted3[0].indexOf("Lv.")&&QQ(node).wrap('")} //if (QQ(node).parent().attr('class') == 'hptext'){ //console.log("hptext"); //QQ(node).setAttribute("style",'"border-radius: 4px 4px 4px 4px; left: -48px; width: 48px;"'); //QQ(node).wrap('
'); //} // 疑似コマンド if(/*text.match(translateText(text)) && (*/'hpbar'==QQ(node).parent().parent().attr('class')&& //console.log("hpbar " + text); //console.log("HPバーの色: "); QQ(node).wrap("
"),text&&-1!==text.indexOf(' does not exist. To send a message starting with "/')){if(-1!==text.indexOf(' does not exist. To send a message starting with "/7')){let splitted=(text=text.slice(0,-2)).split('", type "//7');wikiurl2=splitted[1],QQ(node).wrap('')}if(-1!==text.indexOf(' does not exist. To send a message starting with "/7')){let splitted=(text=text.slice(0,-2)).split('", type "//7');wikiurl2=splitted[1],QQ(node).wrap('')}if(-1!==text.indexOf(' does not exist. To send a message starting with "/6')){let splitted=(text=text.slice(0,-2)).split('", type "//6');wikiurl2=splitted[1],QQ(node).wrap('')}if(-1!==text.indexOf(' does not exist. To send a message starting with "/6')){let splitted=(text=text.slice(0,-2)).split('", type "//6');wikiurl2=splitted[1],QQ(node).wrap('')}if(-1!==text.indexOf(' does not exist. To send a message starting with "/?')){let splitted=(text=text.slice(0,-2)).split('", type "//?');wikiurl2=(wikiurl2=splitted[1]).replace("z","Z"),QQ(node).wrap('')}if(-1!==text.indexOf(' does not exist. To send a message starting with "/?')){let splitted=(text=text.slice(0,-2)).split('", type "//?');wikiurl2=(wikiurl2=splitted[1]).replace("z","Z"),QQ(node).wrap('')}-1!==text.search('The command "/コマンド" does not exist. To send a message starting with "/コマンド", type "//コマンド".')&& //text = text.replace(text,"疑似コマンド"); QQ(node).wrap('')} //node=elTW.previousNode(); //QQ(t).remove(); }}!function(){'use strict';document.getElementById('room-')&&translateElement(document.getElementById('room-')),QQ(document).on('DOMNodeInserted',(function(e){translateElement(e.target)}))}(); /////////////////////////////////////