|
// ==UserScript== |
|
// @name sengokuixa-no-dounokouno |
|
// @description 戦国IXAの個人的なUserScript |
|
// @version 0.2.0 |
|
// @namespace sengokuixa-no-dounokouno |
|
// @author @dounokouno |
|
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js |
|
// @require http://jquery-json.googlecode.com/files/jquery.json-2.4.min.js |
|
// @include http://*.sengokuixa.jp/* |
|
// @match http://*.sengokuixa.jp/* |
|
// ==/UserScript== |
|
// |
|
|
|
// ------------------------------------------------------------------------ |
|
// sengokuixa-no-dounokouno.user.js |
|
// |
|
// Since: 2012-08-22 |
|
// Modified: 2013-02-17 |
|
// |
|
// 配布URL: https://gist.github.com/dounokouno/4142402 |
|
// Email: dounokouno@gmail.com |
|
// Twitter: @dounokouno |
|
// ------------------------------------------------------------------------ |
|
|
|
(function() { |
|
'use strict'; |
|
var dkTool = []; |
|
|
|
// $.ajaxの共通設定 |
|
$.ajaxSetup({ |
|
cache: false, |
|
dataType: 'html' |
|
}); |
|
|
|
|
|
// ------------------------------------------------------------------------ |
|
// 「待機武将一覧」の武将ステータスに経験値を表示 |
|
// ------------------------------------------------------------------------ |
|
dkTool.push({ |
|
description: '「待機武将一覧」の武将ステータスに「次のレベルの経験値」(次LvEXP)を表示', |
|
id: 'dk_deck_status_nextexp', |
|
className: 'dk_nextexp', |
|
set: function() { |
|
var $elm = $('#box .ig_deck_smallcardarea'); |
|
if ($elm.length >= 1 && $('.' + this.className).length === 0 && GM_getValue(this.id)) { |
|
$('#box .ig_deck_smallcardarea').each(function() { |
|
// 次のレベルの経験値を取得 |
|
var inlineId = $(this).find('.ig_deck_smallcardimage a').attr('href').replace(/^.*&inlineId=|&.*$/g, ''), |
|
nextexp = $('#' + inlineId + ' .ig_card_nextexp').text().replace('--', '-'); |
|
|
|
// HTML追加 |
|
$(this).find('.ig_deck_smallcarddataarea .ig_deck_smallcarddata:nth-child(1) tr:nth-child(2)').after('<tr className=' + this.className + '><th>次LvEXP</th><td>' + nextexp + '</td></tr>'); |
|
}); |
|
} |
|
}, |
|
reset: function() { |
|
$('.' + this.className).remove(); |
|
} |
|
}); |
|
|
|
|
|
// ------------------------------------------------------------------------ |
|
// 「兵編成」画面に「1ずつ編成」を追加 |
|
// ------------------------------------------------------------------------ |
|
// 2013-02-09 兵編成画面で1ずつ編成が簡単になったので、一旦コメントアウト |
|
/* |
|
dkTool.push({ |
|
description: '「兵編成」画面に「1ずつ編成」を追加', |
|
id: 'dk_set_unit_one_input', |
|
set: function() { |
|
var $elm = $('#ig_deckbox .ig_soldier_runbtn'); |
|
if ($elm.length >= 1 && $('#' + this.id).length === 0 && GM_getValue(this.id)) { |
|
// 編成可能な兵種を取得 |
|
var ary = []; |
|
$('#unit_id_arr\\[0\\]').find('option').each(function() { |
|
ary.push({ |
|
name: $(this).text().replace(/\(.*$/, ''), |
|
value: $(this).val() |
|
}); |
|
}); |
|
|
|
// HTML |
|
var html = '<div id="' + this.id + '">'; |
|
html += '1ずつ編成:'; |
|
html += '<select>'; |
|
for (var i = 0, l = ary.length; i < l; i++) { |
|
html += '<option value="' + ary[i].value + '">' + ary[i].name + '</option>'; |
|
} |
|
html += '</select>'; |
|
html += '</div>'; |
|
|
|
// HTMLを追加 |
|
$elm.append(html); |
|
|
|
// onchangeイベント |
|
$('#' + this.id).find('select').bind('change', function() { |
|
$('.job_s select').val($(this).val()); |
|
$('.cntchange input').val(1); |
|
}); |
|
} |
|
}, |
|
reset: function() { |
|
$('#' + this.id).remove(); |
|
} |
|
}); |
|
*/ |
|
|
|
|
|
// ------------------------------------------------------------------------ |
|
// 「兵士一覧」の下に「合計兵士数」を追加 |
|
// ------------------------------------------------------------------------ |
|
dkTool.push({ |
|
description: '「兵士一覧」の下に「合計兵士数」を追加', |
|
id: 'dk_set_unit_list_sum_soldiers', |
|
set: function() { |
|
var $elm = $('#soldiers_catalog tbody'); |
|
if ($elm.length >= 1 && $('#' + this.id).length === 0 && GM_getValue(this.id)) { |
|
// HTML |
|
var html = '<tr id="' + this.id + '">'; |
|
html += '<th colspan="2">合計</th>'; |
|
html += '<td class="td_left_posi wait_soldiers"></td>'; |
|
html += '<td class="td_left_posi soldiers"></td>'; |
|
html += '<td colspan="5" class="td_border_right">※兵数の変更によって、実際の数値と異なる場合があります。</td>'; |
|
html += '</tr>'; |
|
|
|
// HTMLを追加 |
|
$elm.append(html); |
|
|
|
// 兵数を計算、表示 |
|
this.sum(); |
|
} |
|
}, |
|
sum: function() { |
|
var $elm = $('#soldiers_catalog tbody'), |
|
sum_wait_soldiers = 0, |
|
sum_soldiers = 0; |
|
|
|
// 兵数を計算 |
|
$elm.find('tr').not('tr#' + this.id).each(function() { |
|
var cnt = 0; |
|
$(this).find('td.td_left_posi').each(function() { |
|
cnt++; |
|
// 対騎兵数 |
|
if (cnt === 1) { |
|
sum_wait_soldiers += parseInt($(this).text(), 10); |
|
} |
|
// 総兵数 |
|
if (cnt === 2) { |
|
sum_soldiers += parseInt($(this).text(), 10); |
|
} |
|
}); |
|
}); |
|
|
|
// 表示 |
|
$('#' + this.id) |
|
.find('.wait_soldiers').text(sum_wait_soldiers) |
|
.end() |
|
.find('.soldiers').text(sum_soldiers); |
|
}, |
|
reset: function() { |
|
$('#' + this.id).remove(); |
|
} |
|
}); |
|
|
|
|
|
// ------------------------------------------------------------------------ |
|
// サイドバーの「状態」に部隊一覧を表示 |
|
// ------------------------------------------------------------------------ |
|
dkTool.push({ |
|
description: 'サイドバーの「状態」に「部隊一覧」を追加', |
|
id: 'dk_sidebar_deck_status_unitlist', |
|
set: function() { |
|
if ($('#' + this.id).length === 0 && GM_getValue(this.id)) { |
|
var o = this, |
|
gmName = this.id + '_data'; |
|
|
|
// 一旦、GM_getValueの情報を表示 |
|
if (GM_getValue(gmName)) { |
|
appendHtml(o.id, $.parseJSON(GM_getValue(gmName))); |
|
} |
|
|
|
// 全部隊の出陣状況一覧を取得 |
|
$.ajax({ |
|
url: '/facility/unit_status.php?dmo=all', |
|
success: function(data) { |
|
var ary = []; |
|
$(data).find('#box .ig_fight_statusarea').each(function() { |
|
ary.push({ |
|
name: $(this).find('.ig_fightunit_title h3, .ig_dungeonunit_title h3').text().replace(/\s|(.*)/g, ''), |
|
href: $(this).find('.ig_fightunit_title a, .ig_dungeonunit_title a').attr('href'), |
|
status: getStatus($(this).find('table tr:nth-child(2) td img[src^="http://cache.sengokuixa.jp"]').attr('src')) |
|
}); |
|
}); |
|
|
|
// GM_getValue(name)の値と比較 |
|
if (GM_getValue(gmName) !== $.toJSON(ary)) { |
|
// HTML |
|
appendHtml(o.id, ary); |
|
|
|
// GM_setValue |
|
GM_setValue(gmName, $.toJSON(ary)); |
|
} |
|
} |
|
}); |
|
} |
|
|
|
// 状態判別関数 |
|
function getStatus(str) { |
|
if (typeof str !== 'string') { |
|
// String型以外の場合は、とりあえず「待機」と判断する |
|
return 'wait'; |
|
} |
|
if (str.match(/wait/)) { |
|
return 'wait'; |
|
} else if (str.match(/attack/)) { |
|
return 'attack'; |
|
} else if (str.match(/meeting/)) { |
|
return 'meeting'; |
|
} else if (str.match(/backup/)) { |
|
return 'backup'; |
|
} else if (str.match(/return/)) { |
|
return 'return'; |
|
} else if (str.match(/dungeon/)) { |
|
return 'dungeon'; |
|
} else if (str.match(/develop/)) { |
|
return 'develop'; |
|
} else if (str.match(/move/)) { |
|
return 'move'; |
|
} else { |
|
return str; |
|
} |
|
} |
|
|
|
// 状態の日本語名を取得 |
|
function getStatusJP(str) { |
|
if (str.match(/wait/)) { |
|
return '待機'; |
|
} else if (str.match(/attack/)) { |
|
return '攻撃'; |
|
} else if (str.match(/meeting/)) { |
|
return '合流'; |
|
} else if (str.match(/backup/)) { |
|
return '加勢'; |
|
} else if (str.match(/return/)) { |
|
return '帰還'; |
|
} else if (str.match(/dungeon/)) { |
|
return '探索'; |
|
} else if (str.match(/develop/)) { |
|
return '開拓'; |
|
} else if (str.match(/move/)) { |
|
return '国移動'; |
|
} else { |
|
return str; |
|
} |
|
} |
|
|
|
// HTMLを追加 |
|
function appendHtml(id, ary) { |
|
// idを持つ要素を削除 |
|
$('#' + id).remove(); |
|
|
|
// HTML |
|
var str = '<div id="' + id + '">'; |
|
str += '<div class="sideBoxHead"><h4>部隊一覧</h4></div>'; |
|
str += '<div class="sideBoxInner">'; |
|
str += '<ul>'; |
|
for (var i = 0, l = ary.length; i < l; i++) { |
|
if (ary[i].name === $('#ig_unitchoice .now').text()) { |
|
// カレントページの場合 |
|
str += '<li class="on">' + ary[i].name + '<span class="icon ' + ary[i].status + '">' + getStatusJP(ary[i].status) + '</span></a>'; |
|
} else { |
|
// カレントページ意外の場合は、 |
|
str += '<li><a href="' + ary[i].href + '">' + ary[i].name + '<span class="icon ' + ary[i].status + '">' + getStatusJP(ary[i].status) + '</span></a></li>'; |
|
} |
|
} |
|
str += '</ul>'; |
|
str += '</div>'; |
|
str += '</div>'; |
|
|
|
// HTMLを追加 |
|
$('#sideboxTop > .sideBox:nth-child(3) .stateTable').after(str); |
|
} |
|
}, |
|
reset: function() { |
|
$('#' + this.id).remove(); |
|
} |
|
}); |
|
|
|
|
|
// ------------------------------------------------------------------------ |
|
// サイドバーの「状態」にショートカットメニューを追加 |
|
// ------------------------------------------------------------------------ |
|
dkTool.push({ |
|
description: 'サイドバーの「状態」にショートカットメニューを追加', |
|
id: 'dk_sidebar_deck_status_shortcut', |
|
set: function() { |
|
if ($('#' + this.id).length === 0 && GM_getValue(this.id)) { |
|
// 表示するショートカットメニュー |
|
var ary = [ |
|
{ |
|
name: '部隊編成', |
|
href: '/card/deck.php' |
|
}, { |
|
name: '出陣状況(全部隊)', |
|
href: '/facility/unit_status.php?dmo=all' |
|
}, { |
|
name: '兵士編成', |
|
href: '/facility/set_unit_list.php' |
|
}, { |
|
name: '待機兵士一覧', |
|
href: '/facility/unit_list.php' |
|
} |
|
]; |
|
|
|
// HTML |
|
var str = '<div id="' + this.id + '">'; |
|
str += '<div class="sideBoxHead"><h4>ショートカットメニュー</h4></div>'; |
|
str += '<div class="sideBoxInner">'; |
|
str += '<ul>'; |
|
for (var i = 0, l = ary.length; i < l; i++) { |
|
//if (ary[i].href === url) { |
|
if (location.href.match(new RegExp(ary[i].href.replace('?', '\\?')))) { |
|
// カレントページの場合 |
|
str += '<li class="on">' + ary[i].name + '</a>'; |
|
} else { |
|
// カレントページ意外の場合は、 |
|
str += '<li><a href="' + ary[i].href + '">' + ary[i].name + '</span></a></li>'; |
|
} |
|
} |
|
str += '</ul>'; |
|
str += '</div>'; |
|
str += '</div>'; |
|
|
|
// HTMLを追加 |
|
$('#sideboxTop > .sideBox:nth-child(3)').append(str); |
|
} |
|
}, |
|
reset: function() { |
|
$('#' + this.id).remove(); |
|
} |
|
}); |
|
|
|
|
|
// ------------------------------------------------------------------------ |
|
// サイドバーの「表示拠点選択」を「状態」の下に移動 |
|
// ------------------------------------------------------------------------ |
|
dkTool.push({ |
|
description: 'サイドバーの「表示拠点選択」を「状態」の下に移動', |
|
id: 'dk_sidebar_village_relocate', |
|
set: function() { |
|
if (GM_getValue(this.id)) { |
|
$('#sideboxBottom .sideBox:nth-child(1)').before($('#sideboxBottom .sideBox:nth-child(2)')); |
|
} |
|
}, |
|
reset: function() { |
|
$('#sideboxBottom .sideBox:nth-child(1)').before($('#sideboxBottom .sideBox:nth-child(2)')); |
|
} |
|
}); |
|
|
|
|
|
// ------------------------------------------------------------------------ |
|
// 「出陣確認」画面に合流用情報コピー欄を追加 |
|
// ------------------------------------------------------------------------ |
|
dkTool.push({ |
|
description: '「出陣確認」画面に合流用情報コピー欄を追加', |
|
id: 'dk_gofightconfirmboxtitle_meeting_info', |
|
set: function() { |
|
var $elm = $('#ig_gofightconfirmboxtitle'); |
|
if ($elm.length >= 1 && $('#' + this.id).length === 0 && GM_getValue(this.id)) { |
|
// 目的地、時間を取得 |
|
var destination,time; |
|
destination = $elm.find('tr:nth-child(1) td:nth-child(2)').text().replace(/\t/g, ''); |
|
time = $elm.find('tr:nth-child(2) td:nth-child(2)').text().replace(/\t| /g, ' '); |
|
|
|
// HTML |
|
var html = '<table class="paneltable table_gofight_conftitle" id="' + this.id + '">'; |
|
html += '<tr>'; |
|
html += '<th>合流情報</th>'; |
|
html += '<td colspan="4"><input type="text" value="' + destination + ' ' + time + '"></td>'; |
|
html += '</tr>'; |
|
|
|
destination = destination.match(/\(.*\)/)[0]; |
|
destination = destination.replace(/\(|\)/g, ''); |
|
time = time.split(' ')[1]; |
|
var ary = time.split(':'); |
|
if (parseInt(ary[0], 10) === 0) { |
|
time = ary[1] + ':' + ary[2]; |
|
} |
|
|
|
html += '<th>合流情報(簡易版)</th>'; |
|
html += '<td colspan="4"><input type="text" value="' + destination + 'まで' + time + '"></td>'; |
|
html += '</tr>'; |
|
html += '</table>'; |
|
|
|
// HTMLを追加 |
|
$elm.append(html); |
|
|
|
// 合流用情報にフォーカス |
|
$('#' + this.id).find('input[type="text"]').bind('click focus', function() { |
|
$(this).select(); |
|
return false; |
|
}); |
|
} |
|
}, |
|
reset: function() { |
|
$('#' + this.id).remove(); |
|
} |
|
}); |
|
|
|
|
|
// ------------------------------------------------------------------------ |
|
// dkToolを実行 |
|
// ------------------------------------------------------------------------ |
|
for (var i = 0, l = dkTool.length; i < l; i++) { |
|
dkTool[i].set(); |
|
} |
|
|
|
|
|
// ------------------------------------------------------------------------ |
|
// 設定画面 |
|
// ------------------------------------------------------------------------ |
|
var dkSetting = function() { |
|
// HTML |
|
var str = '<div id="dkSetting_window" style="display:none">', |
|
checked = ''; |
|
str += '<ul class="dkSetting_ul">'; |
|
for (var i = 0, l = dkTool.length; i < l; i++) { |
|
checked = ''; |
|
if (GM_getValue(dkTool[i].id)) { |
|
checked = 'checked'; |
|
} |
|
str += '<li><label><input type="checkbox" data-id="' + dkTool[i].id + '" data-num="' + i + '" ' + checked + '> ' + dkTool[i].description + '</label></li>'; |
|
} |
|
str += '</ul>'; |
|
str += '<p class="right"><a href="#" id="dkSetting_delete">設定を削除</a></p>'; |
|
str += '<div>'; |
|
|
|
// HTMLを追加 |
|
$('body').append(str); |
|
|
|
// 設定ボタンを追加 |
|
$('#navi01 ul').append('<li><a href="#TB_inline?height=180&width=485&inlineId=dkSetting_window" class="thickbox" title="GM設定" id="dkSetting">GM設定</a></li>'); |
|
|
|
// ThickBoxの表示位置がバグるため、styleを追加 |
|
$('#dkSetting').click(function() { |
|
// #TB_windowが表示されるまで少し待つ |
|
setTimeout(function() { |
|
$('.dkSetting_ul').parent().parent().css({ |
|
marginTop: '14px' |
|
}); |
|
}, 0.1); |
|
}); |
|
|
|
// 設定を削除 |
|
$('#dkSetting_delete').click(function() { |
|
if (confirm("GM設定を削除しますか?\n(リセットすると全ての機能がオフになります)")) { |
|
var ary = GM_listValues(); |
|
for (var i = 0, l = ary.length; i < l; i++) { |
|
GM_deleteValue(ary[i]); |
|
} |
|
$('.dkSetting_ul input').removeAttr('checked'); |
|
} |
|
}); |
|
|
|
// チェックボックス |
|
$('.dkSetting_ul').find('input').change(function() { |
|
var num = parseInt($(this).data('num'), 10); |
|
if ($(this).attr('checked')) { |
|
GM_setValue($(this).data('id'), true); |
|
dkTool[num].set(); |
|
} else { |
|
GM_setValue($(this).data('id'), false); |
|
dkTool[num].reset(); |
|
} |
|
}); |
|
}; |
|
dkSetting(); |
|
|
|
|
|
// ------------------------------------------------------------------------ |
|
// CSS |
|
// ------------------------------------------------------------------------ |
|
var dkCss = function() { |
|
// 開始タグ |
|
var str = '<style id="dkCss">'; |
|
|
|
// 「待機武将一覧」の武将ステータスに「次のレベルの経験値」(次LvEXP)を表示している場合 |
|
if (GM_getValue('dk_deck_status_nextexp')) { |
|
str += '#ig_deck_smallcardarea_out.union .ig_deck_smallcardarea { height: 262px; }'; |
|
} |
|
|
|
// 「兵編成」画面の「1ずつ編成」 |
|
// 2013-02-09 機能停止中のため、一旦コメントアウト |
|
//str += '#dk_set_unit_one_input { float: left; margin: 2px 6px; }'; |
|
|
|
// 合計兵士数 |
|
str += '#dk_set_unit_list_sum_soldiers th { padding: 6px 0 0; border-top: none; }'; |
|
|
|
// サイドバーの状態の下 |
|
str += '#sideboxTop > .sideBox:nth-child(3) div.sideBoxInner { padding:5px; }'; |
|
str += '#sideboxTop > .sideBox:nth-child(3) li { margin-left: 6px; margin-bottom: 6px; padding-left: 8px; background: url(../img/common/sidebar/icon_off.gif) no-repeat 0 2px; }'; |
|
str += '#sideboxTop > .sideBox:nth-child(3) li:last-child { margin-bottom: 0; }'; |
|
str += '#sideboxTop > .sideBox:nth-child(3) li.on { color: #ffff00; background-image: url(../img/common/sidebar/icon_on.gif); }'; |
|
str += '#sideboxTop > .sideBox:nth-child(3) .icon { display: inline-block; margin-left: 2px; padding: 2px; border-width: 1px; border-style: solid; border-radius: 3px; color: #fff; text-decoration: none; }'; |
|
str += '#sideboxTop > .sideBox:nth-child(3) .wait { border-color: #3f7126; background-color: #3f7126; }'; |
|
str += '#sideboxTop > .sideBox:nth-child(3) .attack { border-color: #981b1a; background-color: #981b1a; }'; |
|
str += '#sideboxTop > .sideBox:nth-child(3) .meeting { border-color: #014a7c; background-color: #014a7c; }'; |
|
str += '#sideboxTop > .sideBox:nth-child(3) .backup { border-color: #003467; background-color: #003467; }'; |
|
str += '#sideboxTop > .sideBox:nth-child(3) .return { border-color: #676767; background-color: #676767; }'; |
|
str += '#sideboxTop > .sideBox:nth-child(3) .dungeon { border-color: #ff8100; background-color: #ff8100; }'; |
|
str += '#sideboxTop > .sideBox:nth-child(3) .develop { border-color: #004f00; background-color: #004f00; }'; |
|
str += '#sideboxTop > .sideBox:nth-child(3) .move { border-color: #823482; background-color: #823482; }'; |
|
|
|
// 部隊一覧 |
|
str += '#sideboxTop > .sideBox:nth-child(3) #dk_sidebar_deck_status_unitlist li { background-position: 0 5px; }'; |
|
|
|
// ショートカットメニュー |
|
str += '#sideboxTop > .sideBox:nth-child(3) #dk_sidebar_deck_status_shortcut .sideBoxInner { padding-top: 8px; }'; |
|
str += '#sideboxTop > .sideBox:nth-child(3) #dk_sidebar_deck_status_shortcut li { margin-bottom: 8px; }'; |
|
str += '#sideboxTop > .sideBox:nth-child(3) #dk_sidebar_deck_status_shortcut li:last-child { margin-bottom: 2px; }'; |
|
|
|
// 「出陣確認」画面に合流用情報コピー欄 |
|
str += '#ig_gofightconfirmboxtitle { height: 132px; }'; |
|
str += '#dk_gofightconfirmboxtitle_meeting_info { margin: 24px 0; }'; |
|
str += '#dk_gofightconfirmboxtitle_meeting_info th { width: 128px; border-top: 1px solid #fff; }'; |
|
str += '#dk_gofightconfirmboxtitle_meeting_info td { padding: 2px 2px 0; border-top: 1px solid #fff; }'; |
|
str += '#dk_gofightconfirmboxtitle_meeting_info input[type="text"] { width: 410px; margin-bottom: 2px; padding: 4px; border: none; font-size: 12px; font-family: "MS P明朝","細明朝体","ヒラギノ明朝 Pro W3"; }'; |
|
|
|
// GM設定 |
|
str += '#dkSetting { display: block; width: 60px; margin-top: 7px; padding: 2px 0 1px; border: 1px solid #fff; border-radius:3px; color: #000; font-size: 9px;text-align: center; text-decoration: none; background-color: #fff; }'; |
|
|
|
// 設定ウィンドウ |
|
str += '.dkSetting_ul { padding: 10px 0; }'; |
|
str += '.dkSetting_ul li { list-style: disc; margin-bottom: 7px; margin-left: 20px; }'; |
|
str += '.dkSetting_reset li input { margin-right: 7px; }'; |
|
str += '.right { text-align: right; }'; |
|
|
|
// 終了タグ |
|
str += '</style>'; |
|
|
|
// append |
|
$('head').append(str); |
|
}; |
|
dkCss(); |
|
})(); |