Greasy Fork

Roll

匿名版ROLL点工具

目前为 2015-01-31 提交的版本。查看 最新版本

// ==UserScript==
// @name	Roll
// @author	丧失A
// @version	0.0.1
// @description	匿名版ROLL点工具
// @match	*.nimingban.com/*
// @include	*.nimingban.com/*
// @require http://code.jquery.com/jquery-1.11.2.min.js
// @grant none
// @namespace https://greasyfork.org/users/8781
// ==/UserScript==

function rnd(seed){
seed = ( seed * 16807 + 0 ) % 2147483647;
return seed;
}
function roll(commentList){
    for(var i=0;i<commentList.length;i++){
        var ID=parseInt(commentList.parent().find(".h-threads-info").find(".h-threads-info-id")[i].innerHTML.substring(3));
        var Time=parseInt(commentList.parent().find(".h-threads-info").find(".h-threads-info-createdat")[i].innerHTML.slice(-2));
        var rollQuest=commentList[i].innerHTML.match(/roll\([0-9]D[0-9]{1,2}\)+/g);
            if(rollQuest!=null){
                for(var j=0;j<rollQuest.length;j++){
                    var rolltime = parseInt(rollQuest[j].substring(5,6));
                    var rollmax = parseInt(rollQuest[j].substring(7));
                    var rollresult = 0;
                        for(var p=0;p<rolltime;p++) rollresult+= (rnd(ID+Time*(p+1))%rollmax + 1);
                    commentList[i].innerHTML=commentList[i].innerHTML.replace(rollQuest[j],rollQuest[j]+"="+rollresult);
                }
            }
    
       }
}
roll($(".h-threads-content"));