// ==UserScript== // @name route assistant // @namespace myhead // @description 金书红颜录路线武功规划脚本,需配合相关维基页面使用 // @version 1.1 // @grant none // @homepageURL https://greasyfork.org/zh-CN/scripts/13722-route-assistant // @include http://tpr.inkit.org/doku.php?id=tpr5:route // @downloadURL none // ==/UserScript== /* oResult={ '拳':[aRegExpSearchResult1{[0](matched content),[1](captured content in parenthesis),[2],index,input},aRegExpSearchResult2...], '剑':[], '兵':[], '特':[], '暗':[], '内':[], '轻':[], '余':[] } Pos= aC1[i] ={ __Con: { sMResult: entries list contained by current position sPath: route position chain sName: route position name, sCon: RegExp context of the position, nStart: start index in sCon, nEnd: end index in sCon }, next: [] //next is deeper list of route option object } 下列说明中[]表示被包围的是一个词,括号内容为这个词的描述,实际使用中不要输入[]。 路线格式:
#[天书或其他基本剧情部分1]
1 [第一级路线分歧1] bind [第一级路线分歧3]
2 [第二级路线分歧1]
@ 武功1+8-特 武功二+8阳-剑 武功5+8-特?2
2 [第二级路线分歧2]
@ 武功d+8-特
1 [第一级路线分歧2]
@ 武功233+8-特
#[天书或其他基本剧情部分1]
1 [第一级路线分歧3]
@ 武功233+8-特 武功2+3-特 武功1+8-特 武功8+8-特
……
每个以数字或符号开头的有效语句占一行。#表示选项路径的根;以1、2、3等一位数字开头的语句分别代表第一、二、三级的子选项,子选项最高9级;以@开头的为该选项路径的武功列表。
使用路线绑定时,在需要添加绑定的路线后添加 bind [要绑定的路线分歧],[]中的内容是需要绑定的目标路线选项名,不需要包含完整路径,也不要不含语句前的数字符号,bind的内容和要绑定的目标在忽视前后空格的情况下需要精确一致。根据路线情况可添加单向绑定(如水笙线的收狄云分支单向绑定白绣线)或双向绑定(如倚天与鹿鼎的绑定)。要同时为一个语句添加多个绑定,则需在句尾添加多个bind参数,bind参数之间以空格隔开。
缩进不是必要的,但为增强源数据可读性考虑请逐行缩进。
武功条目格式:
[武功名,请勿使用数字、空格,必须]+[指数,一位数字,可选][阴阳,一位字符,阴或阳,可选]-[系别,一位字符,可选]?[周目要求,一位数字,可选,缺省为1]
条目起始部分为不限长度的汉字序列,决定该武功条目的名称;加号 + 引导武功的系数、轻内的等级或其他有意义的一位数字,将被用在输出结果的排序中;紧跟着+号与一位数字的是武功对应内力性质,一位汉字,阴或者阳,只有在指定了+号与数字内容的情况下才能添加阴阳参数,在进行输出结果的过滤时,如果指定了阴阳选项,将筛选出阴阳属性相符的以及未限制阴阳的武功;减号 - 引导一位汉字的武功类型指代,将被用在输出结果的分类中;问号 ? 引导可获得该武功的最低周数,将被用于判断是否将该武功条目输出,默认为1。除了开头的武功名必须指定之外,其他所有参数都是可选的,但所有被使用的参数必须按照+-?的顺序出现。所有符号都应是半角英文符号。武功条目之间以空格分隔。
在编辑源数据时进行预排序(令武功条目从左至右从小到大基本有序)可降低脚本进行排序时的开销。
*/
var aC1= [],
//aC1 correspond to the list of route root object
aRoute=[],
oResult={},
sOrigin='',
sResult='',
t;
window.mainDiv= document.createElement('div'),
window.navi= document.createElement('div'),
window.div1= document.createElement('div'),
window.div2= document.createElement('div'),
window.div2p= document.createElement('div'),
window.div2f= document.createElement('div'),
window.round= document.createElement('select'),
window.speci= document.createElement('span'),
window.toggle= document.createElement('button'),
window.oTarget= {};
toggle.innerHTML="打开路线武功规划器";
toggle.onclick=function(){
if(sOrigin=== '') main();
mainDiv.style.display='';
};
window.onload=function(){
toggle.id='__toggle';
mainDiv.id='__mainDiv';
oTarget= document.getElementById('target');
oTarget.insertBefore(toggle,oTarget.firstChild);
};
function main(){
//search route and set UI;
if(!oTarget){
alert('找不到源数据');
return;
}
sOrigin=oTarget.textContent;
var rP1= /#(.+)/g,sMR='';
for(var i=0,aTemp;i<100;i++) {
aTemp=rP1.exec(sOrigin);
//aTemp contains [0] [1] .index .input
if (aTemp=== null) break;
t= aTemp.input.match(/\n\s*.*/)[0].match(/@(.*)/);
sMR= t? t[1]:'';
aC1[i]={
//aC1[i] is route option object
__Con: {
sMResult: sMR,
sPath: aTemp[0],
sName: aTemp[1].match(/\s*\S+\s*/)[0],
sCon: aTemp.input,
nStart: aTemp.index,
nEnd: undefined
},
next: []
//next is deeper list of route option object
};
//initialise the route result array
aRoute[i]= aC1[i];
if(i>0)
aC1[i-1].__Con.nEnd= aTemp.index-1;
}
//create UI and set up initial option list
mainDiv.setAttribute('style','position: absolute; left: 200px; top: 100px; width: 800px; height: 600px; background: white; border: solid #E0E0E0; overflow: auto;resize: both;');
//
navi.innerHTML=
""+
""+
"";
navi.setAttribute('style','border-bottom: solid #F0F0F0; background: #F0F0F0');navi.setAttribute('style','border-bottom: solid #F0F0F0;background: #F0F0F0');
div2.style.display='none';
div2.innerHTML+= '请选择周目:';
for(var i=1;i<7;i++)
round.innerHTML+='';
div2.appendChild(round);
button= document.createElement('button');
button.innerHTML='开始统计';
button.onclick= analyse;
div2.appendChild(button);
//create filter option bar div2f
div2f.innerHTML+= '结果过滤器:';
speci.innerHTML+=
'名称显示 '+
'类别'+
'阴阳'+
'最低数值';
div2f.appendChild(speci);
button= document.createElement('button');
button.innerHTML='过滤结果';
button.onclick=filter;
div2f.appendChild(button);
div2.appendChild(div2f);
div2.appendChild(div2p);
div2.style.margin='10px';
var tarList=document.createElement('ol');
for(var i=0,li,doList;i