NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Reactoridle math
// @namespace zzzz
// @include http://reactoridle.com/
// @version 1.0
// @grant none
// ==/UserScript==
var debug_text;
var list = [];
setTimeout(main,1000);
function create_div(){
text =
"<span>{<input type='checkbox' id='click_check_box' /> auto sell }</span>" +
"<span style='font-family: \"Courier New\", Courier, monospace; font-size: 13px;' name='debug_text' id='debug_text'>"+
"0"+
"</span>";
topBar = document.getElementsByClassName("overviewBox")[0];
if(!topBar) return;
var opts = document.createElement("span");
opts.innerHTML = text;
topBar.insertBefore(opts, topBar.lastChild);
}
function create_table(){
rightCommercial = document.getElementById("rightCommercial");
if(!rightCommercial ) return;
col1 = '#2f4f4f';
col2 = '#008b8b';
text ="<table id='heat_table' style='display: -moz-inline-box;'>"+
"<tr bgcolor='#ff8c00'><td>name</td><td>heat</td><td>x1.25</td><td>x1.5</td><td></td><td> </td></tr>";
for(q=0;q<10;q++) {
text += "<tr bgcolor='" +(q/2==Math.round(q/2)?col1:col2)+ "'><td id='n"+q+"name'> </td><td id='"+q+"heat'> </td><td id='"+q+"x25'> </td><td id='"+q+"x50'> </td><td id='"+q+"xN'> </td><td id='"+q+"xN'><input id='"+q+"inscrement_input' type='number' style='width: 50px;'></td></tr>";
}
text += "</table> <br />" +
"<input type='checkbox' id='clear_check_box' /> clear all";
opts = document.createElement("span");
opts.innerHTML = text;
rightCommercial.insertBefore(opts, rightCommercial.lastChild);
}
function click_sell(){
document.getElementById("sellPowerButton").click( );
}
function main(){
setTimeout(main,10);
debug_text = document.getElementById("debug_text");
if(!debug_text){ create_div(); return; }
t = document.getElementById("heat_table");
if(!t) {create_table(); return;}
click_check_box = document.getElementById("click_check_box");
clear_check_box = document.getElementById("clear_check_box");
if(clear_check_box){
if(clear_check_box.checked){
list.length = 0;
clear_check_box.checked = false;
rightCommercial = document.getElementById("rightCommercial");
if(rightCommercial) rightCommercial.innerHTML = "";
return;
}
}
if(click_check_box) {
if (click_check_box.checked) {
click_sell();
}
}
readTextInfo2();
calculate();
debug_text.innerHTML = list.length;
}
function calculate(){
for(q=0;q<list.length;q++){
input = document.getElementById(q+"inscrement_input");
n = input.value;
heat = document.getElementById(q+"heat");
h = heat.innerHTML;
xn = document.getElementById(q+"xN");
xn.innerHTML = h*n;
}
}
function readTextInfo2() {
infoText = document.getElementsByClassName('infoText')[0];
if(!infoText) return;
b = infoText.getElementsByTagName('b')[0];
if(!b) return;
id_name = getIdName(b.innerHTML);
for(q=0;q<list.length;q++) {
if(list[q]==id_name){
updateTag2(q, infoText);
return;
}
}
addNewTag2(infoText);
}
function updateTag2(q, infoText){
name_info = infoText.getElementsByTagName("b")[0];
if(!name_info) return;
heat_info = infoText.getElementsByClassName("heat")[0];
if(!heat_info) return;
h = heat_info.innerHTML;
if(h.indexOf("/")>-1) return;
namer = document.getElementById("n"+q+"name");
heat = document.getElementById(q+"heat");
x25 = document.getElementById(q+"x25");
x50 = document.getElementById(q+"x50");
namer.innerHTML = name_info.innerHTML;
h = h.replace(" ", "");
if(h.indexOf("million")>=0){
h = h.replace("million", "");
h=h*1000000;
}
heat.innerHTML = h;
x25.innerHTML = Math.round(h*1.25*100)/100;
x50.innerHTML = Math.round(h*1.50*100)/100;
}
function addNewTag2(infoText){
name_info = infoText.getElementsByTagName("b")[0];
if(!name_info) return;
heat_info = infoText.getElementsByClassName("heat")[0];
if(!heat_info) return;
h = heat_info.innerHTML;
if(h.indexOf("/")>-1) return;
id_name = getIdName(name_info.innerHTML);
list.push(id_name);
}
function getIdName(name){
return name.replace(" ", "X") + "X";
}