Greasy Fork is available in English.
Orcish script for tiers
当前为
// ==UserScript==
// @name Orcish inline tiers
// @namespace Goldstar
// @description Orcish script for tiers
// @author Goldstar labs
// @include https://stereolife.website/pub/*
// @include https://armorgames.com/dawn-of-the-dragons-game/13509
// @version 0.0.1
// @grant GM_xmlhttpRequest
// @grant GM_log
// @connect <value>
// ==/UserScript==
( function ( data ) {
"use strict";
// Switches block between active and inactive
var node_click = function ()
{
// Get current node status
var status = this.getAttribute("class") === "active" ? "" : "active";
// Reset all nodes status
for (var counter = 0; counter < this.parentNode.childNodes.length; counter++)
{
this.parentNode.childNodes[counter].setAttribute ( "class", "" );
}
// Set active status to current node
this.setAttribute ( "class", status );
this.parentNode.setAttribute("active",status);
};
/**
* creates a new element for the list
* @param {string} label the name of the dataset
* @param {string} src the image id
* @param {Function} func the function to be called when clicked
* @returns {unresolved}
*/
var node_create = function(label, src, func)
{
var wrapper = document.createElement ( "li" );
wrapper.onclick = func;
wrapper.appendChild ( document.createElement('div') );
if ( src )
{
GM_xmlhttpRequest({
method: 'GET',
url: src,
headers: { 'Content-Type': 'application/json; charset=UTF-8' },
onload: function(r)
{
var table_content = document.createElement ('table');
table_content.style.padding = "0 0 0 0";
table_content.style.backgroundColor = '#F5F5F5';
table_content.style.borderSpacing = "0";
table_content.style.width = '100%';
table_content.style.border = 'thin solid #9C9C9C';
table_content.setAttribute('border', 1);
// table_content.style.borderBottom = "thick solid #0000FF";
table_content.style.borderCollapse = "collapse";
var table_body = document.createElement('tbody');
var parsed_response = JSON.parse(r.responseText);
/* parsing raids */
var i = 0;
for (var raid of parsed_response.raids)
{
console.log(raid.name);
var row_damage = document.createElement('tr');
var row_loot = document.createElement('tr');
var row_coeff = document.createElement('tr');
row_damage.style.textAlign = "center";
row_loot.style.textAlign = "center";
row_coeff.style.textAlign = "center";
if (i%2 == 1)
{
row_damage.style.backgroundColor = "#D8D8D8";
row_loot.style.backgroundColor = "#D8D8D8";
row_coeff.style.backgroundColor = "#D8D8D8";
}
i++;
var raid_name = document.createElement('td');
raid_name.setAttribute('rowspan', '3');
raid_name.appendChild(document.createTextNode(raid.name));
row_damage.appendChild(raid_name);
table_body.appendChild(row_damage);
table_body.appendChild(row_loot);
table_body.appendChild(row_coeff);
/* AP OS MS */
var ap = document.createElement('td');
ap.appendChild(document.createTextNode(raid.ap));
row_damage.appendChild(ap);
var os = document.createElement('td');
os.appendChild(document.createTextNode(raid.os));
row_loot.appendChild(os);
var ms = document.createElement('td');
ms.appendChild(document.createTextNode(raid.ms));
row_coeff.appendChild(ms);
for (var tier of raid.tiers)
{
var damage = document.createElement('td');
damage.appendChild(document.createTextNode(tier.damage));
var loot = document.createElement('td');
var loot_str = '';
if (tier.c.length > 0 || tier.u.length > 0 || tier.r.length > 0 || tier.e.length > 0)
{
loot_str += tier.c == undefined ? '' : tier.c;
loot_str += '/';
loot_str += tier.u == undefined ? '' : tier.u;
loot_str += '/';
loot_str += tier.r == undefined ? '' : tier.r;
loot_str += '/';
loot_str += tier.e == undefined ? '' : tier.e;
}
if (tier.stats.length > 0)
{
if (loot_str.length > 0)
{
loot_str += ' ';
}
loot_str += tier.stats;
}
loot.appendChild(document.createTextNode(loot_str));
var coeff = document.createElement('td');
coeff.appendChild(document.createTextNode(tier.dmgsp));
if (raid.os == tier.damage)
{
if (i%2 == 1)
{
damage.style.backgroundColor = "#D1FFBD";
loot.style.backgroundColor = "#D1FFBD";
coeff.style.backgroundColor = "#D1FFBD";
}
else
{
damage.style.backgroundColor = "#BEEBAA";
loot.style.backgroundColor = "#BEEBAA";
coeff.style.backgroundColor = "#BEEBAA";
}
}
row_damage.appendChild(damage);
row_loot.appendChild(loot);
row_coeff.appendChild(coeff);
}
}
table_content.appendChild(table_body);
wrapper.firstChild.appendChild ( table_content );
}});
}
if(label)
{
wrapper.appendChild ( document.createElement ( "button" ) );
wrapper.lastChild.appendChild ( document.createTextNode ( label ) );
}
return wrapper;
};
var list = document.createElement ( "ul" );
list.setAttribute ( "id", "NewInlineTierCharts" );
list.appendChild ( node_create ( "\u21C6", "", function () {
this.parentNode.setAttribute("class",( this.parentNode.getAttribute ( "class" ) === "right" ? "" : "right" ));
} ) );
/* Parsing input data and build menu */
for (var node of data)
{
list.appendChild(node_create(node[0], node[1], node_click));
}
var styles = document.createElement ( "style" );
styles.setAttribute ( "type", "text/css" );
styles.setAttribute ( "id", "NewInlineTierChartsStyles" );
styles.appendChild ( document.createTextNode (
"#NewInlineTierCharts{position:fixed;top:0;left:-65px;z-index:100000;max-height:100%;}" +
"#NewInlineTierCharts:hover,#NewInlineTierCharts[active=\"active\"]{left:0;}" +
"#NewInlineTierCharts.right{left:auto;right:-65px;}" +
"#NewInlineTierCharts.right:hover,#NewInlineTierCharts.right[active=\"active\"]{right:0;}" +
"#NewInlineTierCharts,#NewInlineTierCharts li{margin:0;padding:0;list-style: none;display:block;}" +
"#NewInlineTierCharts li{min-height:0.25em;}" +
"#NewInlineTierCharts img{width:auto;height:auto;display:block;background-color:#fff;}" +
"#NewInlineTierCharts div{width:auto;max-height:100%;display:none;overflow:auto;}" +
"#NewInlineTierCharts button{border-radius:2px;background:#fff;height:auto;font-size: 12px;font-family: monospace;padding:1px;text-align: center;box-sizing: border-box;text-align:center;color:#000;border: 1px solid #000;width:75px;display:block;background-color:#fff;background-image:linear-gradient(to bottom,rgba(255,255,255,0.1),rgba(255,255,255,0.2),rgba(0,0,0,0.1));font-weight:normal;line-height:normal;}" +
"#NewInlineTierCharts .active div{display:block;position:fixed;top:0;left:75px;z-index:100000;max-height:100%;max-width:"+(window.innerWidth-150)+"px;}" +
"#NewInlineTierCharts.right .active div{left:auto;right:75px;}" +
"#NewInlineTierCharts .active button{background:#222;color:#fff;}"
) );
window.addEventListener('resize',function() {
document.getElementById("NewInlineTierChartsStyles").innerHTML = document.getElementById("NewInlineTierChartsStyles").innerHTML.replace(/(#NewInlineTierCharts .active div\{.*?max-width:)[0-9]+(px;.*?\})/,'$1'+(window.innerWidth-150)+'$2');
});
document.getElementsByTagName ( "head" )[0].appendChild ( styles );
document.getElementsByTagName ( "body" )[0].appendChild ( list );
} ) (
[
[ "", ""] ,
[ "Elite", "http://18.218.243.237:3000/rpc/tiers_v1?_name=&_type=Elite" ],
[ "Deadly", "http://18.218.243.237:3000/rpc/tiers_v1?_name=&_type=Deadly" ]
]
);