NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name stop formatting resources
// @version 0.1
// @description stop formatting resources
// @author Kbaniszack
// @match https://*.ogame.gameforge.com/game/*
// @grant none
// @require http://code.jquery.com/jquery-3.4.1.min.js
// @updateURL https://openuserjs.org/meta/kbaniszack/stop_formatting_resources.meta.js
// @license MIT
// ==/UserScript==
/* global $ gfNumberGetHumanReadable MutationObserver */
const jq = $.noConflict(true); // eslint-disable-line no-undef
const old = gfNumberGetHumanReadable;
gfNumberGetHumanReadable = function (value, shortForm, precision) {
return old.apply(old, [value, false, precision]);
};
const formatCostNumber = function (value) {
value = parseInt(value);
let unit = 0;
while (value > 1000) {
value = value / 1000;
unit++;
}
value = value.toFixed(2);
switch (unit) {
case 1:
value += 'K';
break;
case 2:
value += 'M';
break;
case 3:
value += 'Md';
break;
default:
break;
}
return value;
};
if (jq('#technologydetails_content').length > 0) {
new MutationObserver(function (mutationsList) {
for (let mutation of mutationsList) {
if (mutation.type === 'childList') {
for (let node of mutation.addedNodes) {
const $node = jq(node);
if (jq(node).is('div#technologydetails')) {
$node.find('div.content div.information div.costs ul li').each(function (i, el) {
const $el = jq(el);
$el.text(formatCostNumber($el.data('value')));
});
}
}
}
}
}).observe(jq('#technologydetails_content')[0], {
childList: true
});
}