Last active
August 29, 2015 14:18
-
-
Save puyo-sh/0e1d000aeeb96256ea08 to your computer and use it in GitHub Desktop.
ブラウザ三国志 防御情報CSV化
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name 3gokushi-DeffenceData | |
// @namespace https://github.com/puyo-sh/bro3 | |
// @description ブラウザ三国志 防御情報CSV化 | |
// @include http://*.3gokushi.jp/* | |
// @version 1.2 | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js | |
// ==/UserScript== | |
// 2015.04.09 ver1.0 とりあえず作成 | |
// 2015.04.09 ver1.1 同盟ログにも生成リンク表示 | |
// 2015.04.09 ver1.2 攻撃ログの武将情報を取得 | |
(function ($){ | |
makeDeffenceData = function(){ | |
var deffence_table = j$("table[summary='防御者']"); | |
if(deffence_table.length > 0){ | |
var soldierType = ''; | |
$.each(deffence_table,function(t){ | |
var rows = deffence_table[t].rows; | |
// 初期化 | |
var player = ''; | |
var sldrUnit1,sldrUnit2,sldrUnit3,sldrUnit4,sldrUnit5,sldrUnit6,sldrUnit7, | |
sldrUnit8,sldrUnit9,sldrUnit10,sldrUnit11,sldrUnit12,sldrUnit13,sldrUnit14,sldrUnit15; | |
var info = ''; | |
// 処理開始 | |
$.each(rows, function(i) { | |
var cells = rows[i].cells; | |
$.each(cells,function(s){ | |
switch(i){ | |
case 0: | |
if(s == 1){ | |
player = j$(this).find("a").eq(1).text(); | |
} | |
break; | |
case 1: // 下級兵 兵種 | |
if(t==0 && s > 0){ | |
soldierType += '"'+j$(this).text()+'",'; | |
} | |
break; | |
case 2: // 兵士数 | |
var soldirNum = Number(j$(this).text()); | |
switch(s){ | |
case 1: // 剣兵 | |
sldrUnit1 = soldirNum; | |
break; | |
case 2: // 盾兵 | |
sldrUnit2 = soldirNum; | |
break; | |
case 3: // 槍兵 | |
sldrUnit3 = soldirNum; | |
break; | |
case 4: // 弓兵 | |
sldrUnit4 = soldirNum; | |
break; | |
case 5: // 騎兵 | |
sldrUnit5 = soldirNum; | |
break; | |
case 6: // 衝車 | |
sldrUnit6 = soldirNum; | |
break; | |
case 7: // 斥候 | |
sldrUnit7 = soldirNum; | |
break; | |
} | |
break; | |
case 3: // 死傷数 | |
var soldirNum = Number(j$(this).text()); | |
switch(s){ | |
case 1: // 剣兵 | |
sldrUnit1 = sldrUnit1 - soldirNum; | |
break; | |
case 2: // 盾兵 | |
sldrUnit2 = sldrUnit2 - soldirNum; | |
break; | |
case 3: // 槍兵 | |
sldrUnit3 = sldrUnit3 - soldirNum; | |
break; | |
case 4: // 弓兵 | |
sldrUnit4 = sldrUnit4 - soldirNum; | |
break; | |
case 5: // 騎兵 | |
sldrUnit5 = sldrUnit5 - soldirNum; | |
break; | |
case 6: // 衝車 | |
sldrUnit6 = sldrUnit6 - soldirNum; | |
break; | |
case 7: // 斥候 | |
sldrUnit7 = sldrUnit7 - soldirNum; | |
break; | |
} | |
break; | |
case 4: // 上級兵 兵種 | |
if(t==0 && s > 0){ | |
soldierType += '"'+j$(this).text()+'",'; | |
} | |
break; | |
case 5: // 兵士数 | |
var soldirNum = Number(j$(this).text()); | |
switch(s){ | |
case 1: // 大剣兵 | |
sldrUnit8 = soldirNum; | |
break; | |
case 2: // 重盾兵 | |
sldrUnit9 = soldirNum; | |
break; | |
case 3: // 矛槍兵 | |
sldrUnit10 = soldirNum; | |
break; | |
case 4: // 弩兵 | |
sldrUnit11 = soldirNum; | |
break; | |
case 5: // 近衛騎兵 | |
sldrUnit12 = soldirNum; | |
break; | |
case 6: // 投石機 | |
sldrUnit13 = soldirNum; | |
break; | |
case 7: // 斥候騎兵 | |
sldrUnit14 = soldirNum; | |
break; | |
case 8: // 武将 | |
sldrUnit15 = soldirNum; | |
break; | |
} | |
break; | |
case 6: // 死傷数 | |
var soldirNum = Number(j$(this).text()); | |
switch(s){ | |
case 1: // 大剣兵 | |
sldrUnit8 = sldrUnit8 - soldirNum; | |
break; | |
case 2: // 重盾兵 | |
sldrUnit9 = sldrUnit9 - soldirNum; | |
break; | |
case 3: // 矛槍兵 | |
sldrUnit10 = sldrUnit10 - soldirNum; | |
break; | |
case 4: // 弩兵 | |
sldrUnit11 = sldrUnit11 - soldirNum; | |
break; | |
case 5: // 近衛騎兵 | |
sldrUnit12 = sldrUnit12 - soldirNum; | |
break; | |
case 6: // 投石機 | |
sldrUnit13 = sldrUnit13 - soldirNum; | |
break; | |
case 7: // 斥候騎兵 | |
sldrUnit14 = sldrUnit14 - soldirNum; | |
break; | |
case 8: // 武将 | |
sldrUnit15 = sldrUnit15 - soldirNum; | |
break; | |
} | |
break; | |
case 7: // 武将情報 | |
if(s == 1){ | |
info = j$(this).text(); | |
} | |
break; | |
} | |
}); | |
}); | |
// 1tableの処理終了 | |
var one_line = '"'+sldrUnit1+'","'+sldrUnit2+'","'+sldrUnit3+'","'+sldrUnit4+'","'+sldrUnit5+'","'+sldrUnit6+'","'+sldrUnit7+'","","'+sldrUnit8+'","'+sldrUnit9+'","'+sldrUnit10+'","'+sldrUnit11+'","'+sldrUnit12+'","'+sldrUnit13+'","'+sldrUnit14+'","'+sldrUnit15+'"'; | |
var infoMatch = delCode(info); | |
j$("#deffence_result").append('"'+player+'",'+one_line+',"'+infoMatch+"\"\n"); | |
}); | |
} | |
j$("#deffence_result").prepend('"",'+soldierType+"\n"); | |
} | |
/* Functions | |
-----------------------------------------------------------------------*/ | |
function htmlspecialchars(ch) { | |
ch = ch.replace(/&/g,"&") ; | |
ch = ch.replace(/"/g,"'") ; | |
ch = ch.replace(/'/g,"'") ; | |
ch = ch.replace(/</g,"<") ; | |
ch = ch.replace(/>/g,">") ; | |
return ch ; | |
} | |
function delCode(ch){ | |
var org_ch = ch; | |
ch = ch.match(/参戦した武将:([^(\$||")]+)獲得経験値/); | |
if(ch != void(0)){ | |
ch = ch[1]; | |
ch = ch.replace(/\s\s/g," "); | |
ch = ch.replace(/\[生存\]/g,""); | |
return ch; | |
}else{ | |
ch2 = org_ch.match(/参戦した武将:([^(\$||")]+)/); | |
if(ch2 != void(0)){ | |
ch2 = ch2[1]; | |
ch2 = ch2.replace(/\n/g," "); | |
ch2 = ch2.replace(/\s\s/g," "); | |
ch2 = ch2.replace(/\[生存\]/g,""); | |
ch2 = ch2.replace(/\[戦闘不能\]/g,""); | |
if(ch2.indexOf('いません') != -1){ | |
ch2 = ''; | |
} | |
return ch2; | |
} | |
} | |
return ""; | |
} | |
if(location.pathname.indexOf('/report/detail.php') != -1 || location.pathname.indexOf('/alliance/detail.php') != -1){ | |
// 初期化 | |
j$("#gray02Wrapper > h2").after("<textarea id='deffence_result' style='width:100%;border:2px solid #CCCCCC; height:100px; overflow-y:scroll;font-size:10px;display:none;'></textarea>"); | |
j$('#deffence_result').focus(function(){ | |
j$(this).select(); | |
}); | |
var deffenceDataButton = j$("<a>防御情報生成</a>"); | |
deffenceDataButton.click(function(){ | |
j$("#deffence_result").empty(); | |
j$("#deffence_result").show(); | |
// Run | |
makeDeffenceData(); | |
}); | |
j$("#gray02Wrapper > h2").after(deffenceDataButton); | |
} | |
})(jQuery); | |
jQuery.noConflict(); | |
j$ = jQuery; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1.報告書から対象の結果の詳細画面を開く
2.「防御情報生成」をクリック
3.表示されたBOX情報をコピーし、テキストファイルに貼り付けて保存する(文字コードはUTF-8がオススメ)
4.GoogleSpreadSheetを開く
[ファイル]→[インポート]→[アップロード]で表示されたダイアログをそのままで[インポート]ボタンを押せば一覧が生成される