Roll

匿名版ROLL点工具

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name	Roll
// @author	丧失A
// @version	0.0.4
// @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 * 9301 + 49297 ) % 233280;
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\(\d+D\d+\)+/g);
            if(rollQuest!=null){
                for(var j=0;j<rollQuest.length;j++){
                    var rolltime = parseInt(rollQuest[j].substring(5,rollQuest[j].indexOf('D')));
                    var rollmax = parseInt(rollQuest[j].substring(rollQuest[j].indexOf('D')+1));
                    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]+"<font color='#FF3333'>="+rollresult+"</font>");
                }
            }
    
       }
}
roll($(".h-threads-content"));