Greasy Fork is available in English.

Typing Tube MOD official

try to take over the world!

Stan na 28-04-2020. Zobacz najnowsza wersja.

// ==UserScript==
// @name         Typing Tube MOD official
// @namespace    https://typing-tube.net/
// @version      6.3.6
// @description  try to take over the world!
// @author       Toshi
// @match        https://typing-tube.net/movie/show/*?test=test
// @match        https://typing-tube.net/movie/typing/*?test=test
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js
// @noframes
// @run-at document-end


// ==/UserScript==
var ranking_array = [];
var next_kpm = 0;//次のラインの必要kpm
var line_time = 0;//ラインの残り時間
var typing_count_save = 0;//ライン切替時、現在の打鍵数を取得する
var count_save = -1;//ライン切替時、ライン数を取得する。フラグ用
var line_typingspeed = 0;//ラインの打鍵速度
var line_typingspeed_rkpm = 0;//初速を無視したライン打鍵速度
var linetyping_sec = 0;//現在ラインの入力時間(ライン切替時0になる)
var playing_time = 0;//過去のラインの合計入力時間
var playing_time_current = 0;//入力時間(累計)
var typing_speed = 0;//累計打鍵速度
var countdown_anime = false//カウントダウンアニメのフラグ
var difficulty = []
var difficulty_average = 0;
var result_html = ""
var now_time = 0
var Typing_Result = '';
var start3 = false;
var ending = false;
var skip_flag = false
window.AudioContext = window.AudioContext || window.webkitAudioContext;
var key_type = new AudioContext();
var miss_type = new AudioContext();
var clear_type = new AudioContext();

key_type_load();
function key_type_load(){
var request_key_type = new XMLHttpRequest();
request_key_type.open('GET', "/sounds/key_type.mp3", true);
request_key_type.responseType = 'arraybuffer';
request_key_type.onload = function() {
        key_type.decodeAudioData(request_key_type.response, function(buffer) {
                audio_buffer_key_type = buffer;
        }, function(){
                //エラー
        }
        );
};
request_key_type.send();
}
function key_type_play(){
var key_type_gain = key_type.createGain();
var key_type_source = key_type.createBufferSource();
key_type_source.buffer = audio_buffer_key_type;
key_type_source.connect(key_type_gain);
key_type_gain.connect(key_type.destination);
if (is_played && !finished && player.getPlayerState() == 1) {
if($("[value=Interlocking_volume]").prop("checked")){
if($('#volume').text()){
key_type_gain.gain.value = ($('#volume').text()/100)
}}
    else{
key_type_gain.gain.value = $('[name="effect_volume_type"]').val()/100
}}
key_type_source.start(0);
}
miss_type_load();
function miss_type_load(){
var request_miss_type = new XMLHttpRequest();
request_miss_type.open('GET', "/sounds/miss_type.mp3", true);
request_miss_type.responseType = 'arraybuffer';
request_miss_type.onload = function() {
        miss_type.decodeAudioData(request_miss_type.response, function(buffer) {
                audio_buffer_miss_type = buffer;
        }, function(){
                //エラー
        }
        );
};
request_miss_type.send();
}
function miss_type_play(){
var miss_type_gain = miss_type.createGain();
var miss_type_source = miss_type.createBufferSource();
miss_type_source.buffer = audio_buffer_miss_type;
miss_type_source.connect(miss_type_gain);
miss_type_gain.connect(miss_type.destination);
if (is_played && !finished && player.getPlayerState() == 1) {
if($("[value=Interlocking_volume]").prop("checked")){
if($('#volume').text()){
miss_type_gain.gain.value = ($('#volume').text()/100)
}}
    else{
miss_type_gain.gain.value = $('[name="effect_volume_type"]').val()/100
}}
miss_type_source.start(0);
}
clear_type_load();
function clear_type_load(){
var request_clear_type = new XMLHttpRequest();
request_clear_type.open('GET', "/sounds/clear_type.mp3", true);
request_clear_type.responseType = 'arraybuffer';
request_clear_type.onload = function() {
        clear_type.decodeAudioData(request_clear_type.response, function(buffer) {
                audio_buffer_clear_type = buffer;
        }, function(){
                //エラー
        }
        );
};
request_clear_type.send();
}
function clear_type_play(){
var clear_type_gain = clear_type.createGain();
var clear_type_source = clear_type.createBufferSource();
clear_type_source.buffer = audio_buffer_clear_type;
clear_type_source.connect(clear_type_gain);
clear_type_gain.connect(clear_type.destination);
if (is_played && !finished && player.getPlayerState() == 1) {
if($("[value=Interlocking_volume]").prop("checked")){
if($('#volume').text()){
clear_type_gain.gain.value = ($('#volume').text()/100)
}}
    else{
clear_type_gain.gain.value = $('[name="effect_volume_type"]').val()/100
}}
clear_type_source.start(0);
}

function setting_reset(){
    var res = confirm("チェックボックス・効果音音量・スクロール量を初期設定に戻します。よろしいですか?");
    if( res == true ) {
$("[value=miss_on],[value=anime_count],[value=font_Gothic],[value=bolding],[value=default],[value=sub],[value=Interlocking_volume],[value=sec],[value=skip_guide]").prop('checked', true);
$("[value=next_lyric_hidden],[value=character_spacing],[value=letter_scroll],[value=line_hidden],[value=eng_highlight],[value=type_sound],[value=miss_sound],[value=clear_sound],[value=combo_break_sound]").prop('checked', false);
$("[name=effect_volume_type],[name=effect_volume_miss],[name=effect_volume_clear]").val(80)
$('[name="letter_scroll_roma"]').val(16)
$('[name="letter_scroll_kana"]').val(10)
    }
}
function effectcolor_reset(){
    var res = confirm("エフェクト色をデフォルトに戻します。よろしいですか?");
    if( res == true ) {
$("[name=miss_color]").val("#FF3554")
$("[name=miss_color]").css({'cssText':'background-color: rgb(255, 53, 84); color: rgb(255, 255, 255);'});
$("[name=countdown_color]").val("rgba(255,255,255,0.9)")
$("[name=countdown_color]").css({'cssText':'background-color:rgba(255,255,255,0.9); color: rgb(0, 0, 0);'});
$("[name=skipguide_color]").val("rgba(255,255,255,0.53)")
$("[name=skipguide_color]").css({'cssText':'background-color:rgba(255,255,255,0.53); color: rgb(0, 0, 0);'});
}
}

 $(document.head).append(`<style>
/*タブのスタイル*/
.tab_item {
  width: calc(100%/3);
  height: 50px;
  line-height: 50px;
  font-size: 16px;
  text-align: center;
  color: #565656;
  display: block;
  float: left;
  text-align: center;
  font-weight: bold;
  transition: all 0.2s ease;
}
.tab_item:hover {
  opacity: 0.75;
}

/*ラジオボタンを全て消す*/
input[name="tab_item"] {
  display: none;
}

/*タブ切り替えの中身のスタイル*/
.tab_content {
  display: none;
  clear: both;
}


/*選択されているタブのコンテンツのみを表示*/
#all:checked ~ #all_content,
#programming:checked ~ #programming_content,
#design:checked ~ #design_content {
  display: block;
}

/*選択されているタブのスタイルを変える*/
.tabs input:checked + .tab_item {
  background-color: #5ab4bd;
  color: #fff;
}
</style>`);
//設定を追加
$('<form id="mod_setting" style="color:#fff; border:2px solid #aaa;z-index:9999;display:none;position:fixed;word-break: break-all;width:600px;max-height: 900px;background-color: rgba(0,0,0,4.33);">'+
'<input id="all" type="radio" name="tab_item" checked><label class="tab_item" for="all">表示設定</label><input id="design" type="radio" name="tab_item"><label class="tab_item" for="design">色・フォント</label>'+
' <div class="tab_content" id="all_content"><div class="tab_content_description"><p class="c-txtsp">'+
'<h6 style="margin-bottom:0!important;">入力モード設定</h6><label><input type="checkbox" name=chk_sample value="sub"checked>サブ入力ガイドを表示</input></label><br><label><input type="checkbox" name=chk_sample value="eng_highlight">英単語をスペース・ひらがな区切りでハイライト(かな表示のみ)</input></label><br><label><input type="checkbox" name=chk_sample value="letter_scroll">入力歌詞をスクロール表示</input></label><label><input type="number"name="letter_scroll_kana"min="0" max="30">かな表示スクロール数</input></label><label><input type="number"name="letter_scroll_roma"min="0" max="30">ローマ字表示スクロール数</input></label><label><input type="checkbox" name=chk_sample value="next_lyric_hidden">入力不要なラインは[次の歌詞]に表示しない</input></label><label><input type="checkbox" name=chk_sample value="line_hidden">初速測定モード(次の歌詞とライン経過時間を隠します)</input></label>'+
'<h6 style="margin-bottom:0!important;">効果音・音量</h6><label><input type="checkbox" name=chk_sample value="type_sound">打鍵音</input></label><label><input type="number"name="effect_volume_type"min="0" max="100"></input></label><label><input type="checkbox" name=chk_sample value="miss_sound">ミス音</input></label><label><input type="number"name="effect_volume_miss"min="0" max="100"></input></label><br><label><input type="checkbox" name=chk_sample value="clear_sound">クリア音</input></label><label><input type="number"name="effect_volume_clear"min="0" max="100"></input></label><label><input type="checkbox" name=chk_sample value="combo_break_sound">100コンボ以上のミス音</input></label><label><input type="number"name="effect_volume_combo_break"min="0" max="100"></input></label><br><label><input type="checkbox" name=chk_sample value="Interlocking_volume"checked>曲音量と効果音音量を連動</input></label>'+
'<h6 style="margin-bottom:0!important;">打鍵速度</h6><label><input type="radio" name=chk_sample value="sec"checked>打/秒</input></label><label><input type="radio" name=chk_sample value="kpm">kpm</input></label>'+
'<br></p></div></div>'+
'<div class="tab_content" id="design_content"><div class="tab_content_description"><p class="c-txtsp">'+
'<h6 style="margin-bottom:0!important;">エフェクト設定</h6><label><input type="checkbox" name=chk_sample value="miss_on"checked>ミスエフェクト</label><label><input class="color" value="#FF3554" name="miss_color">色で表示</label><br><label><input type="checkbox" name=chk_sample value="anime_count"checked>間奏終了前にカウントダウン</label><label><input class="color" value="rgba(255,255,255,0.9)" name="countdown_color">色で表示</label><br><label><input type="checkbox" name=chk_sample value="skip_guide" checked>スペースキーで任意スキップ</label><label><input class="color" value="rgba(255,255,255,0.53)" name="skipguide_color">色で表示</label><br><button type="button" onclick="effectcolor_reset()"">エフェクトの色をリセット</button>'+
'<h6 style="margin-bottom:0!important;">フォント設定</h6><label><input type="checkbox" name=chk_sample value="font_Gothic"checked>游ゴシック体表示</input></label><label><input type="checkbox" name=chk_sample value="bolding"checked>フォントを太く表示</input></label><label><input type="checkbox" name=chk_sample value="character_spacing">入力歌詞の文字間隔を広げる</input></label>'+
'<h6 style="margin-bottom:0!important;">背景カラー</h6><label><input class="color" value="rgba(255,255,255,0)" name="playarea_color"></label><label><input type="number" name="playarea_radius" min="0" max="30" value="0">px</input>縁を丸める</label><br>'+
'<label>縁取り線<select name="futidori_theme"><option value="none">なし</option><option value="solid">1本線</option><option value="double">2本線</option><option value="groove">立体線(窪む)</option><option value="ridge">立体線(隆起)</option><option value="outset">立体線(影)</option><option value="dashed">破線</option><option value="dotted">点線</option></select></label><label>縁の色<input class="color" value="#FFFFFF" name="futidori_color"></label><label>太さ<select name="futidori_border-width"><option value="medium">普通</option><option value="thin">細い</option><option value="thick">太い</option></select></label><br>'+
'<br><h6 style="margin-bottom:0!important;">文字の色</h6><label>入力後の文字<input class="color" value="#0099CC" name="correctword_color"></label><label>ラインクリア<input class="color" value="#1eff52" name="lineclear_color"></label><label>先頭の文字<input class="color" value="#FFFFFF" name="first_color"></label><label>入力歌詞<input class="color" value="#FFFFFF" name="word_color"></label><br><label>歌詞<input class="color" value="#FFFFFF" name="lyric_color"></label><label>次の歌詞(準備中)<input class="color" value="rgba(255,255,255,.7)" name="next_lyrics_color"></label>'+
'<select name="color_theme"><option>プリセット</option><option value="デフォルト">デフォルト</option><option value="先頭の文字を赤く強調">先頭の文字を赤く強調</option></select>'+
'<br></p></div></div>'+
'<button type="button" onclick="setting_reset()" style="position:absolute;right:5px;bottom:5px;">設定をリセット</button></form>').insertAfter('.share')


$('<a class="btn" style="font-size:24px;"><i class="zmdi-hc-fw zmdi fas fa-cog" title="設定を開く"></i></a>').insertBefore('.twitter:eq(0)')


$('<div class="esckey">Escキーで開始</div>').insertBefore('#playBotton1')
$('#playBotton1 > .col-6').eq(0).html('<label style="margin-bottom:0!important;"><input  type="radio" name=mode_select value="kana_type"checked>Play - かな表示</label>')
$('#playBotton2 > .col-6').eq(0).html('<label style="margin-bottom:0!important;"><input  type="radio" name=mode_select value="roma_type">Play - ローマ字表示</label>')
$('#playBotton4 > .col-6').eq(0).html('<label style="margin-bottom:0!important;"><input  type="radio" name=mode_select value="kanamode_type">Play - かな入力<span style="font-size:50%">(106/109)</span></label>')
$('#playBotton5 > .col-6').eq(0).html('<label style="margin-bottom:0!important;"><input  type="radio" name=mode_select value="kanamode_mac_type">Play - かな入力<span style="font-size:50%">(Mac用JIS)</span></label>')


//CSS変更
$("#status").css({'cssText':'font-size:1.4rem;'+'white-space: nowrap;'});

$("#mod_setting,.col-6").change( function () {
if($("[name=futidori_theme]").val() =="none"){
    localStorage.setItem('futidori_theme','none')
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});
}else if($("[name=futidori_theme]").val() =="solid"){
    localStorage.setItem('futidori_theme','solid')
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});
}else if($("[name=futidori_theme]").val() =="double"){
    localStorage.setItem('futidori_theme','double')
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});
}else if($("[name=futidori_theme]").val() =="dashed"){
    localStorage.setItem('futidori_theme','dashed')
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});

}else if($("[name=futidori_theme]").val() =="dotted"){
    localStorage.setItem('futidori_theme','dotted')
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});

}else if($("[name=futidori_theme]").val() =="outset"){
    localStorage.setItem('futidori_theme','outset')
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});

}else if($("[name=futidori_theme]").val() =="groove"){
    localStorage.setItem('futidori_theme','groove')
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});

}else if($("[name=futidori_theme]").val() =="ridge"){
    localStorage.setItem('futidori_theme','ridge')
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});

}
if($("[name=futidori_border-width]").val() =="medium"){
    localStorage.setItem('futidori_border-width','medium')
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});

}else if($("[name=futidori_border-width]").val() =="thin"){
    localStorage.setItem('futidori_border-width','thin')
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});

}else if($("[name=futidori_border-width]").val() =="thick"){
    localStorage.setItem('futidori_border-width','thick')
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});

}


if($("[name=color_theme]").val() =="デフォルト"){
color_default()
}else if($("[name=color_theme]").val() =="先頭の文字を赤く強調"){
letter_red()
}

//チェックボックス設定保存 判別(サーバーに保存する機能ができ次第削除)ここから
if($("[value=sub]").prop("checked")){
    localStorage.setItem('sub',1)
}else{
    localStorage.setItem('sub',0)
}
if($("[value=eng_highlight]").prop("checked")){
    localStorage.setItem('eng_highlight',1)
}else{
    localStorage.setItem('eng_highlight',0)
}
if($("[value=letter_scroll]").prop("checked")){
    localStorage.setItem('letter_scroll',1)
}else{
    localStorage.setItem('letter_scroll',0)
}if($("[value=next_lyric_hidden]").prop("checked")){
    localStorage.setItem('next_lyric_hidden',1)
}else{
    localStorage.setItem('next_lyric_hidden',0)
}if($("[value=line_hidden]").prop("checked")){
    localStorage.setItem('line_hidden',1)
}else{
    localStorage.setItem('line_hidden',0)
}if($("[value=type_sound]").prop("checked")){
    localStorage.setItem('type_sound',1)
}else{
    localStorage.setItem('type_sound',0)
}if($("[value=miss_sound]").prop("checked")){
    localStorage.setItem('miss_sound',1)
}else{
    localStorage.setItem('miss_sound',0)
}if($("[value=clear_sound]").prop("checked")){
    localStorage.setItem('clear_sound',1)
}else{
    localStorage.setItem('clear_sound',0)
}if($("[value=combo_break_sound]").prop("checked")){
    localStorage.setItem('combo_break_sound',1)
}else{
    localStorage.setItem('combo_break_sound',0)
}if($("[value=Interlocking_volume]").prop("checked")){
    localStorage.setItem('Interlocking_volume',1)
}else{
    localStorage.setItem('Interlocking_volume',0)
}if($("[value=sec]").prop("checked")){
    localStorage.setItem('sec_kpm',1)
}else if($("[value=kpm]").prop("checked")){
    localStorage.setItem('sec_kpm',0)
}if($("[value=miss_on]").prop("checked")){
    localStorage.setItem('miss_on',1)
}else{
    localStorage.setItem('miss_on',0)
}if($("[value=anime_count]").prop("checked")){
    localStorage.setItem('anime_count',1)
}else{
    localStorage.setItem('anime_count',0)
}if($("[value=skip_guide]").prop("checked")){
    localStorage.setItem('skip_guide',1)
}else{
    localStorage.setItem('skip_guide',0)
}if($("[value=bolding]").prop("checked")){
    localStorage.setItem('bolding',1)
}else{
    localStorage.setItem('bolding',0)
}if($("[value=character_spacing]").prop("checked")){
    localStorage.setItem('character_spacing',1)
}else{
    localStorage.setItem('character_spacing',0)
}if($("[value=font_Gothic]").prop("checked")){
    localStorage.setItem('font_Gothic',1)
}else{
    localStorage.setItem('font_Gothic',0)
}

if($("[value=kana_type]").prop("checked")){
    localStorage.setItem('mode_select',0)
}else if($("[value=roma_type]").prop("checked")){
    localStorage.setItem('mode_select',1)
}else if($("[value=kanamode_type]").prop("checked")){
    localStorage.setItem('mode_select',2)
}else if($("[value=kanamode_mac_type]").prop("checked")){
    localStorage.setItem('mode_select',3)
}
//チェックボックス設定保存 判別(サーバーに保存する機能ができ次第削除)ここまで

})

function color_default(){
$("[name=first_color],[name=lyric_color],[name=word_color]").val("#FFFFFF")
$("[name=first_color],[name=lyric_color],[name=word_color]").css({'cssText':'background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);'});
$("[name=correctword_color]").val("#0099CC")
$("[name=correctword_color]").css({'cssText':'background-color: rgb(0, 153, 204); color: rgb(255, 255, 255);'});
$("[name=lineclear_color]").val("#1eff52")
$("[name=lineclear_color]").css({'cssText':'background-color: rgb(30, 255, 82); color: rgb(255, 255, 255);'});
$("[name=next_lyrics_color]").val("rgba(255,255,255,.7)")
$("[name=next_lyrics_color]").css({'cssText':'background-color: rgba(255, 255, 255, 0.7); color: rgb(0, 0, 0);'});
}
function letter_red(){
$("[name=first_color]").val("#FF0000")
$("[name=first_color]").css({'cssText':'background-color: rgb(255, 0, 0);color: rgb(255, 255, 255);'});
$("[name=lyric_color],[name=word_color]").val("#FFFFFF")
$("[name=lyric_color],[name=word_color]").css({'cssText':'background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);'});
$("[name=correctword_color]").val("#919395")
$("[name=correctword_color]").css({'cssText':'background-color: rgb(145, 147, 149); color: rgb(255, 255, 255);'});
$("[name=lineclear_color]").val("#919395")
$("[name=lineclear_color]").css({'cssText':'background-color: rgb(145, 147, 149); color: rgb(255, 255, 255);'});
$("[name=next_lyrics_color]").val("rgba(255,255,255,.7)")
$("[name=next_lyrics_color]").css({'cssText':'background-color: rgba(255, 255, 255, 0.7); color: rgb(0, 0, 0);'});
}


//設定・「歌詞を見る」を選択したときに出るwindow
function mod_setting_open() {
//モーダルウィンドウを出現させるクリックイベント
$(".fa-cog").click( function () {

    //キーボード操作などにより、オーバーレイが多重起動するのを防止する
    $( this ).blur();  //ボタンからフォーカスを外す
    if ( $( "#modal-overlay" )[0] ) return false;       //新しくモーダルウィンドウを起動しない (防止策1)

    //オーバーレイを出現させる
$("body").append('<div id="modal-overlay" style="z-index:888;display:none;position:fixed;top:0;left:0;width:100%;height:120%;"></div>');
    $( "#modal-overlay" ).fadeIn( "fast" );

    //コンテンツをセンタリングする
    centering();

    //コンテンツをフェードインする
    $("#mod_setting").fadeIn( "fast" );
    //[#modal-overlay]、をクリックしたら#mod_settingを閉じる
    $( "#modal-overlay,#modal-close" ).unbind().click( function () {
        $( "#mod_setting,#modal-overlay" ).fadeOut( "fast" , function () {
            //[#modal-overlay]を削除する
            $('#modal-overlay').remove();
        });
    });
});

$( window ).resize( centering );
    //センタリングを実行する関数
    function centering() {

        //画面(ウィンドウ)の幅、高さを取得
        var w = $( window ).width();
        var h = $( window ).height();

        // コンテンツ(#mod_setting)の幅、高さを取得
        var cw = $("#mod_setting").outerWidth();
        var ch = $("#mod_setting").outerHeight();

        //センタリングを実行する
        if ($("[value=css_check]").prop("checked")) {

        $("#mod_setting").css( {"left": ((w - cw)/1.7)+ "px","top": ((h - ch)/1.9) + "px"} );
        } else {
            $("#mod_setting").css( {"left": ((w - cw))+ "px","top": ((h - ch)/4) + "px"} );
        }
    }
}
function typing_lyric_open(){
    $(function(){

//モーダルウィンドウを出現させるクリックイベント
$("#modal-open").click( function(){

    //キーボード操作などにより、オーバーレイが多重起動するのを防止する
    $( this ).blur() ;  //ボタンからフォーカスを外す
    if( $( "#modal-overlay1" )[0] ) return false ;      //新しくモーダルウィンドウを起動しない (防止策1)
    //if($("#modal-overlay")[0]) $("#modal-overlay").remove() ;     //現在のモーダルウィンドウを削除して新しく起動する (防止策2)

    //オーバーレイを出現させる
$("body").append('<div id="modal-overlay1" style="z-index:888;display:none;position:fixed;top:0;left:0;width:100%;height:120%;background-color:rgba(0,0,0,.8);"></div>');
    $( "#modal-overlay1" ).fadeIn( "nomal" ) ;

    //コンテンツをセンタリングする
    centeringModalSyncer() ;

    //コンテンツをフェードインする
    $( "#typing_lyrics" ).fadeIn( "nomal" ) ;

    //[#modal-overlay]、または[#modal-close]をクリックしたら…
    $( "#modal-overlay1" ).unbind().click( function(){

        //[#modal-content]と[#modal-overlay]をフェードアウトした後に…
        $( "#typing_lyrics,#modal-overlay1" ).fadeOut( "nomal" , function(){

            //[#modal-overlay]を削除する
            $('#modal-overlay1').remove() ;

        } ) ;

    } ) ;

} ) ;

//リサイズされたら、センタリングをする関数[centeringModalSyncer()]を実行する
$( window ).resize( centeringModalSyncer ) ;

    //センタリングを実行する関数
    function centeringModalSyncer() {

        //画面(ウィンドウ)の幅、高さを取得
        var w = $( window ).width() ;
        var h = $( window ).height() ;

        // コンテンツ(#modal-content)の幅、高さを取得
        // jQueryのバージョンによっては、引数[{margin:true}]を指定した時、不具合を起こします。
//      var cw = $( "#modal-content" ).outerWidth( {margin:true} );
//      var ch = $( "#modal-content" ).outerHeight( {margin:true} );
        var cw = $( "#typing_lyrics" ).outerWidth();
        var ch = $( "#typing_lyrics" ).outerHeight();

        //センタリングを実行する
                if($("[value=css_check]").prop("checked")){
$( "#typing_lyrics" ).css( {"left": ((w - cw)/2) + "px","top": ((h - ch)/2.5) + "px"} ) ;

                }
        else{
        $( "#typing_lyrics" ).css( {"left": ((w - cw)/2) + "px","top": ((h - ch)/2) + "px"} ) ;
        }
    }

} ) ;
}

function load_sound(){
    combo_break = new Audio();
    combo_break.src = "/sounds/combo_break.mp3";
    combo_break.preload


}

function add_css(){
var stylesheet = document.styleSheets.item(0)
    stylesheet.insertRule("[data-kana]{    position: relative;}", 1);
    stylesheet.insertRule(".missmark::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -2px;right: 0;margin: auto;font-size: 1.4em;}",3);
    stylesheet.insertRule(".missmark1::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -3.2px;right: 0;margin: auto;font-size: 1.4em;}", 4);
    stylesheet.insertRule(".missmark2::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -5.4px;right: 0;margin: auto;font-size: 1.4em;}", 5);
    stylesheet.insertRule(".missmark3::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -5.9px;right: 0;margin: auto;font-size: 1.4em;}", 6);
    stylesheet.insertRule(".missmark4::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -6.2px;right: 0;margin: auto;font-size: 1.4em;}", 7);
    stylesheet.insertRule(".missmark5::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -6.7px;right: 0;margin: auto;font-size: 1.4em;}", 8);
    stylesheet.insertRule(".missmark6::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -7.7px;right: 0;margin: auto;font-size: 1.4em;}", 9);
    stylesheet.insertRule(".missmark7::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -8.2px;right: 0;margin: auto;font-size: 1.4em;}", 10);
    stylesheet.insertRule(".missmark8::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -8.5px;right: 0;margin: auto;font-size: 1.4em;}", 11);
    stylesheet.insertRule(".missmark9::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -9.2px;right: 0;margin: auto;font-size: 1.4em;}", 12);
    stylesheet.insertRule(".missmark10::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -2.8px;right: 0;margin: auto;font-size: 1.4em;}", 13);
    stylesheet.insertRule(".missmark11::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -4px;right: 0;margin: auto;font-size: 1.4em;}", 14);
    stylesheet.insertRule(".missmark12::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -5.3px;right: 0;margin: auto;font-size: 1.4em;}", 15);
    stylesheet.insertRule(".missmark13::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -5.8px;right: 0;margin: auto;font-size: 1.4em;}", 16);
    stylesheet.insertRule(".missmark14::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -4.7px;right: 0;margin: auto;font-size: 1.4em;}", 17);
    stylesheet.insertRule(".missmark15::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -7.3px;right: 0;margin: auto;font-size: 1.4em;}", 18);
    stylesheet.insertRule(".missmark16::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -5px;right: 0;margin: auto;font-size: 1.4em;}", 19);
    stylesheet.insertRule(".missmark17::before{    content: attr(data-kana);position: absolute;top: -.49em;left:-5.5px;right: 0;margin: auto;font-size: 1.4em;}", 20);
    stylesheet.insertRule(".missmark18::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -2.7px;right: 0;margin: auto;font-size: 1.4em;}", 21);
    stylesheet.insertRule(".missmark19::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -7.9px;right: 0;margin: auto;font-size: 1.4em;}", 22);
    stylesheet.insertRule(".missmark20::before{    content: attr(data-kana);position: absolute;top: -.49em;left: -4.4px;right: 0;margin: auto;font-size: 1.4em;}", 23);
    stylesheet.insertRule("#kashi_roma:after{content:'\u200b';}", 24);
    stylesheet.insertRule("#kashi_sub:after{content:'\u200b';}", 25);
    stylesheet.insertRule(".fa-cog:hover{transform:rotate(90deg);}", 26);
    stylesheet.insertRule('.gothicfont{font-family:"游ゴシック", "Yu Gothic"!important;}',27);
    stylesheet.insertRule('#kashi_area{cursor:none!important;}',29);
    stylesheet.insertRule("[onclick='submit_score()']:after{content:'Enterキーでランキング送信';}", 30);
    stylesheet.insertRule(".letter_space{letter-spacing: 0.7px;}", 31);
    stylesheet.insertRule(".letter_bold{font-weight:600;}", 32);
    stylesheet.insertRule(".letter_nomal{font-weight:500!important;}", 33);
    stylesheet.insertRule(".kashi_hidden{visibility: hidden;}", 34);
    stylesheet.insertRule(".line_hidden{visibility: hidden;}", 35);
    stylesheet.insertRule(".letter_scroll{white-space: nowrap;position:relative;height:24px;overflow:hidden;}", 36);
//MOD適応前の#kashi_romaスタイルを隠す↓
  stylesheet.insertRule("#kashi_roma{visibility: hidden;font-size:17.5px;word-break: break-all;}", 37);
    stylesheet.insertRule(".progress{margin-bottom: 0!important;}", 38);
    stylesheet.insertRule(".sub_margin{margin-top: 0.5rem!important;}", 39);
    stylesheet.insertRule(".next_hidden{visibility: hidden!important;white-space: nowrap;overflow:hidden;}", 40);
    stylesheet.insertRule("#mod_setting label,.col-6 label{cursor: pointer;}", 41);
    stylesheet.insertRule("#mod_setting label{margin-right: 5px;}", 42);
    stylesheet.insertRule("#skip_guide:after{content:'\u200b';}", 43);
    stylesheet.insertRule("#kashi_next:after{content:'\u200b';}", 44);
    stylesheet.insertRule("#next_kpm:after{content:'\u200b';}", 45);
    stylesheet.insertRule('#kashi_next{margin-top:0px!important;}',46);
    stylesheet.insertRule('#modal-open:hover{  cursor: pointer;text-decoration : underline;}',47);
    stylesheet.insertRule('#controlbox .col-6{padding-right: 0!important;}',48);
    stylesheet.insertRule('#controlbox{margin-left:0px!important;}',49);
// stylesheet.insertRule('#main_content{padding-left:0px!important;}',50);

}

//設定関連の処理
function read_localstorage(){

//正当音ボリューム
if(!localStorage.getItem('ef_volume_type')){
    $('[name="effect_volume_type"]').val('80')
    localStorage.setItem('ef_volume_type',80)
}else if(localStorage.getItem('ef_volume_type')){
$('[name="effect_volume_type"]').val(localStorage.getItem('ef_volume_type'))
}

//ミス音個別ボリューム
if(!localStorage.getItem('ef_volume_miss')){
    $('[name="effect_volume_miss"]').val('80')
    localStorage.setItem('ef_volume_miss',80)
}else if(localStorage.getItem('ef_volume_miss')){
$('[name="effect_volume_miss"]').val(localStorage.getItem('ef_volume_miss'))
}

//ラインクリア音個別ボリューム
if(!localStorage.getItem('ef_volume_clear')){
    $('[name="effect_volume_clear"]').val('80')
    localStorage.setItem('ef_volume_clear',80)
}else if(localStorage.getItem('ef_volume_clear')){
$('[name="effect_volume_clear"]').val(localStorage.getItem('ef_volume_clear'))
}

//ラインクリア音個別ボリューム
if(!localStorage.getItem('ef_volume_combo_break')){
    $('[name="effect_volume_combo_break"]').val('80')
    localStorage.setItem('ef_volume_combo_break',80)
}else if(localStorage.getItem('ef_volume_combo_break')){
$('[name="effect_volume_combo_break"]').val(localStorage.getItem('ef_volume_combo_break'))
}
//BGMボリューム
if(!localStorage.getItem('volume_storage')){
    localStorage.setItem('volume_storage',70)
    $('#volume').html(localStorage.getItem('volume_storage'));

}else if (localStorage.getItem('volume_storage')) {
    $('#volume').html(localStorage.getItem('volume_storage'));

var volume_change = setInterval(function(){
if (typeof lyrics_array !== 'undefined') {
    player.setVolume(localStorage.getItem('volume_storage'));
    clearInterval(volume_change);
}
})
}
/*
//hiddenモード隠す文字数
if(!localStorage.getItem('hide_letter')){
    $('[name="hide_letter"]').val(3)
        localStorage.setItem('hide_letter',3)

}else if(localStorage.getItem('hide_letter')){
    $('[name="hide_letter"]').val(localStorage.getItem('hide_letter'))
}
*/

//かな表示スクロール文字数
if(!localStorage.getItem('letter_scroll_kana')){
    $('[name="letter_scroll_kana"]').val(10)
        localStorage.setItem('letter_scroll_kana',10)

}else if(localStorage.getItem('letter_scroll_kana')){
    $('[name="letter_scroll_kana"]').val(localStorage.getItem('letter_scroll_kana'))
}

//ローマ字表示スクロール文字数
if(!localStorage.getItem('letter_scroll_roma')){
    $('[name="letter_scroll_roma"]').val(16)
        localStorage.setItem('letter_scroll_roma',16)

}else if(localStorage.getItem('letter_scroll_roma')){
    $('[name="letter_scroll_roma"]').val(localStorage.getItem('letter_scroll_roma'))
}

//ミスエフェクト色
if(!localStorage.getItem('miss_color')){
    localStorage.setItem('miss_color',"#FF3554")
}else if(localStorage.getItem('miss_color')){
$('[name="miss_color"]').val(localStorage.getItem('miss_color'))
}

if(!localStorage.getItem('countdown_color')){
    localStorage.setItem('countdown_color',"rgba(255,255,255,0.9)")
}else if(localStorage.getItem('countdown_color')){
$('[name="countdown_color"]').val(localStorage.getItem('countdown_color'))
}

if(!localStorage.getItem('skipguide_color')){
    localStorage.setItem('skipguide_color',"rgba(255,255,255,0.53)")
}else if(localStorage.getItem('skipguide_color')){
$('[name="skipguide_color"]').val(localStorage.getItem('skipguide_color'))
}

//先頭の文字を強調する色
if(!localStorage.getItem('first_color1')){
    localStorage.setItem('first_color1',"#FFFFFF")
}else if(localStorage.getItem('first_color1')){
$('[name="first_color"]').val(localStorage.getItem('first_color1'))
}

if(!localStorage.getItem('playarea_color')){
    localStorage.setItem('playarea_color',"rgba(255,255,255,0)")
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});
}else if(localStorage.getItem('playarea_color')){
$('[name="playarea_color"]').val(localStorage.getItem('playarea_color'))
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});
}

if(!localStorage.getItem('playarea_radius')){
    localStorage.setItem('playarea_radius',0)
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});
}else if(localStorage.getItem('playarea_radius')){
$('[name="playarea_radius"]').val(localStorage.getItem('playarea_radius'))
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});
}

if(!localStorage.getItem('futidori_theme')){
    localStorage.setItem('futidori_theme','none')
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;padding-top:6px;padding-bottom:6px;'});
}else if(localStorage.getItem('futidori_theme')){
$($("[name=futidori_theme]").val(localStorage.getItem('futidori_theme'))).prop('selected', true);
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;padding-top:6px;padding-bottom:6px;'});
}

if(!localStorage.getItem('futidori_border-width')){
    localStorage.setItem('futidori_border-width','medium')
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});
}else if(localStorage.getItem('futidori_border-width')){
$($("[name=futidori_border-width]").val(localStorage.getItem('futidori_border-width'))).prop('selected', true);
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});
}

if(!localStorage.getItem('futidori_color')){
    localStorage.setItem('futidori_color',"#FFFFFF")
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});
}else if(localStorage.getItem('futidori_color')){
$('[name="futidori_color"]').val(localStorage.getItem('futidori_color'))
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});
}

if(!localStorage.getItem('correctword_color')){
    localStorage.setItem('correctword_color',"#0099CC")
}else if(localStorage.getItem('correctword_color')){
$('[name="correctword_color"]').val(localStorage.getItem('correctword_color'))
}

if(!localStorage.getItem('lineclear_color')){
    localStorage.setItem('lineclear_color',"#1eff52")
}else if(localStorage.getItem('lineclear_color')){
$('[name="lineclear_color"]').val(localStorage.getItem('lineclear_color'))
}

if(!localStorage.getItem('word_color')){
    localStorage.setItem('word_color',"#FFFFFF")
}else if(localStorage.getItem('word_color')){
$('[name="word_color"]').val(localStorage.getItem('word_color'))
}


if(!localStorage.getItem('lyric_color')){
    localStorage.setItem('lyric_color',"#FFFFFF")
}else if(localStorage.getItem('lyric_color')){
$('[name="lyric_color"]').val(localStorage.getItem('lyric_color'))


}if(!localStorage.getItem('next_lyrics_color')){
    localStorage.setItem('next_lyrics_color',"rgba(255,255,255,.7)")
}else if(localStorage.getItem('next_lyrics_color')){
$('[name="next_lyrics_color"]').val(localStorage.getItem('next_lyrics_color'))
}

//ここからチェックボックス保存(サーバーで保存される機能実装までの仮実装)

if(!localStorage.getItem('sub')){
    localStorage.setItem('sub',1)
}else if(localStorage.getItem('sub') == 0){
$("[value=sub]").prop('checked', false);
}
if(!localStorage.getItem('eng_highlight')){
    localStorage.setItem('eng_highlight',0)
}else if(localStorage.getItem('eng_highlight') == 1){
$("[value=eng_highlight]").prop('checked', true);
}
if(!localStorage.getItem('letter_scroll')){
    localStorage.setItem('letter_scroll',0)
}else if(localStorage.getItem('letter_scroll') == 1){
$("[value=letter_scroll]").prop('checked', true);
}if(!localStorage.getItem('next_lyric_hidden')){
    localStorage.setItem('next_lyric_hidden',0)
}else if(localStorage.getItem('next_lyric_hidden') == 1){
$("[value=next_lyric_hidden]").prop('checked', true);
}if(!localStorage.getItem('line_hidden')){
    localStorage.setItem('line_hidden',0)
}else if(localStorage.getItem('line_hidden') == 1){
$("[value=line_hidden]").prop('checked', true);
}if(!localStorage.getItem('type_sound')){
    localStorage.setItem('type_sound',0)
}else if(localStorage.getItem('type_sound') == 1){
$("[value=type_sound]").prop('checked', true);
}if(!localStorage.getItem('miss_sound')){
    localStorage.setItem('miss_sound',0)
}else if(localStorage.getItem('miss_sound') == 1){
$("[value=miss_sound]").prop('checked', true);
}if(!localStorage.getItem('clear_sound')){
    localStorage.setItem('clear_sound',0)
}else if(localStorage.getItem('clear_sound') == 1){
$("[value=clear_sound]").prop('checked', true);
}if(!localStorage.getItem('combo_break_sound')){
    localStorage.setItem('combo_break_sound',0)
}else if(localStorage.getItem('combo_break_sound') == 1){
$("[value=combo_break_sound]").prop('checked', true);
}if(!localStorage.getItem('sec_kpm')){
    localStorage.setItem('sec_kpm',1)
}else if(localStorage.getItem('sec_kpm') == 0){
$("[value=kpm]").prop('checked', true);
}if(!localStorage.getItem('miss_on')){
    localStorage.setItem('miss_on',1)
}else if(localStorage.getItem('miss_on') == 0){
$("[value=miss_on]").prop('checked', false);
}if(!localStorage.getItem('anime_count')){
    localStorage.setItem('anime_count',1)
}else if(localStorage.getItem('anime_count') == 0){
$("[value=anime_count]").prop('checked', false);
}if(!localStorage.getItem('skip_guide')){
    localStorage.setItem('skip_guide',1)
}else if(localStorage.getItem('skip_guide') == 0){
$("[value=skip_guide]").prop('checked', false);
}if(!localStorage.getItem('font_Gothic')){
    localStorage.setItem('font_Gothic',1)
}else if(localStorage.getItem('font_Gothic') == 0){
$("[value=font_Gothic]").prop('checked', false);
}if(!localStorage.getItem('bolding')){
    localStorage.setItem('bolding',1)
}else if(localStorage.getItem('bolding') == 0){
$("[value=bolding]").prop('checked', false);
}if(!localStorage.getItem('character_spacing')){
    localStorage.setItem('character_spacing',0)
}else if(localStorage.getItem('character_spacing') == 1){
$("[value=character_spacing]").prop('checked', true);
}

if(!localStorage.getItem('mode_select')){
    localStorage.setItem('mode_select',0)
}else if(localStorage.getItem('mode_select') == 1){
$("[value=roma_type]").prop('checked', true);
}else if(localStorage.getItem('mode_select') == 2){
$("[value=kanamode_type]").prop('checked', true);
}else if(localStorage.getItem('mode_select') == 3){
$("[value=kanamode_mac_type]").prop('checked', true);
}
//チェックボックス保存ここまで(サーバー保存の機能ができ次第削除)
}
function localstrage_save(){
if(!document.webkitHidden){
if(localStorage.getItem('ef_volume_type') != $('[name="effect_volume_type"]').val()){
    localStorage.setItem('ef_volume_type',$('[name="effect_volume_type"]').val())
}
if(localStorage.getItem('ef_volume_miss') != $('[name="effect_volume_miss"]').val()){
    localStorage.setItem('ef_volume_miss',$('[name="effect_volume_miss"]').val())
}
if(localStorage.getItem('ef_volume_clear') != $('[name="effect_volume_clear"]').val()){
    localStorage.setItem('ef_volume_clear',$('[name="effect_volume_clear"]').val())
}
if(localStorage.getItem('ef_volume_combo_break') != $('[name="effect_volume_combo_break"]').val()){
    localStorage.setItem('ef_volume_combo_break',$('[name="effect_volume_combo_break"]').val())
}
/*
if(localStorage.getItem('hide_letter') != $('[name="hide_letter"]').val()){
    localStorage.setItem('hide_letter',$('[name="hide_letter"]').val())
}
*/
if(localStorage.getItem('letter_scroll_kana') != $('[name="letter_scroll_kana"]').val()){
    localStorage.setItem('letter_scroll_kana',$('[name="letter_scroll_kana"]').val())
}
if(localStorage.getItem('letter_scroll_roma') != $('[name="letter_scroll_roma"]').val()){
    localStorage.setItem('letter_scroll_roma',$('[name="letter_scroll_roma"]').val())
}
if(localStorage.getItem('volume_storage') != $('#volume').text() && !finished){
    localStorage.setItem('volume_storage', $('#volume').text())
}
if(localStorage.getItem('miss_color') != $('[name="miss_color"]').val()){
    localStorage.setItem('miss_color', $('[name="miss_color"]').val())
    updateLineView();
}
if(localStorage.getItem('countdown_color') != $('[name="countdown_color"]').val()){
    localStorage.setItem('countdown_color', $('[name="countdown_color"]').val())
}
if(localStorage.getItem('skipguide_color') != $('[name="skipguide_color"]').val()){
    localStorage.setItem('skipguide_color', $('[name="skipguide_color"]').val())
}
if(localStorage.getItem('first_color1') != $('[name="first_color"]').val()){
    localStorage.setItem('first_color1', $('[name="first_color"]').val())
    updateLineView();

}
if(localStorage.getItem('playarea_color') != $('[name="playarea_color"]').val()){
    localStorage.setItem('playarea_color', $('[name="playarea_color"]').val())
    updateLineView();
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});
}

if(localStorage.getItem('playarea_radius') != $('[name="playarea_radius"]').val()){
    localStorage.setItem('playarea_radius', $('[name="playarea_radius"]').val())
    updateLineView();
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});
}

if(localStorage.getItem('futidori_color') != $('[name="futidori_color"]').val()){
    localStorage.setItem('futidori_color', $('[name="futidori_color"]').val())
    updateLineView();
$("#controlbox").css({'cssText':'background:'+localStorage.getItem("playarea_color")+';border-radius:'+localStorage.getItem('playarea_radius')+'px;border:'+localStorage.getItem('futidori_theme')+';border-color:'+localStorage.getItem('futidori_color')+';border-width:'+localStorage.getItem('futidori_border-width')+';padding-top:6px;padding-bottom:6px;'});
}

if(localStorage.getItem('correctword_color') != $('[name="correctword_color"]').val()){
    localStorage.setItem('correctword_color', $('[name="correctword_color"]').val())
    updateLineView();

}

if(localStorage.getItem('lineclear_color') != $('[name="lineclear_color"]').val()){
    localStorage.setItem('lineclear_color', $('[name="lineclear_color"]').val())
    updateLineView();

}
if(localStorage.getItem('word_color') != $('[name="word_color"]').val()){
    localStorage.setItem('word_color', $('[name="word_color"]').val())
    updateLineView();

}
if(localStorage.getItem('lyric_color') != $('[name="lyric_color"]').val()){
    localStorage.setItem('lyric_color', $('[name="lyric_color"]').val())
$("#kashi").css({'cssText':'margin-top:0!important;color:'+localStorage.getItem('lyric_color')+';'});

}
if(localStorage.getItem('next_lyrics_color') != $('[name="next_lyrics_color"]').val()){
    localStorage.setItem('next_lyrics_color', $('[name="next_lyrics_color"]').val())
$("#kashi_next").css({'cssText':'margin-bottom:0!important;color:'+localStorage.getItem('next_lyrics_color')+';'});
$("#kpm_color").css({'cssText':'color:'+localStorage.getItem('next_lyrics_color')+';'});
}


}
}
function checkbox_check(){
if(!is_played && play_mode == "normal"){
if($("[value=kana_type]").prop("checked")){
kana_mode = false
mode='kana'
keyboard='normal';
$("#kashi_roma").css({'cssText':'margin-bottom: 0 !important;'});
}else if($("[value=roma_type]").prop("checked")){
kana_mode = false
mode='roma'
keyboard='normal';
$("#kashi_roma").css({'cssText':'margin-bottom: 0 !important;'});
}else if($("[value=kanamode_type]").prop("checked")){
kana_mode = true
mode='kana'
keyboard='normal';
$("#kashi_roma").css({'cssText':'margin-bottom: 0 !important;'+'visibility:visible!important;'});
}else if($("[value=kanamode_mac_type]").prop("checked")){
kana_mode = true
mode='kana'
keyboard='mac';
$("#kashi_roma").css({'cssText':'margin-bottom: 0 !important;'+'visibility:visible!important;'});
}
}
if (is_played && !finished && player.getPlayerState() == 1) {
if($("[value=Interlocking_volume]").prop("checked")){
if($('#volume').text()){
    combo_break.volume = ($('#volume').text()/100)
}}
    else{
    combo_break.volume = $('[name="effect_volume_miss"]').val()/100
}}



//游ゴシック体表示
if($("[value=font_Gothic]").prop("checked")){
$('#kashi_roma,#kashi_sub').addClass('gothicfont')
}else{
$('#kashi_roma,#kashi_sub').removeClass('gothicfont')
}
if(typeof lyrics_array !== 'undefined'){

if($("[value=next_lyric_hidden]").prop("checked")){
if(lyrics_array[count][1] != 'end' && !lyrics_array[count][2]){
$('#kashi_next').addClass('next_hidden')
}else{
$('#kashi_next').removeClass('next_hidden')
}
}else{
$('#kashi_next').removeClass('next_hidden')
}
}
//ボリューム連動ONで個別ボリューム設定を変更不可にする
if($("[value=Interlocking_volume]").prop("checked")){
$('[name*="effect_volume"]').attr('disabled',true)
$('[name*="effect_volume"]').css({'cssText':'display:none;'});

}else{
$('[name*="effect_volume"]').attr('disabled',false)
$('[name*="effect_volume"]').css({'cssText':'display:block;'});
}

//入力歌詞の文字間隔を開ける
if($("[value=character_spacing]").prop("checked")){
$( "#kashi_sub,#kashi_roma" ).addClass("letter_space")
}else{
$( "#kashi_sub,#kashi_roma" ).removeClass("letter_space")
}

//太字設定
if($("[value=bolding]").prop("checked")){
$( "#kashi_sub,#kashi_roma" ).addClass("letter_bold")
.removeClass("letter_nomal")
}else{
$( "#kashi_sub,#kashi_roma" ).removeClass("letter_bold")
.addClass("letter_nomal")
}if($("[value=line_hidden]").prop("checked")){
$( "#kashi_next,#next_kpm" ).addClass("kashi_hidden")
}else{
$( "#kashi_next,#next_kpm" ).removeClass("kashi_hidden")
}if($("[value=line_hidden]").prop("checked")){
$(".bg-info").addClass("line_hidden")
}else{
$(".bg-info").removeClass("line_hidden")
}if($("[value=letter_scroll]").prop("checked") && !kana_mode){
$("#kashi_roma,#kashi_sub").addClass("letter_scroll")
    .removeClass("mt-2")
$("#kashi_sub").addClass("sub_margin")
}else{
$("#kashi_roma,#kashi_sub").removeClass("letter_scroll")
    .addClass("mt-2")
$("#kashi_sub").removeClass("sub_margin")
}

if (typeof lyrics_array !== 'undefined' && $('#difficult > span').text() == "" &&((difficulty_average/difficulty.length)*player.getPlaybackRate()) >= 0) {
 $('.share').prepend('<div id="difficult" style="color: #fd5;font-weight: 600;"><span style="border-radius: 16px;padding: 3px;background-color: rgba(0,0,0,.60);" id="modal-open" class="button-link"></span></div>')
typing_lyric_open()
movie_time = parseInt(lyrics_array[lyrics_array.length-1][0])/$("#speed").text()
movie_mm =("00" + parseInt(parseInt(movie_time) / 60)).slice(-2)
movie_ss = ("00" +(parseInt(movie_time) - movie_mm * 60)).slice(-2)
    if($("[value=sec]").prop("checked")){
$('#difficult > span').html('<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+(200000 / score_per_char).toFixed(0) + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+$("#typing_lyrics .type_length:eq(0)").text()+'line</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+((difficulty_average/difficulty.length)*$("#speed").text()).toFixed(2)+'打/秒, 最高'+(Math.max.apply(null, difficulty)*$("#speed").text()).toFixed(2)+'打/秒</span>')
}else{
$('#difficult > span').html('<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+(200000 / score_per_char).toFixed(0) + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+$("#typing_lyrics .type_length:eq(0)").text()+'line</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+(((difficulty_average/difficulty.length)*$("#speed").text())*60).toFixed(0)+'kpm, 最高'+((Math.max.apply(null, difficulty)*$("#speed").text())*60).toFixed(0)+'kpm</span>')
}
}

}



var observer = new MutationObserver(function(){
movie_time = parseInt(lyrics_array[lyrics_array.length-1][0])/$("#speed").text()
movie_mm =("00" + parseInt(parseInt(movie_time) / 60)).slice(-2)
movie_ss = ("00" +(parseInt(movie_time) - movie_mm * 60)).slice(-2)
    if($("[value=sec]").prop("checked")){
$('#difficult > span').html('<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+(200000 / score_per_char).toFixed(0) + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+$("#typing_lyrics .type_length:eq(0)").text()+'line</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+((difficulty_average/difficulty.length)*$("#speed").text()).toFixed(2)+'打/秒, 最高'+(Math.max.apply(null, difficulty)*$("#speed").text()).toFixed(2)+'打/秒</span>')
}else{
$('#difficult > span').html('<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+(200000 / score_per_char).toFixed(0) + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+$("#typing_lyrics .type_length:eq(0)").text()+'line</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+(((difficulty_average/difficulty.length)*$("#speed").text())*60).toFixed(0)+'kpm, 最高'+((Math.max.apply(null, difficulty)*$("#speed").text())*60).toFixed(0)+'kpm</span>')
}
});
/** 監視対象の要素オブジェクト */
const elem = document.getElementById('speed');

/** 監視時のオプション */
const config = {
  attributes: true,
  childList: true,
  characterData: true
};
/** 要素の変化監視をスタート */
observer.observe(elem, config);


//lyrics_arrayを読み込んで「歌詞を見る」を作成
function lyricsarray_reading(){
//lyrics_array変数が読み込まれたとき
var load_lyric = setInterval(function(){
if(typeof lyrics_array !== 'undefined'){

var lyrics_length = lyrics_array.length
var number_lyrics = 1
var typing_lyric = "<h5 style='margin-top:5px;'>タイピングワード一覧</h5>"
var line_length = typing_array_roma.filter( v => !!( '' + v )).length

$('<div id="typing_lyrics" style="border:2px solid #aaa;z-index:9999;display:none;font-size:120%;position:fixed;word-break: break-all;overflow: scroll; max-height: 500px;background-color: rgba(0,0,0,4.33);font-weight: 600;user-select: none !important;-ms-user-select: none !important;-moz-user-select: none !important;-webkit-user-select: none !important;">').insertAfter('.movietitle')

//lyrics_arrayを参照
for (let j = 0; j < lyrics_length; j++){

//lyrics_array[?][1]の先頭に空のルビタグを挿入(ルビあり時⇔ルビなし時の表示ズレ修正)
if(lyrics_array[j][1] != 'end'){
lyrics_array[j][1] = "<ruby>&#8203;<rt>&#8203;</rt></ruby>" + lyrics_array[j][1]
}

//lyrics_array[?][2]から[入力歌詞を見る]を生成
//譜面の平均打鍵速度を生成
if(lyrics_array[j][2] && lyrics_array[j][1] != 'end'){
difficulty.push((typing_array_roma[j].join('').length/(lyrics_array[j+1][0]-lyrics_array[j][0])).toFixed(2))
difficulty_average += (typing_array_roma[j].join('').length/(lyrics_array[j+1][0]-lyrics_array[j][0]))
typing_lyric += (number_lyrics +"/<span class='type_length'>"+line_length+"</span> ["+(typing_array_roma[j].join('').length/((lyrics_array[j+1][0]-lyrics_array[j][0])*player.getPlaybackRate())).toFixed(2)+'打/秒]('+(((typing_array_roma[j].join('').length/((lyrics_array[j+1][0]-lyrics_array[j][0])*player.getPlaybackRate())))*60).toFixed(0)+'kpm)<br><span>'+lyrics_array[j][2]+"</span><br><span style='text-transform:uppercase;'>"+typing_array_roma[j].join('')+"</span><br><br>")
number_lyrics = number_lyrics +1
}
}
//lyrics_arrayを参照 ここまで

//生成した入力歌詞を表示
$('#typing_lyrics').append(typing_lyric)
clearInterval(load_lyric);
}
})
}

//プレイ開始時に各機能で必要なDOMを追加
function play_preparation(){
var play_start = setInterval(function(){
    if (is_played) {

            $('.esckey').remove()
    $('<div id="next_kpm" style="font-size:12.5px;font-weight: 500;text-align-last:left;"></div><div id="total_time" style="font-weight: 600;color: #fff;text-align-last: right;height: 0px;"></div><div id="skip_guide" style="font-weight:400;text-align-last:left;">&nbsp;</div>').insertAfter('#kashi_next')

$('<div id="line_time" style="font-weight: 600;color: #fff;text-align-last: right;"></div>').insertBefore('#bar_input_base')
$('<div id="rank" style="font-size:16.9px;font-weight: 600;color: #fff;position:relative;top:-6px;white-space: nowrap;"></div>').insertAfter('#status')
$('<div id="count_anime" style="font-size:40px;font-weight: 600;text-align-last:center;height: 0px;"></div>').insertBefore('#kashi')//カウントダウンDOM追加
$("#line_time").html("&nbsp;")
$('.mt-3,#bar_base,#bar_input_base').css({'cssText':'margin-top:0!important;'})
$("#kashi").removeClass('text-white').css({'cssText':'margin-top:0!important;color:'+localStorage.getItem('lyric_color')+';'});
$("#kashi_next").removeClass('text-muted').css({'cssText':'margin-bottom:0!important;color:'+localStorage.getItem('next_lyrics_color')+';'});


if(kana_mode && play_mode == "practice"){
$("#kashi_roma").css({'cssText':'margin-bottom: 0 !important;'+'visibility:visible!important;'});
}
$(".col-8").css({'cssText':'flex: 0 0 75.66667%;'+'max-width: 75.66667%;'});
$(".col-4").css({'cssText':'flex: 0 0 24.33333%;'+'max-width: 24.33333%;'});
    player.setVolume(localStorage.getItem('volume_storage'));

clearInterval(play_start);
}
})
}
var movie_time;
var movie_mm;
var movie_ss;
//時間計算・時間を利用した機能
function time_calculation(){
if(typeof is_played !== 'undefined'){

if(is_played && player.getPlayerState() == 1){
if(!finished){


/**
*@時間計算
*/
var now_time = (player.getCurrentTime()+player.difftime)/player.getPlaybackRate()
var mm =("00" + parseInt(parseInt(now_time) / 60)).slice(-2)
var ss = ("00" +(parseInt(now_time) - mm * 60)).slice(-2)


//曲の経過時間を[分:秒]で表示
$("#total_time").html(mm + ':' + ss + " / " + movie_mm+':'+movie_ss)


/**
*@ライン経過時間計算
*/
if(count != count_save){//ライン切り替わり直後
$("#count_anime").html("")
skip_flag=false
count_save = count //フラグON
if(count >= 2){//2ライン目以降
if(lyrics_array[count-2][2] && typing_count_save == typing_count && count > logcount){
inputline_counter.push(count-1)
  $("span").removeClass("missmark");
}

if(line_typingspeed == 0 && lyrics_array[count-2][2] == ''){
    kpmlog.push(kpmlog[kpmlog.length-1])
    rkpmlog.push(rkpmlog[rkpmlog.length-1])
    nokorimoji_log.push(nokorimoji_log[nokorimoji_log.length-1])
    line_misscount.push(line_misscount[line_misscount.length-1])
    latencylog.push(latencylog[latencylog.length-1])
}else if(line_typingspeed == 0 && lyrics_array[count-2][2] != ''){
    kpmlog.push(0)
    rkpmlog.push(0)
    nokorimoji_log.push(nokorimoji)
    line_misscount.push((typing_miss_count-misstyping_count_save))
    latencylog.push('null')
}
    else if(line_typingspeed != 0 && lyrics_array[count-2][2] != ''){
    kpmlog.push((line_typingspeed).toFixed(2))
    rkpmlog.push((line_typingspeed_rkpm).toFixed(2))
    nokorimoji_log.push(nokorimoji)
    line_misscount.push((typing_miss_count-misstyping_count_save))
    latencylog.push(latency.toFixed(3))

}
    nokorimoji = next_char[1]+line_input_roma.join('')
    misstyping_count_save = typing_miss_count
typing_count_save = typing_count //現在ラインの打鍵数を出す

latency_flag=false

if(lyrics_array[count].length == 2){
    lyrics_array[count].push('')
}

if(lyrics_array[count - 2][2]){
if(!line_clear){//③ラインクリア失敗時
playing_time += (lyrics_array[count - 1][0]-lyrics_array[count - 2][0])/player.getPlaybackRate()//ライン時間を加算
    }else {//③ラインクリアしていたらフラグのみ初期化
line_clear = false
}
}
if(countdown_anime){

countdown_anime = false //間奏でのカウントダウンフラグOFF
}
}
}


line_typingspeed = (typing_count-typing_count_save)/linetyping_sec
line_typingspeed_rkpm = (typing_count-typing_count_save)/ (linetyping_sec-latency)
typing_speed = (typing_count/playing_time_current)
//①ラインの経過時間を計測、過去のライン時間から累計時間を出す
if(count >= 1){
linetyping_sec = (time_buf - lyrics_array[count - 1][0])/player.getPlaybackRate()
}
if(next_char[0] && !completed){
playing_time_current = linetyping_sec + playing_time
if(!latency_flag){
latency = (linetyping_sec)
if(already_input_roma.length == 1 ||already_input.length == 1){
latency_flag=true
}
}
}
//②ラインクリアした時
else if(completed && !line_clear){
line_clear = true;

//クリア時は現在のライン経過時間を加算
playing_time += linetyping_sec
}
//NaNを0にする
if (isNaN(typing_speed)){typing_speed = 0;}
if(isNaN(line_typingspeed)){line_typingspeed = 0;}

//次のラインの必要打鍵速度を計算
if(lyrics_array[count +1]){//曲終了前のライン以外
next_kpm = ((typing_array_roma[count].join("").length) / (lyrics_array[count+1][0]-lyrics_array[count][0]))*player.getPlaybackRate()
}}
}}
}
function countdowntime_and_nextkpm(){
line_time =(lyrics_array[count][0] - (player.getCurrentTime()+player.difftime))/player.getPlaybackRate()
//全体打鍵速度を表示
if(line_time >= 0){
//DOMに打鍵時間を表示
//打/秒表示
if($("[value=sec]").prop("checked")){
$("#rank").html((ranking_array.length +1) + "位 [" +typing_speed.toFixed(2) + "打/秒]")
if($("[value=line_hidden]").prop("checked")){
$("#line_time").html(line_typingspeed.toFixed(2) + "打/秒 / latency: " +latency.toFixed(3)+ "ms")
}else{
$("#line_time").html(line_typingspeed.toFixed(2) + "打/秒 / 残り" +line_time.toFixed(1) +"秒")
}


//next打鍵速度表示
if(lyrics_array[count][2] && lyrics_array[count+1] && next_kpm.toFixed(2) != $(".next_kpm_value").text()){
$("#next_kpm").html("<span id='kpm_color' style='color:"+localStorage.getItem('next_lyrics_color')+";'>NEXT:<span class='next_kpm_value'>"+next_kpm.toFixed(2)+"</span>打/秒</span>")

}

//次のライン入力する文字が無かったらnext速度を表示しない
else if((!lyrics_array[count][2] || !lyrics_array[count+1]) && $("#next_kpm").text() != "&nbsp;"){
$("#next_kpm").html("&nbsp;")
}
}

//kpm表示
else {
$("#rank").html((ranking_array.length +1) + "位 ["  +((typing_speed)*60).toFixed(0) + "kpm]")
if($("[value=line_hidden]").prop("checked")){
$("#line_time").html(((line_typingspeed)*60).toFixed(0) + "kpm / latency: " +latency.toFixed(3)+ "ms")
}else{
$("#line_time").html(((line_typingspeed)*60).toFixed(0) + "kpm / 残り"+line_time.toFixed(1)+"秒")
}
if(lyrics_array[count][2] && lyrics_array[count+1] && (next_kpm*60).toFixed(0) != $(".next_kpm_value").text()){
$("#next_kpm").html("<span id='kpm_color' style='color:"+localStorage.getItem('next_lyrics_color')+";'>NEXT:<span class='next_kpm_value'>"+(next_kpm*60).toFixed(0)+"</span>kpm</span>")
}

else if((!lyrics_array[count][2] || !lyrics_array[count+1]) && $("#next_kpm").text() != "&nbsp;"){
$("#next_kpm").html("")
}
}
}



}
function spacekey_skipguide(){
//スキップ案内を表示
if(!next_char[1] && !skip_flag && $("[value=skip_guide]").prop("checked")){
if(completed &&line_time >= 3){
$("#skip_guide").html("<span style='color:"+localStorage.getItem('skipguide_color')+";'><i>Type Space key to skip. ⏩</i></span>")
}else if(!completed && line_time >= 3.5 && linetyping_sec >= 0.5){//入力する文字がなかった時
$("#skip_guide").html("<span style='color:"+localStorage.getItem('skipguide_color')+";'><i>Type Space key to skip. ⏩</i></span>")
}else if(!next_char[1] && line_time <= 3 && completed){
$("#skip_guide").html("")//スキップできなくなるタイミングで案内非表示(ラインクリア時は3秒)
}else if(!next_char[1] && line_time <= 1 && !completed){
$("#skip_guide").html("")//スキップできなくなるタイミングで案内非表示
}else if(!next_char[1] && countdown_anime && 3.5 >= line_time){
$("#skip_guide").html("")//カウントダウンが表示されたタイミングで案内非表示
}
}else{
$("#skip_guide").html("")
}
}
function sec_countdownanime(){
if(!next_char[1] && line_time >= 1.3 && !countdown_anime && !completed && (!lyrics_array[count-1][1] || lyrics_array[count-1][1]=="<ruby>&#8203;<rt>&#8203;</rt></ruby>") && lyrics_array[count][2] && lyrics_array[count+1] && $("[value=anime_count]").prop("checked")){//4秒以上の間奏中、次のラインに入力する文字が存在する時
countdown_anime = true
}

if(countdown_anime){
if(3.5 >= line_time && line_time >= 0.73){//間奏ラインの残り時間大体3秒ぐらいのとき
$("#count_anime").html("<span style='color:"+localStorage.getItem('countdown_color')+";'><i>"+(line_time).toFixed(0)+"</i></span>")//残り時間を整数で歌詞エリアに表示
}else if(line_time <= 0.73){////間奏ラインの残り時間大体1秒ぐらいのとき
$("#count_anime").html("<span style='color:"+localStorage.getItem('countdown_color')+";'><i>GO!</i></span>")//歌詞エリアにGO!と表示する
}
}
}

//プレイリザルト
function typing_result_generator(){
if (is_played && !finished && player.getPlayerState() == 1) {

if(count >= 1 && lyrics_array[count-1][2] && !start2){
logcount = count
nokorimoji = next_char[1]+line_input_roma.join('')
start2 = true
}
}
if(!lyrics_array[count+1] && !next_char[1] || finished){
if(!ending){
var line_counter = $("#typing_lyrics .type_length:eq(0)").text()
var typinglog_save = typinglog.concat()
    number_lyrics = 1
    ending = true
$('<h1 id="result_head" style ="font-size:20px;background-color: rgba(0,0,0,.33);margin:0px!important;padding-bottom: 5px;">Typing Result</h1><div id="typingloglog" style="word-break: break-all;overflow: scroll; max-height: 700px;font-size: 120%;background-color: rgba(0,0,0,.33);font-weight: 600;user-select: none !important;-ms-user-select: none !important;-moz-user-select: none !important;-webkit-user-select: none !important;"></div><br>').insertAfter('#controlbox')

if(typinglog_save.length == 0){
typinglog_save.splice(lyrics_array.length-1, 0, ["0", "", "0", lyrics_array.length-1, 0, 2]);
}else if(typinglog_save.length != 0 && lyrics_array[count-1][2] && typing_count_save == typing_count && lyrics_array[count][1] =='end' && finished){
inputline_counter.push(count)
}

for(var m = 0; m < (typinglog_save.length+(inputline_counter.length)); m++){
if(inputline_counter == ''){
break
}
if(!typinglog_save[m]){//ライン番号取得
typinglog_save.splice(m, 0, ["0", "", "0", inputline_counter[0], 0, 2]);
inputline_counter.shift()
}
if(typinglog_save[m][3] > inputline_counter[0]){//ライン番号取得
typinglog_save.splice(m, 0, ["0", "", "0", inputline_counter[0], 0, 2]);
inputline_counter.shift()
}
}

if(!start3){
Typing_Result += (number_lyrics+'/'+line_counter+' '+lyrics_array[logcount-1][2])
start3 = true
number_lyrics = (number_lyrics+1)
}

for(var i = 0; i < typinglog_save.length; i++){//入力した文字の数繰り返す

if(logcount != typinglog_save[i][3] && i >= 1){//ライン番号取得
if($("[value=sec]").prop("checked")){
if(nokorimoji_log[typinglog_save[i-1][3]].length != 0){

if(typinglog_save[i-1][5] == 0){
Typing_Result += ('<span class="sippai" style="color:#F12FFF;">'+' failure</span><br><span style="text-transform:uppercase;">' + result_html + nokorimoji_log[typinglog_save[i][3]-1].replace(/(.)(.*)/,'<span style="color:red;">$1</span>$2') + '</span><br>latency: '+latencylog[typinglog_save[i][3]-1]+', 打/秒: ' +kpmlog[typinglog_save[i][3]-1]+ ' 初速抜き: '+rkpmlog[typinglog_save[i][3]-1]+', miss: '+line_misscount[typinglog_save[i][3]-1]+'<br><br><span>'+number_lyrics+'/'+line_counter+' '+lyrics_array[typinglog_save[i][3]-1][2])
}else if(typinglog_save[i-1][5] == 1){
Typing_Result += ('<span class="sippai" style="color:#F12FFF;">'+' failure</span><br><span style="text-transform:uppercase;">' + result_html + nokorimoji_log[typinglog_save[i][3]-1] + '</span><br>latency: '+latencylog[typinglog_save[i][3]-1]+', 打/秒: '+kpmlog[typinglog_save[i][3]-1]+ ' 初速抜き: '+rkpmlog[typinglog_save[i][3]-1]+', miss: '+line_misscount[typinglog_save[i][3]-1]+'<br><br><span>'+number_lyrics+'/'+line_counter+' '+lyrics_array[typinglog_save[i][3]-1][2])
}else if(typinglog_save[i-1][5] == 2){
Typing_Result += ('<span class="sippai" style="color:#F12FFF;">'+' failure</span><br><span style="text-transform:uppercase;">' + nokorimoji_log[typinglog_save[i][3]-1] +'</span><br>latency: null, 打/秒: 0 初速抜き: 0, miss: 0<br><br><span>'+number_lyrics+'/'+line_counter+' '+lyrics_array[typinglog_save[i][3]-1][2])
}}
else{
if(typinglog_save[i-1][5] == 1){
Typing_Result += ('<span class="seikou" style="color:#FFFF00;">'+' clear</span><br><span style="text-transform:uppercase;">' + result_html + '</span><br>latency: '+latencylog[typinglog_save[i][3]-1]+', 打/秒: '+kpmlog[typinglog_save[i][3]-1]+ ' 初速抜き: '+rkpmlog[typinglog_save[i][3]-1]+', miss: '+line_misscount[typinglog_save[i][3]-1]+'<br><br><span>'+number_lyrics+'/'+line_counter+' '+lyrics_array[typinglog_save[i][3]-1][2])
}else{
Typing_Result += ('<span class="sippai" style="color:#F12FFF;">'+' failure</span><br><span style="text-transform:uppercase;">' + nokorimoji_log[typinglog_save[i-1][3]] +'</span><br>latency: null, 打/秒: 0 初速抜き: 0, miss: 0<br><br><span>'+number_lyrics+'/'+line_counter+' '+lyrics_array[typinglog_save[i][3]-1][2])
}
}
}else{
if(nokorimoji_log[typinglog_save[i-1][3]].length != 0){
if(typinglog_save[i-1][5] == 0){
Typing_Result += ('<span class="sippai" style="color:#F12FFF;">'+' failure</span><br><span style="text-transform:uppercase;">' + result_html + nokorimoji_log[typinglog_save[i][3]-1].replace(/(.)(.*)/,'<span style="color:red;">$1</span>$2') + '</span><br>latency: '+latencylog[typinglog_save[i][3]-1]+', kpm: '+(kpmlog[typinglog_save[i][3]-1]*60).toFixed(0)+', rkpm: '+(rkpmlog[typinglog_save[i][3]-1]*60).toFixed(0)+', miss: '+line_misscount[typinglog_save[i][3]-1]+'<br><br><span>'+number_lyrics+'/'+line_counter+' '+lyrics_array[typinglog_save[i][3]-1][2])
}else if(typinglog_save[i-1][5] == 1){
Typing_Result += ('<span class="sippai" style="color:#F12FFF;">'+' failure</span><br><span style="text-transform:uppercase;">' + result_html + nokorimoji_log[typinglog_save[i][3]-1] + '</span><br>latency: '+latencylog[typinglog_save[i][3]-1]+', kpm: '+(kpmlog[typinglog_save[i][3]-1]*60).toFixed(0)+', rkpm: '+(rkpmlog[typinglog_save[i][3]-1]*60).toFixed(0)+', miss: '+line_misscount[typinglog_save[i][3]-1]+'<br><br><span>'+number_lyrics+'/'+line_counter+' '+lyrics_array[typinglog_save[i][3]-1][2])
}else if(typinglog_save[i-1][5] == 2){
Typing_Result += ('<span class="sippai" style="color:#F12FFF;">'+' failure</span><br><span style="text-transform:uppercase;">' + nokorimoji_log[typinglog_save[i][3]-1] +'</span><br>latency: null, kpm: 0, rkpm: 0, miss: 0<br><br><span>'+number_lyrics+'/'+line_counter+' '+lyrics_array[typinglog_save[i][3]-1][2])
}}
else{
if(typinglog_save[i-1][5] == 1){
Typing_Result += ('<span class="seikou" style="color:#FFFF00;">'+' clear</span><br><span style="text-transform:uppercase;">' + result_html + '</span><br>latency: '+latencylog[typinglog_save[i][3]-1]+', kpm: '+(kpmlog[typinglog_save[i][3]-1]*60).toFixed(0)+', rkpm: '+(rkpmlog[typinglog_save[i][3]-1]*60).toFixed(0)+', miss: '+line_misscount[typinglog_save[i][3]-1]+'<br><br><span>'+number_lyrics+'/'+line_counter+' '+lyrics_array[typinglog_save[i][3]-1][2])
}else{
Typing_Result += ('<span class="sippai" style="color:#F12FFF;">'+' failure</span><br><span style="text-transform:uppercase;">' + nokorimoji_log[typinglog_save[i-1][3]] +'</span><br>latency: null, kpm: 0, rkpm: 0, miss: 0<br><br><span>'+number_lyrics+'/'+line_counter+' '+lyrics_array[typinglog_save[i][3]-1][2])
}
}
}
number_lyrics = (number_lyrics+1)
logcount = typinglog_save[i][3]
result_html = ""
}
if(typinglog_save[i][5] == 1){//正当していたときの処理
if(i >= 1 && logcount == typinglog_save[i-1][3] && typinglog_save[i-1][5] == 0){//ミスをしていたら
result_html += ('<span style="color:red">'+typinglog_save[i][1].replace(/ /, '⎽')+'</span>')
}else{//してなかったら
result_html +=('<span style="color:#60d7ff">'+typinglog_save[i][1].replace(/ /, '⎽')+'</span>')
}

}
if($("[value=sec]").prop("checked")){
if(!next_char[1]){
if(i+1 == typinglog_save.length && completed){//次の行がend時、ラインクリア
Typing_Result += ('<span class="seikou" style="color:#FFFF00;">'+' clear</span><br><span style="text-transform:uppercase;">' + result_html+'</span><br>latency: '+latency.toFixed(3)+', 打/秒: '+line_typingspeed.toFixed(2)+' 初速抜き: '+line_typingspeed_rkpm.toFixed(2)+', miss: '+(typing_miss_count-misstyping_count_save))
}else if(i+1 == typinglog_save.length && !completed){//次の行がend時、失敗
if(nokorimoji_log[nokorimoji_log.length-1].length != 0){
Typing_Result += ('<span class="sippai" style="color:#F12FFF;">'+' failure</span><br><span style="text-transform:uppercase;">' + result_html+ nokorimoji_log[nokorimoji_log.length-1] + '</span><br>latency: '+latencylog[nokorimoji_log.length-1]+", 打/秒: "+kpmlog[nokorimoji_log.length-1]+' 初速抜き: ' +rkpmlog[nokorimoji_log.length-1]+ ', miss: '+line_misscount[nokorimoji_log.length-1])
}else{
Typing_Result += ('<span class="seikou" style="color:#FFFF00;">'+' clear</span><br><span style="text-transform:uppercase;">' + result_html+'</span><br>latency: '+latencylog[nokorimoji_log.length-1]+", 打/秒: "+kpmlog[nokorimoji_log.length-1]+' 初速抜き: ' +rkpmlog[nokorimoji_log.length-1]+ ', miss: '+line_misscount[nokorimoji_log.length-1])
}
}
}else if(i+1 == typinglog_save.length && !completed && next_char[1]){
Typing_Result += ('<span class="sippai" style="color:#F12FFF;">'+' failure</span><br><span style="text-transform:uppercase;">' + result_html+nokorimoji+'</span><br>latency: '+(latency).toFixed(3)+', 打/秒: '+line_typingspeed.toFixed(2)+' 初速抜き: '+line_typingspeed_rkpm.toFixed(2)+', miss: '+(typing_miss_count-misstyping_count_save))
}
}else{
if(!next_char[1]){
if(i+1 == typinglog_save.length && completed){//次の行がend時、ラインクリア
Typing_Result += ('<span class="seikou" style="color:#FFFF00;">'+' clear</span><br><span style="text-transform:uppercase;">' + result_html+'</span><br>latency: '+latency.toFixed(3)+', kpm: '+(line_typingspeed*60).toFixed(0)+', rkpm: '+(line_typingspeed_rkpm*60).toFixed(0)+', miss: '+(typing_miss_count-misstyping_count_save))
}else if(i+1 == typinglog_save.length && !completed){//次の行がend時、失敗
if(nokorimoji_log[nokorimoji_log.length-1].length != 0){
Typing_Result += ('<span class="sippai" style="color:#F12FFF;">'+' failure</span><br><span style="text-transform:uppercase;">' + result_html+ nokorimoji_log[nokorimoji_log.length-1] + '</span><br>latency: '+latencylog[nokorimoji_log.length-1]+", kpm: "+(kpmlog[nokorimoji_log.length-1]*60).toFixed(0) + ', rkpm:' +(line_typingspeed_rkpm*60).toFixed(0)+ ', miss: '+line_misscount[nokorimoji_log.length-1])
}else{
Typing_Result += ('<span class="seikou" style="color:#FFFF00;">'+' clear</span><br><span style="text-transform:uppercase;">' + result_html+'</span><br>latency: '+latencylog[nokorimoji_log.length-1]+", kpm: "+(kpmlog[nokorimoji_log.length-1]*60).toFixed(0) + ', rkpm:' +(rkpmlog[nokorimoji_log.length-1]*60).toFixed(0)+ ', miss: '+line_misscount[nokorimoji_log.length-1])
}
}
}else if(i+1 == typinglog_save.length && !completed && next_char[1]){
Typing_Result += ('<span class="sippai" style="color:#F12FFF;">'+' failure</span><br><span style="text-transform:uppercase;">' + result_html+nokorimoji+'</span><br>latency: '+(latency).toFixed(3)+', kpm: '+(line_typingspeed*60).toFixed(0)+', rkpm: '+(line_typingspeed_rkpm*60).toFixed(0).replace(/^[-]?([1-9]\d*|0)(\.\d+)?$/,"0")+', miss: '+(typing_miss_count-misstyping_count_save))
}
}
if(i+2 == typinglog_save.length+1){
$('#typingloglog').append(Typing_Result)
$('<h6 style ="font-size:130%;background-color: rgba(0,0,0,.33);margin:0px!important;padding-bottom: 5px;">Score Penalty<br>Missd: '+ (-typing_miss_count*(((parseInt(score_per_char)/20)/100)/4)).toFixed(2)+'<br>Escape: '+(((Math.floor(parseInt(score)/20)/100)+(typing_miss_count*(((parseInt(score_per_char)/20)/100)/4)))-100).toFixed(2).replace(/^[-]?(\d*|0)(\.01)?$/,'0.00')+'</h6>').insertAfter('#result_head')
$('<h5 style ="background-color: rgba(0,0,0,.33);margin:0px!important;padding-bottom: 5px;">'+'<span style="color:#FFFF00;">'+$('#typingloglog').find('.seikou').length+' clear</span> / <span style="color:#FFFF00;"><span style="color:#F12FFF;">'+$('#typingloglog').find('.sippai').length+' failure</span></h5>').insertAfter('#result_head')
}
}
}
}
}

//関数を適用
$(function(){
mod_setting_open()
load_sound()
add_css()
read_localstorage()
lyricsarray_reading()
play_preparation()

//時間計算interval 0msで常に更新
setInterval(function (){
time_calculation()
localstrage_save()
},0);


//interval 50msで更新する機能
setInterval(function (){
checkbox_check()
if(typeof is_played !== 'undefined'){
if(is_played && player.getPlayerState() == 1){
if(!finished){
countdowntime_and_nextkpm()
spacekey_skipguide()
sec_countdownanime()
}
//プレイ終了時の機能
typing_result_generator()
}
}
},50);
});


$(window).on('load', function () {
//スコアランキングから登録者数とスコアを抽出
for (let i = 0;i<$(".list-group ").find(".player_ranking").length; i++) {
 ranking_array.unshift(Number($(".p-2 > .player_ranking")[i].textContent.replace( ':', '' )))
}
})





var line_clear = false;
var start2 = false;
var logcount =0
var latencylog = ["0"]
var latency = (0).toFixed(3)
var latency_flag = false
var kpmlog=["0"]
var rkpmlog=["0"]
var nokorimoji_log=["0"]
var nokorimoji = "";
var inputline_counter=[]
var result_line = ["0"]
var misstyping_count_save = 0
var line_misscount =["0"]

// 歌詞が更新されたら入力ラインをアップデート
// ref. https://risaki-masa.com/function-for-observing-variable-with-js/
function observe( interval, onGet, onChanged ) {
    let     previousValue   = onGet();
    const   onObserve       = function() {
        const VALUE = onGet();
        if ( previousValue === VALUE ) return;

        onChanged( VALUE );
        previousValue = VALUE;
    };

    setInterval( onObserve, interval );
}
const INTERVAL  = 0;
const onGet     = function() { return count; };
const onChanged = function() { updateLineView();};

observe( INTERVAL, onGet, onChanged );


function updateLineView() {
if (!$("#kashi_sub")[0]) {
// DOM要素がない場合は初期化
        $("#kashi_roma").after($("<div>").attr('id', 'kashi_sub'));
        // モードによって出力を変更
        // わかりにくいけど #kashi_roma = main #kashi_sub = sub
if(mode == 'kana'){
$("#kashi_sub").css({'cssText':'text-transform:uppercase;'});
}
}

if(kana_mode) {
$("#kashi_roma").addClass("kana_mode_input_dom");
$("#kashi_sub").addClass("kana_mode_input_dom");
}

else if (mode == 'roma') {

$("#kashi_roma").addClass("roma_input_dom");

if($("[value=sub]").prop("checked")){
$("#kashi_sub").addClass("kana_input_dom");
}else{
$("#kashi_sub").removeClass("kana_input_dom");
$("#kashi_sub").html("")
}

}else if(mode == 'kana'){
$("#kashi_roma").addClass("kana_input_dom");

if($("[value=sub]").prop("checked")){
$("#kashi_sub").addClass("roma_input_dom");
}else{
$("#kashi_sub").removeClass("roma_input_dom");
$("#kashi_sub").html("")

}

}

//////////////////////////////////////////////////////////////////////////////

if (is_played && !finished) {

var kanma ="\,"
var period="\."
   if(next_char[0] == '\,' || next_char[0] == '\.'){
    if(/[ぁ-ん|ヴ|ゔ|ー|、|。]/.test(already_input[already_input.length -1])){
kanma = "、"
period = "。"
       }
   }
       if(line_input_kana[0] == '\,'||line_input_kana[0] == '\.'){
      if(/[ぁ-ん|ヴ|ゔ|ー|、|。]/.test(next_char[0])){
kanma = "、"
period = "。"}
}
/*
var reg = new RegExp("([^]{0,"+localStorage.getItem('hide_letter')+"})([^]*)")
var kashi_hidden_kana ="<span style='position: absolute;bottom: 0;visibility: visible!important;font-size:17.5px;word-break: break-all;'><span style='color:"+(next_char[0].length == 0 ? '#1eff52' : '#09c')+"'>"+already_input.toLowerCase().replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\,)/g,'$1、').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。').replace(/ /g, '⎽').replace(/~/g, 'ー').replace('\.',period)+"</span><span style='color:"+localStorage.getItem('word_color')+";'>" + (String(next_char[0] || []).toLowerCase().replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\,)/g,'$1、').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。').replace('\,',kanma).replace('\.',period).replace(/ /g, '  ').replace(/~/g, 'ー') + String(line_input_kana.join('').toLowerCase().replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\,)/g,'$1、').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。').replace('\,',kanma).replace('\.',period).replace(/ /g, '  ').replace(/~/g, 'ー'))).replace(reg,"<span style='color:#00000000;'>$1</span>$2") + "</span></span>";
if(already_input.length ==0){
kashi_hidden_kana ="<span style='position: absolute;bottom: 0;visibility: visible!important;font-size:17.5px;word-break: break-all;'><span style='color:"+(next_char[0].length == 0 ? localStorage.getItem('lineclear_color') : localStorage.getItem('correctword_color'))+";'>"+already_input.toLowerCase().replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\,)/g,'$1、').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。').replace(/ /g, '⎽').replace(/~/g, 'ー').replace('\.',period)+"</span><span style='color:"+localStorage.getItem('word_color')+";'>" + (String(next_char[0] || []).toLowerCase().replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\,)/g,'$1、').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。').replace('\,',kanma).replace('\.',period).replace(/ /g, '  ').replace(/~/g, 'ー') + String(line_input_kana.join('').toLowerCase().replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\,)/g,'$1、').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。').replace('\,',kanma).replace('\.',period).replace(/ /g, '  ').replace(/~/g, 'ー'))) + "</span></span>";
}
*/
if(kana_mode){
if($("[value=letter_scroll]").prop("checked")){
var kashi_kanamode_html = "<span style='position: absolute;bottom: 0;visibility: visible!important;font-size:17.5px;word-break: break-all;'><span class='correct_input' style='color:"+(next_char[0].length == 0 ? localStorage.getItem('lineclear_color') : localStorage.getItem('correctword_color'))+";'>"+already_input.substr(-localStorage.getItem('letter_scroll_kana'),localStorage.getItem('letter_scroll_kana'))+"</span><span style='color:"+localStorage.getItem('first_color1')+";' class=input_letter data-kana='・'>" + String(next_char[0] || '') +"</span><span style='color:"+localStorage.getItem('word_color')+";'>"+String(line_input_kana.join('')+"</span>");
}else{
kashi_kanamode_html = "<span style='visibility: visible!important;font-size:17.5px;word-break: break-all;'><span class='correct_input' style='color:"+(next_char[0].length == 0 ? localStorage.getItem('lineclear_color') : localStorage.getItem('correctword_color'))+";'>"+already_input+"</span><span style='color:"+localStorage.getItem('first_color1')+";' class=input_letter data-kana='・'>" + String(next_char[0] || '') +"</span><span style='color:"+localStorage.getItem('word_color')+";'>"+String(line_input_kana.join('')+"</span>");
}
}else if($("[value=letter_scroll]").prop("checked")){
var kashi_kana_html = "<span style='position: absolute;bottom: 0;visibility: visible!important;font-size:17.5px;word-break: break-all;'><span class='correct_input' style='color:"+(next_char[0].length == 0 ? localStorage.getItem('lineclear_color') : localStorage.getItem('correctword_color'))+";'>"+(already_input.toLowerCase().replace(/ /g, '⎽').replace(/([ぁ-んー*])(\,)/g,'$1、').replace(/~/g, 'ー').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。')).substr(-localStorage.getItem('letter_scroll_kana'),localStorage.getItem('letter_scroll_kana'))+"</span>"+"<span style='color:"+localStorage.getItem('first_color1')+";'><span class='input_letter' data-kana='・' style='color:"+localStorage.getItem('miss_color')+"!important;'></span>" + String(next_char[0] || []).toLowerCase().replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\,)/g,'$1、').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。').replace('\,',kanma).replace('\.',period).replace(/~/g, 'ー') + "</span><span class='typing_word' style='color:"+localStorage.getItem('word_color')+";'>" + String(line_input_kana.join('').toLowerCase().replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\,)/g,'$1、').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。').replace('\,',kanma).replace('\.',period).replace(/ /g, '  ').replace(/~/g, 'ー') + "</span></span>");
var kashi_roma_html = "<span style='position: absolute;bottom: 0;visibility: visible!important;font-size:17.5px;word-break: break-all;'><span class='correct_input' style='color:"+(next_char[0].length == 0 ? localStorage.getItem('lineclear_color') : localStorage.getItem('correctword_color'))+";'>"+(already_input_roma.replace(/ /g, '⎽')).substr(-localStorage.getItem('letter_scroll_roma'),localStorage.getItem('letter_scroll_roma'))+"</span>" + String(next_char[1] || '').replace(/(.)(\S*)/, "<span style='color:"+localStorage.getItem('first_color1')+";'><span class='input_letter' data-kana='・' style='color:"+localStorage.getItem('miss_color')+"!important;'></span>$1</span><span class='typing_word' style='color:"+localStorage.getItem('word_color')+";'>$2</span>") + "<span class='typing_word' style='color:"+localStorage.getItem('word_color')+";'>" + String(line_input_roma.join('')+ "</span></span>");
if($("[value=eng_highlight]").prop("checked")){
if(next_char[0].length != 0 && line_input_kana.length != 0 && lyrics_array[count-1][2].length != 0){
if(/[ぁ-ん|ヴ|ゔ|ー|、|。|\s]/.test(lyrics_array[count-1][2])){
if(/[a-zA-Z0-9|%|'|"|!|?|,|\.|"|&|\-]/.test(next_char[0][0]) && /[a-zA-Z0-9|%|'|"|!|?|,|\.|"|&|\-]/.test(line_input_kana[0][0])){
kashi_kana_html ="<span style='position: absolute;bottom: 0;visibility: visible!important;font-size:17.5px;word-break: break-all;'><span class='correct_input' style='color:"+(next_char[0].length == 0 ? localStorage.getItem('lineclear_color') : localStorage.getItem('correctword_color'))+";'>"+(already_input.toLowerCase().replace(/ /g, '⎽').replace(/([ぁ-んー*])(\,)/g,'$1、').replace(/~/g, 'ー').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。')).substr(-localStorage.getItem('letter_scroll_kana'),localStorage.getItem('letter_scroll_kana'))+"</span>"+"<span style='color:"+localStorage.getItem('first_color1')+";'><span class='input_letter' data-kana='・' style='color:"+localStorage.getItem('miss_color')+"!important;'></span>" + String(next_char[0] || []).toLowerCase().replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\,)/g,'$1、').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。').replace('\,',kanma).replace('\.',period).replace(/~/g, 'ー') + "</span><span class='typing_word' style='color:"+localStorage.getItem('word_color')+";'>" + String(line_input_kana.join('').toLowerCase().replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\,)/g,'$1、').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。').replace('\,',kanma).replace('\.',period).replace(/ /g, '  ').replace(/~/g, 'ー')).replace(/([a-zA-Z0-9|%|'|"|!|?|,|\.|"|&|\-]+[\s]?)(.*)/,"<span style='color:"+localStorage.getItem('first_color1')+";'>$1</span>$2") + "</span></span>";
}
}
}
}
}else{
kashi_kana_html = "<span style='visibility: visible!important;font-size:17.5px;word-break: break-all;'><span class='correct_input' style='color:"+(next_char[0].length == 0 ? localStorage.getItem('lineclear_color') : localStorage.getItem('correctword_color'))+";'>"+already_input.toLowerCase().replace(/ /g, '⎽').replace(/([ぁ-んー*])(\,)/g,'$1、').replace(/~/g, 'ー').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。')+"</span>"+"<span style='color:"+localStorage.getItem('first_color1')+";'><span class='input_letter' data-kana='・' style='color:"+localStorage.getItem('miss_color')+"!important;'></span>" + String(next_char[0] || []).toLowerCase().replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\,)/g,'$1、').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。').replace('\,',kanma).replace('\.',period).replace(/~/g, 'ー') + "</span><span class='typing_word' style='color:"+localStorage.getItem('word_color')+";'>" + String(line_input_kana.join('').toLowerCase().replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\,)/g,'$1、').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。').replace('\,',kanma).replace('\.',period).replace(/ /g, '  ').replace(/~/g, 'ー') + "</span>");
kashi_roma_html = "<span style='visibility: visible!important;font-size:17.5px;word-break: break-all;'><span class='correct_input' style='color:"+(next_char[0].length == 0 ? localStorage.getItem('lineclear_color') : localStorage.getItem('correctword_color'))+";'>"+already_input_roma.replace(/ /g, '⎽')+"</span>" + String(next_char[1] || '').replace(/(.)(\S*)/, "<span style='color:"+localStorage.getItem('first_color1')+";'><span class='input_letter' data-kana='・' style='color:"+localStorage.getItem('miss_color')+"!important;'></span>$1</span><span class='typing_word' style='color:"+localStorage.getItem('word_color')+";'>$2</span>") + "<span class='typing_word' style='color:"+localStorage.getItem('word_color')+";'>" + String(line_input_roma.join('')+ "</span>");
if($("[value=eng_highlight]").prop("checked")){
if(next_char[0].length != 0 && line_input_kana.length != 0 && lyrics_array[count-1][2].length != 0){
if(/[ぁ-ん|ヴ|ゔ|ー|、|。|\s]/.test(lyrics_array[count-1][2])){
if(/[a-zA-Z0-9|%|'|"|!|?|,|\.|"|&|\-]/.test(next_char[0][0]) && /[a-zA-Z0-9|%|'|"|!|?|,|\.|"|&|\-]/.test(line_input_kana[0][0])){
kashi_kana_html ="<span style='visibility: visible!important;font-size:17.5px;word-break: break-all;'><span class='correct_input' style='color:"+(next_char[0].length == 0 ? localStorage.getItem('lineclear_color') : localStorage.getItem('correctword_color'))+";'>"+already_input.toLowerCase().replace(/ /g, '⎽').replace(/([ぁ-んー*])(\,)/g,'$1、').replace(/~/g, 'ー').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。')+"</span>"+"<span style='color:"+localStorage.getItem('first_color1')+";'><span class='input_letter' data-kana='・' style='color:"+localStorage.getItem('miss_color')+"!important;'></span>" + String(next_char[0] || []).toLowerCase().replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\,)/g,'$1、').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。').replace('\,',kanma).replace('\.',period).replace(/~/g, 'ー') + "</span><span class='typing_word' style='color:"+localStorage.getItem('word_color')+";'>" + String(line_input_kana.join('').toLowerCase().replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\,)/g,'$1、').replace(/([ぁ-ん|ヴ|ゔ|ー|、|。*])(\.)(?!\.)/g,'$1。').replace('\,',kanma).replace('\.',period).replace(/ /g, '  ').replace(/~/g, 'ー')).replace(/([a-zA-Z0-9|%|'|"|!|?|,|\.|"|&|\-]+[\s]?)(.*)/,"<span style='color:"+localStorage.getItem('first_color1')+";'>$1</span>$2") + "</span>";
}
}
}
}
}
if(kana_mode){
//        $(".kana_mode_input_dom").html(kashi_kanamode_html);
}else
        $(".roma_input_dom").html(kashi_roma_html);
        $(".kana_input_dom").html(kashi_kana_html);

}/*else if($("[value=hidden]").prop("checked")){
        $(".roma_input_dom").html();
        $(".kana_input_dom").html(kashi_hidden_kana);
}*/
}

//設定のチェックボックスが変更されたときに発動
$("[name=chk_sample],[name=type_lyric_display],[value=sub],[value=sec],input.color").change( function () {
    if($("[value=sec]").prop("checked")){
$('#difficult > span').html('<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+(200000 / score_per_char).toFixed(0) + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+$("#typing_lyrics .type_length:eq(0)").text()+'line</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+((difficulty_average/difficulty.length)*$("#speed").text()).toFixed(2)+'打/秒, 最高'+(Math.max.apply(null, difficulty)*$("#speed").text()).toFixed(2)+'打/秒</span>')
}else{
$('#difficult > span').html('<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+(200000 / score_per_char).toFixed(0) + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+$("#typing_lyrics .type_length:eq(0)").text()+'line</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+(((difficulty_average/difficulty.length)*$("#speed").text())*60).toFixed(0)+'kpm, 最高'+((Math.max.apply(null, difficulty)*$("#speed").text())*60).toFixed(0)+'kpm</span>')
}
if(is_played){
    updateLineView();
}
})






var combo_break;

var combo100 = false;


var ranking = false;
function shortcut_key_esc_enter(){
//ショートカットキー
if(event.keyCode == 27){//Escでポーズ・再生(プレイ開始のショートカットキーとしても使用可)
event.preventDefault();
if(!is_played){
player.playVideo()
}else if(is_played) {
if(player.getPlayerState() == 1){
    player.pauseVideo()
}else{
    player.playVideo()
}
}
}
if(finished && event.keyCode == 13 && !ranking){//曲終了、Enterキーで記録送信
            submit_score();
            ranking = true;
}
}

$("<span>(F10)</span>").insertAfter('#speed')
function shortcut_key_playing(){
    if(event.keyCode ==121) {//F10で倍速
            speedup();
            event.preventDefault();
    }else if(event.keyCode ==9) {//TABキー、Firefoxのクイック検索ショートカットキーを無効化
        event.preventDefault();
        }
    if(event.keyCode == 32 && $("#skip_guide").text() == "Type Space key to skip. ⏩"){//スペースキーでスキップ
toggle_skip();
skip_flag=true
$("#skip_guide").html("")
window.setTimeout(toggle_skip, 25);


}
}

function typesound_and_miss_effect(){
if(next_char[0]){
if (combo && !completed){//combo継続中
latency_flag=true
      nokorimoji = next_char[1]+line_input_roma.join('')
$("span").removeClass("missmark");//ミス表示削除
if ($("[value=type_sound]").prop("checked")) {//打鍵音
key_type_play()
}
}else if(miss_combo){//ミス継続中
if($("[value=miss_sound]").prop("checked")) {//ミス音
if(!combo100){//ミス音

miss_type_play()

}else if(combo100){//100 combo以上でミスするとcombo break音
if($("[value=combo_break_sound]").prop("checked")){
    combo_break.play();
}
miss_type_play()
    combo100 = false;//フラグOFF
}
}
    if($("[value=miss_on]").prop("checked")){//ミス表示を追加
        if (mode == 'kana') {//かな表示専用のミス表示
if(/[\u3042\u3044\u3046\u3048\u304a-\u3062\u3064-\u3082\u3084\u3086\u30F4\u3088-\u3094\u0025\u30FC\uFF5E]+$/.test(next_char[0][0])){//全角全角数字%ヴ
            $("#kashi_roma .input_letter").addClass("missmark");
}else if(/[\u3041\u3043\u3045\u3047\u3049\u3063\u3083\u3085\u3087\u0023\u0040\uFF41-\uFF5A\uFF21-\uFF3A]+$/.test(next_char[0][0])){//ぁぃぅぇぉっゃゅょ#@全角英字大文字小文字
            $("#kashi_roma .input_letter").addClass("missmark1");
}else if(/[\u006E\u0070\u0071\u0075\u0026\u0067\u006B]+$/.test(next_char[0][0])){//npqu&gk
            $("#kashi_roma .input_letter").addClass("missmark2");
}else if(/[\u0063\u0064\u0065\u006F\u0068\u0062\u0054]+$/.test(next_char[0][0])){//cdeogT
            $("#kashi_roma .input_letter").addClass("missmark3");
}else if(/[\u0078\u0079\u0061\u0024]+$/.test(next_char[0][0])){//xya$
            $("#kashi_roma .input_letter").addClass("missmark4");
}else if(/[\u003F\u0076\u0072\u0073\u007A]+$/.test(next_char[0][0])){//?vsrz
            $("#kashi_roma .input_letter").addClass("missmark5");
}else if(/[\u006A\u0066\u0074]+$/.test(next_char[0][0])){//jft
            $("#kashi_roma .input_letter").addClass("missmark6");
}else if(/[\u0021]+$/.test(next_char[0][0])){//!
            $("#kashi_roma .input_letter").addClass("missmark7");
}else if(/[\u002C\u002E\s]+$/.test(next_char[0][0])){//,.半角スペース
            $("#kashi_roma .input_letter").addClass("missmark8");
}else if(/[\u0027\u0069\u006C]+$/.test(next_char[0][0])){//'il
            $("#kashi_roma .input_letter").addClass("missmark9");
}else if(/[\u006D\uFF10-\uFF19]+$/.test(next_char[0][0])){//全角数字m
            $("#kashi_roma .input_letter").addClass("missmark10");
}else if(/[\u0077\u004D]+$/.test(next_char[0][0])){//wM
            $("#kashi_roma .input_letter").addClass("missmark11");
}else if(/[\u0041-\u0044\u004B\u004C\u0052\u0055]+$/.test(next_char[0][0])){//ABCDKLRU
            $("#kashi_roma .input_letter").addClass("missmark12");
}else if(/[\u0045\u0046\u0050\u0059\u005A\u0030-\u0039]+$/.test(next_char[0][0])){//EFYZ半角01234566789
            $("#kashi_roma .input_letter").addClass("missmark13");
}else if(/[\u0047\u0048\u004E\u0051]+$/.test(next_char[0][0])){//GHNQ
            $("#kashi_roma .input_letter").addClass("missmark14");
}else if(/[\u0049\u004A\u0022]+$/.test(next_char[0][0])){//IJ"
            $("#kashi_roma .input_letter").addClass("missmark15");
}else if(/[\u004F]+$/.test(next_char[0][0])){//O
            $("#kashi_roma .input_letter").addClass("missmark16");
}else if(/[\u0053\u0056\u0058\u002F]+$/.test(next_char[0][0])){//SVX/
            $("#kashi_roma .input_letter").addClass("missmark17");
}else if(/[\u0057]+$/.test(next_char[0][0])){//W
            $("#kashi_roma .input_letter").addClass("missmark18");
}else if(/[\u002D]+$/.test(next_char[0][0])){//-
            $("#kashi_roma .input_letter").addClass("missmark19");
}else if(/[\u003D\u007E]+$/.test(next_char[0][0])){//=~
            $("#kashi_roma .input_letter").addClass("missmark20");
}
}else if (mode == 'roma') {//ローマ字表示専用のミス表示
if(/[\u3042\u3044\u3046\u3048\u304a-\u3062\u3064-\u3082\u3084\u3086\u3088-\u3094\u0025\u30FC\uFF5E]+$/.test(next_char[1][0])){//全角全角数字%
            $("#kashi_roma .input_letter").addClass("missmark");
}else if(/[\u3041\u3043\u3045\u3047\u3049\u3063\u3083\u3085\u3087\u0023\u0040\uFF41-\uFF5A\uFF21-\uFF3A]+$/.test(next_char[1][0])){//ぁぃぅぇぉっゃゅょ#@全角英字大文字小文字
            $("#kashi_roma .input_letter").addClass("missmark1");
}else if(/[\u006E\u0070\u0071\u0075\u0026\u0067\u006B]+$/.test(next_char[1][0])){//npqu&gk
            $("#kashi_roma .input_letter").addClass("missmark2");
}else if(/[\u0063\u0064\u0065\u006F\u0068\u0062\u0054]+$/.test(next_char[1][0])){//cdeogT
            $("#kashi_roma .input_letter").addClass("missmark3");
}else if(/[\u0078\u0079\u0061\u0024]+$/.test(next_char[1][0])){//xya$
            $("#kashi_roma .input_letter").addClass("missmark4");
}else if(/[\u003F\u0076\u0072\u0073\u007A]+$/.test(next_char[1][0])){//?vsrz
            $("#kashi_roma .input_letter").addClass("missmark5");
}else if(/[\u006A\u0066\u0074]+$/.test(next_char[1][0])){//jft
            $("#kashi_roma .input_letter").addClass("missmark6");
}else if(/[\u0021]+$/.test(next_char[1][0])){//!
            $("#kashi_roma .input_letter").addClass("missmark7");
}else if(/[\u002C\u002E\s]+$/.test(next_char[1][0])){//,.半角スペース
            $("#kashi_roma .input_letter").addClass("missmark8");
}else if(/[\u0027\u0069\u006C]+$/.test(next_char[1][0])){//'il
            $("#kashi_roma .input_letter").addClass("missmark9");
}else if(/[\u006D\uFF10-\uFF19]+$/.test(next_char[1][0])){//全角数字m
            $("#kashi_roma .input_letter").addClass("missmark10");
}else if(/[\u0077\u004D]+$/.test(next_char[1][0])){//wM
            $("#kashi_roma .input_letter").addClass("missmark11");
}else if(/[\u0041-\u0044\u004B\u004C\u0052\u0055]+$/.test(next_char[1][0])){//ABCDKLRU
            $("#kashi_roma .input_letter").addClass("missmark12");
}else if(/[\u0045\u0046\u0050\u0059\u005A\u0030-\u0039]+$/.test(next_char[1][0])){//EFYZ半角01234566789
            $("#kashi_roma .input_letter").addClass("missmark13");
}else if(/[\u0047\u0048\u004E\u0051]+$/.test(next_char[1][0])){//GHNQ
            $("#kashi_roma .input_letter").addClass("missmark14");
}else if(/[\u0049\u004A\u0022]+$/.test(next_char[1][0])){//IJ"
            $("#kashi_roma .input_letter").addClass("missmark15");
}else if(/[\u004F]+$/.test(next_char[1][0])){//O
            $("#kashi_roma .input_letter").addClass("missmark16");
}else if(/[\u0053\u0056\u0058\u002F]+$/.test(next_char[1][0])){//SVX/
            $("#kashi_roma .input_letter").addClass("missmark17");
}else if(/[\u0057]+$/.test(next_char[1][0])){//W
            $("#kashi_roma .input_letter").addClass("missmark18");
}else if(/[\u002D]+$/.test(next_char[1][0])){//-
            $("#kashi_roma .input_letter").addClass("missmark19");
}else if(/[\u003D\u007E]+$/.test(next_char[1][0])){//=~
            $("#kashi_roma .input_letter").addClass("missmark20");
}
}
    }
}
}else if(!next_char[0]){
}if(!line_clear && completed){//ラインクリア。フラグON
nokorimoji=""
 if($("[value=clear_sound]").prop("checked")){//クリア音
clear_type_play()
}else if(!$("[value=clear_sound]").prop("checked") && $("[value=type_sound]").prop("checked")){//クリア音OFF状態で最後を打鍵音に変更
key_type_play()
}
if(combo >= 100){//100combo以上のフラグON
    combo100 = true;
}


}
}

document.onkeydown =
    (function (e) {

shortcut_key_esc_enter()
if(is_played && !finished){
if(lyrics_array[count-1][2] && count >= 1){
// 入力ラインの描画アップデート
    updateLineView();
}
if(player.getPlayerState() == 1){
shortcut_key_playing()

//ランキングのスコアを抜かした時の処理
if((parseInt(score)/20)/100 >= ranking_array[0]){//次の目標スコアを超えた時

for(var i = 0; i < $(".list-group ").find(".player_ranking").length; i++){//現在の自分のスコアより下のスコアを削除
ranking_array.shift();
    if((parseInt(score)/20)/100 < ranking_array[0]){//目標スコアが自分のスコアより高くなったらループ終わり
        break;
    }
}
}

    switch(e.keyCode){//Typing Tubeで有効なキーコード
case 32://Space
case 65://a
case 66://b
case 67://c
case 68://d
case 69://e
case 70://f
case 71://g
case 72://h
case 73://i
case 74://j
case 75://k
case 76://l
case 77://m
case 78://n
case 79://o
case 80://p
case 81://q
case 82://r
case 83://s
case 84://t
case 85://u
case 86://v
case 87://w
case 88://x
case 89://y
case 90://z
case 48://0
case 49://1
case 50://2
case 51://3
case 52://4
case 53://5
case 54://6
case 55://7
case 56://8
case 57://9
//case 187://+
case 188://,
case 189://-(chrome)
case 190://.
//case 222://^
case 191:///
case 219://[
case 173://-(firefox)
//case 160://^(firefox)
//case 59://+(firefox)
/*
//かな入力
case 33:
case 34:
case 35:
case 36:
case 37:
case 38:
case 39:
case 40:
case 41:
case 113://9
case 119://9
case 101://9
case 114://9
case 116://9
case 121://9
case 117://9
case 105://9
case 111://9
case 112://9
case 64://9
case 97://9
case 115://9
case 100://9
case 102://9
case 103://9
case 104://9
case 106://9
case 107://9
case 108://9
case 122://9
case 120://9
case 99://9
case 118://9
case 98://9
case 110://9
case 109://9://9
case 64://9
//かな入力ここまで
*/
typesound_and_miss_effect()
}
}}
})


/**
*@プレイ中の処理変更 ここまで---
*/
/////////////////////////////////////////////////////////////////////////////////////////////////


/*
//#status変更(update_status関数を上書き)
function evalInPage(fun) {
  location.href = "javascript:void (" + fun + ")()";
}
evalInPage(function () {

update_status = function(){
let correct = typing_count / (typing_miss_count + typing_count) * 100.0;
let linecorrect = complete_count / (failer_count + complete_count) * 100.0;
if (isNaN(correct)) {
          correct = 0;
}
if (isNaN(linecorrect)) {
          linecorrect = 100;
}

$("#status").html((Math.floor(parseInt(score)/20)/100).toFixed(2)+"<br>"+typing_miss_count+" miss<br>"+combo+"/"+max_combo+" combo<br>"+ typing_count + "/<span style='font-size:85%;'>" + (200000 / score_per_char).toFixed(0) + "</span>打 " + correct.toFixed(1) + "%<br>"+complete_count + " clear"+ " ["+(typing_array.filter( v => !!( '' + v )).length-failer_count)+"] "+linecorrect.toFixed(0)+"%");
update_skip();

}
})

//Cookie関連
jQuery(function($){
            //ページを読み込んだら、チェックボックスにクッキーの値を反映する
            if($.cookie("mode_select_selected_value")){
var load_values = $.cookie("mode_select_selected_value").split(",");
                for(var i = 0; i < load_values.length; ++i){
                    load_values[i] = decodeURIComponent(load_values[i]);
                }

                $("[name=mode_select]").each(function(){
                    this.checked = $.inArray(this.value, load_values) != -1;
                });

            }

            //チェックを変えたらクッキーを保存するイベントを登録する
            $("[name=mode_select]").change(function(){

var save_values = [];

                $("[name=mode_select]").each(function(){
                    this.checked && save_values.push(encodeURIComponent(this.value));
                });

                $.cookie("mode_select_selected_value", save_values.join(","), { expires: 30 });
            });
        });
jQuery(function($){
            //ページを読み込んだら、チェックボックスにクッキーの値を反映する
            if($.cookie("type_lyric_display_selected_value")){
var load_values = $.cookie("type_lyric_display_selected_value").split(",");
                for(var i = 0; i < load_values.length; ++i){
                    load_values[i] = decodeURIComponent(load_values[i]);
                }

                $("[name=type_lyric_display]").each(function(){
                    this.checked = $.inArray(this.value, load_values) != -1;
                });

            }

            //チェックを変えたらクッキーを保存するイベントを登録する
            $("[name=type_lyric_display]").change(function(){

var save_values = [];

                $("[name=type_lyric_display]").each(function(){
                    this.checked && save_values.push(encodeURIComponent(this.value));
                });

                $.cookie("type_lyric_display_selected_value", save_values.join(","), { expires: 30 });
            });
        });
jQuery(function($){
            //ページを読み込んだら、チェックボックスにクッキーの値を反映する
            if($.cookie("chk_sample_selected_value")){
var load_values = $.cookie("chk_sample_selected_value").split(",");
                for(var i = 0; i < load_values.length; ++i){
                    load_values[i] = decodeURIComponent(load_values[i]);
                }

                $("[name=chk_sample]").each(function(){
                    this.checked = $.inArray(this.value, load_values) != -1;
                });

            }

            //チェックを変えたらクッキーを保存するイベントを登録する
            $("[name=chk_sample]").change(function(){

var save_values = [];

                $("[name=chk_sample]").each(function(){
                    this.checked && save_values.push(encodeURIComponent(this.value));
                });

                $.cookie("chk_sample_selected_value", save_values.join(","), { expires: 30 });
            });
        });
*/