/*
* @title bookmarklet
* @description my bookmarklet
* @include http://*
* @license MIT License
* @require
*/
var v2y=(raw)=>{
insertHistory(raw);
insertSimpleInfo(raw);
insertItemsData(raw);
insertWeapons(raw);
insertHonor(raw);
insertBattleSkill(raw);
insertSubBattleSkills(raw);
};
var insertSubBattleSkills=(raw)=>{
const insertSubBattleSkillsBySkill = (nameBase, skillList)=>{
skillList.forEach((name, i)=>{
selectByText(`${nameBase}${i+1}`, name);
});
};
insertSubBattleSkillsBySkill('craftEnhance', raw.ES_name);
insertSubBattleSkillsBySkill('craftSong', raw.JK_name);
insertSubBattleSkillsBySkill('craftRiding', raw.KG_name);
insertSubBattleSkillsBySkill('craftAlchemy', raw.HJ_name);
insertSubBattleSkillsBySkill('craftCommand', raw.HO_name);
insertSubBattleSkillsBySkill('craftDivination', raw.UR_name);
insertSubBattleSkillsBySkill('craftPotential', raw.MS_name);
insertSubBattleSkillsBySkill('craftDignity', raw.KK_name);
insertSubBattleSkillsBySkill('magicGramarye', raw.skill_name);
insertSubBattleSkillsBySkill('craftSeal', raw.JI_name);
};
var insertBattleSkill=(raw)=>{
const nums = {
'1': 'Ⅰ', '2':'Ⅱ', '3':'Ⅲ', '4':'Ⅳ', '5':'Ⅴ'
};
raw.ST_name.map((name, i)=>{
const newName = name.replace('/', '/').replace('A', 'A').replace('S', 'S');
if(Number(raw.ST_tlv[i])) {
return newName + nums[raw.ST_tlv[i]];
}
return newName;
}).forEach((name, i)=>{
selectByText(`combatFeatsLv${i*2+1}`, name);
});
};
var insertHonor=(raw)=>{
const list = raw.honorout_item_name;
for(var lackedHonorCount = list.length - 3; lackedHonorCount > 0; lackedHonorCount--) {
addHonorItems();
}
list.forEach((name, i)=>{
inputByName(`honorItem${i+1}`, name);
inputByName(`honorItem${i+1}Pt`, raw.honorout_item_point[i]);
});
};
var insertHistory=(raw)=>{
const bases = {
'1':'器用', '2':'敏捷', '3':'筋力', '4':'生命', '5':'知力', '6':'精神'
};
const list = raw.V_SN_his;
for(var lackedHistoryCount = list.length - 3; lackedHistoryCount > 0; lackedHistoryCount--) {
addHistory();
}
list.forEach((base, i)=>{
inputByName(`history${i+1}Exp`, raw.get_exp_his[i]);
inputByName(`history${i+1}Money`, raw.get_money_his[i]);
inputByName(`history${i+1}Grow`, bases[base]);
inputByName(`history${i+1}Note`, raw.seicho_memo_his[i]);
});
};
var insertWeapons=(raw)=>{
const skills = {
'1': 'ファイター', '2': 'グラップラー', '3': 'フェンサー', '4': 'シューター',
'13': 'エンハンサー', '17': 'デーモンルーラー'
};
const list = raw.arms_name;
for(var lackedWeaponsCount = list.length - 3; lackedWeaponsCount > 0; lackedWeaponsCount--) {
addWeapons();
}
raw.arms_name.forEach((name, i)=>{
inputByName(`weapon${i+1}Name`, name);
inputByName(`weapon${i+1}Usage`, raw.arms_yoho[i]);
inputByName(`weapon${i+1}Reqd`, raw.arms_hitsukin[i]);
inputByName(`weapon${i+1}Acc`, Number(raw.arms_hit_mod[i]) || 0);
inputByName(`weapon${i+1}Rate`, Number(raw.arms_iryoku[i]) || 0);
inputByName(`weapon${i+1}Crit`, Number(raw.arms_critical[i]) || 10);
inputByName(`weapon${i+1}Dmg`, Number(raw.arms_damage_mod[i]) || 0);
inputByName(`weapon${i+1}Note`, raw.arms_memo[i]);
inputByName(`weapon${i+1}Class`, skills[raw.V_arms_hit_ginou[i]]);
inputByName(`weapon${i+1}Category`, raw.arms_cate[i]);
checkByName(`weapon${i+1}Own`, raw.arms_is_senyou[i] === '1');
calcWeapon();
});
checkByName('armourOwn', raw.is_senyou_armer);
checkByName('shieldOwn', raw.is_senyou_shield);
};
var insertItemsData=(raw)=>{
const items = raw.item_name.map((name, i)=>{
if(name){
if(raw.item_memo[i]) {
return `${name} (${raw.item_tanka[i]}) × ${raw.item_num[i]} …… ${raw.item_memo[i]}`;
} else {
return `${name} (${raw.item_tanka[i]}) × ${raw.item_num[i]}`;
}
} else {return false;}
}).filter((d)=>{return d;}).join('\n');
inputByName('items', items);
};
var insertSimpleInfo=(raw)=>{
var simpleInputList = {
'characterName': raw.pc_name,
'freeNote': raw.pc_making_memo,
'race': raw.shuzoku_name,
'age': raw.age,
'gender': raw.sex,
'sin': raw.V_kegare,
'money': raw.money,
'history1Honor': raw.honor_point_sum,
'deposit': raw.debt,
'tags': raw.pc_tags,
'birth': raw.umare_name,
'sttBaseTec': raw.N_waza, 'sttBasePhy': raw.N_karada, 'sttBaseSpi': raw.N_kokoro,
'sttBaseA': raw.V_NC1, 'sttBaseB': raw.V_NC2, 'sttBaseC': raw.V_NC3, 'sttBaseD': raw.V_NC4, 'sttBaseE': raw.V_NC5, 'sttBaseF': raw.V_NC6,
'lvFig': raw.V_GLv1, 'lvGra': raw.V_GLv2, 'lvFen': raw.V_GLv3, 'lvSho': raw.V_GLv4,
'lvSor': raw.V_GLv5, 'lvCon': raw.V_GLv6, 'lvPri': raw.V_GLv7,
'lvFai': raw.V_GLv8, 'lvMag': raw.V_GLv9, 'lvDem': raw.V_GLv17,
'lvSco': raw.V_GLv10, 'lvRan': raw.V_GLv11, 'lvSag': raw.V_GLv12,
'lvEnh': raw.V_GLv13 , 'lvBar': raw.V_GLv14, 'lvRid': raw.V_GLv16,
'lvAlc': raw.V_GLv15, 'lvWar': raw.V_GLv18, 'lvMys': raw.V_GLv19, 'lvPhy': raw.V_GLv20,
'lvGri': raw.V_GLv21, 'lvArt': raw.V_GLv22, 'lvAri': raw.V_GLv23,
'evasionClass': raw.kaihi_ginou_name,
'armourName': raw.armor_name, 'armourReqd':raw.armor_hitsukin, 'armourNote': raw.armor_memo,
'armourDef':raw.armor_bougo || 0, 'armourEva':raw.armor_kaihi || 0,
'shieldName': raw.shield_name, 'shieldReqd':raw.shield_hitsukin, 'shieldNote': raw.shield_memo,
'shieldDef':raw.shield_bougo || 0, 'shieldEva':raw.shield_kaihi || 0,
'defOtherName': raw.shield2_name, 'defOtherReqd':raw.shield2_hitsukin, 'defOtherNote': raw.shield2_memo,
'defOtherDef':raw.shield2_bougo || 0, 'defOtherEva':raw.shield2_kaihi || 0,
'accessoryHeadName': raw.acce1_name[0], 'accessoryHeadNote': raw.acce1_memo[0],
'accessoryEarName': raw.acce2_name[0], 'accessoryEarNote': raw.acce2_memo[0],
'accessoryFaceName': raw.acce3_name[0], 'accessoryFaceNote': raw.acce3_memo[0],
'accessoryNeckName': raw.acce4_name[0], 'accessoryNeckNote': raw.acce4_memo[0],
'accessoryBackName': raw.acce5_name[0], 'accessoryBackNote': raw.acce5_memo[0],
'accessoryHandRName': raw.acce6_name[0], 'accessoryHandRNote': raw.acce6_memo[0],
'accessoryHandLName': raw.acce7_name[0], 'accessoryHandLNote': raw.acce7_memo[0],
'accessoryWaistNote': raw.acce8_name[0], 'accessoryWaistNote': raw.acce8_memo[0],
'accessoryLegNote': raw.acce9_name[0], 'accessoryLegNote': raw.acce9_memo[0],
'accessoryOtherName': raw.acce10_name[0], 'accessoryOtherNote': raw.acce10_memo[0],
};
for( var key in simpleInputList ) {
inputByName(key, simpleInputList[key]);
}
};
var checkByName = (name, value)=>{
document.getElementsByName(name)[0].checked = value;
};
var selectByText = (name, value)=>{
const dom = document.getElementsByName(name)[0];
dom.value = value;
};
var inputByName=(name,value)=>{
const evt = document.createEvent("HTMLEvents");
evt.initEvent('input', true, true );
const dom = document.getElementsByName(name)[0];
dom.value=value;
dom.dispatchEvent(evt);
console.log(name, value);
};
var load=()=>{
let sheet=prompt('キャラクター保管所のキャラクターシートのURLを入力してください','https://charasheet.vampire-blood.net/2179993') || '';
if(sheet===''){return;}
let sc = document.createElement("script");
sc.type = 'text/javascript';
sc.src = `${sheet}.js?callback=v2y`;
let parent = document.getElementsByTagName("script")[0];
parent.parentNode.insertBefore(sc,parent);
};
load();