【2021.04.23追加】 一部修正をしました。 修正後に必要な場合は moko 設定の「LocalStrageの一部クリア」を実施してください。
【2021.04.10追加】 一部修正をしました。 修正後に moko 設定の「LocalStrageの一部クリア」を実施してください。
某機能の初期案に対して 3mm./i2I さんのコードを丸パクリするとこうなりますw
資源バーの各リンクメニューをどうしても変えたくない人向けな感じです。
① getCountryCode()
(ここの内容は、そのまま同じ変更をしています。)
//自国番号と合戦国番号を取得
function getCountryCode() {
var countrycode = [],
date_now = [Date()],
+ atkdef = '',
tmp = getStorage({}, 'ixamoko_country_code');
date_now[1] = Date.parse(date_now[0]);
- if (tmp && (date_now[1] - tmp.date) < 86400000) {
+ if (tmp && tmp.battle_mode == (BATTLE_MODE??'') && (date_now[1] - tmp.date) < 86400000) {
return tmp.countrycode;
}
- tmp.date = Date.parse(date_now[0].replace(/\d+:\d+:\d+/, '10:00:00'));
+ tmp.date = Date.parse(date_now[0].replace(/\d+:\d+:\d+/, '10:10:00'));
tmp.date -= tmp.date < date_now[1] ? 0 : 86400000;
+ tmp.battle_mode = BATTLE_MODE ?? '';
// 全国地図のページから自国と合戦場国の国番号を取得
var html = $.ajax({
url: '/country/all.php',
cache: true,
async: false,
timeout: 2000,
dataType: 'text',
beforeSend: xrwStatusText,
}).responseText;
$(html).find('dl.OwnWin a').each(function() {
countrycode.push($(this).attr('href').match(/c=\d+/)[0].replace('c=', ''));
});
if (!countrycode[1]) {
countrycode[1] = countrycode[0];
}
+ let $def_icons = $(html).find('div.box03 img[src*="icon_helm.gif"]'); // 一部追加(2021.04.10)
+ let $def_icons = $(html).find('.ig_japanrank img[src*="icon_helm.gif"]'); // 一部変更(2021.04.10)
+ atkdef = ($def_icons.length == 0) ? '' : ( $def_icons.length % 2 == 0) ? 'atack' : 'defense';
+ atkdef = ($def_icons.length == 11)? '' : ( $def_icons.length % 2 == 0) ? 'atack' : 'defense'; // 一部変更(2021.04.23)
+ countrycode[2] = atkdef;
+ let win_lose = $(html).find('#tbl' + countrycode[0] + ' .ig_japanrank_unitwin').html().match(/\d+(?=\s*<img)/g);
+ countrycode[3] = {win:parseInt(win_lose[0]), lose:parseInt(win_lose[1]), total:parseInt(win_lose[0]) + parseInt(win_lose[1])};
tmp.countrycode = countrycode;
setStorage('ixamoko_country_code', tmp);
return countrycode;
}
② displayFamilyname()
(ロジックを丸パクリで、表示場所や表示内容を元のものにアレンジしていますので、全コピペで書き換えて下さい。)
・ 時間はスペース的に表示できないので、イベント名にマウスオーバーで吹き出しで表示します。
・ イベント終了時間(休戦1日目23:00)で影武者残党/秘境大殿の表示を消去しています。
// 所属家の表示
function displayFamilyname(){
$('div#btnLordName').append('<div id="familyname"></div>');
$('div#btnLordName').append('<div id="battlestatus"></div>');
$('div#btnLordName').append('<div id="menu_zantou"></div>');
$('div#menu_zantou').append('<div id="zantou"></div>');
$('div#zantou').after('<p class="arrow_box"></p>');
jQuery(function($){
$('div#familyname').text(COUNTRY.numberKey[getCountryCode()[0]]);
});
// 攻撃国/防衛国/天下統一戦、秘境大殿/影武者残党の表示
let country = getCountryCode();
if(BATTLE && country[2] !== undefined){
let icon;
if(BATTLE_MODE == '天下統一戦中'){
$('div#battlestatus').text('天下統一戦');
} else if (BATTLE_MODE == '合戦中' && country[2] == 'atack'){
icon = '../img/battle/japanmap/icon_battle.gif';
} else if (BATTLE_MODE == '合戦中' && country[2] == 'defense'){
icon = '../img/battle/japanmap/icon_helm.gif';
}
if(icon){
$('div#battlestatus').textprepend('<img src="' + icon + '" width="18" height="18" class="iepngfix">'); // 一部修正(2021.04.10)
}
} else if($('#area_war_timer').length) {
let text = (country[3].total%2 == 1 || country[2] == '') ? '秘境大殿' : '影武者残党';
let time = (text == '影武者残党' && country[2] == 'defense') ? '19:00' : '20:00';
$('div#battlestatus').hide();
$('div#zantou').text(text);
$('p.arrow_box').text(time);
}
var armisticeTimer = $('span#area_war_timer').text();
if(parseInt(armisticeTimer.substr(0,2)) < 35){ // 35で休戦日1日目23:00で消去 0で非消去
$('div#zantou').hide();
}
$(function () {
$('div#zantou').hover(function() {
$(this).next('p').show();
}, function(){
$(this).next('p').hide();
});
});
}
③ displayFamilyname() の登録
(登録済みの場合は、追加や変更不要です。)
// === execute function ===
allPageCheck(); // all
<中略>
changeUser(); // user
+ displayFamilyname() // user/familyname
④ main.css
(こちらも、全コピペで書き換えて下さい。)
/* 所属家の表示 #F60*/
div#btnLordName>a>img.iepngfix {position: relative; top: 0px; text-align: center;}
div#familyname {color:#F60; font-size:12px; text-align:center;}
div#battlestatus {color:#33CCFF; font-size:12px; text-align:center;}
div#zantou {color:yellow; font-size:12px; text-align:center;}
#menu_zantou {
position: relative;
}
.arrow_box {
display: none;
text-align:center;
position: absolute;
width:55px;
background: url("../img/common/resources_bar/bg.png") #000;
color: #fff;
padding: 5px;
box-sizing: border-box;
bottom: -25px;
left: 50%;
transform: translateX(-50%);
border: 1px solid #6B5C50;
box-shadow:4px 4px 4px -3px rgba(0, 0, 0, 0.8);
}
以上

