NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Simple Storage Timer // @namespace http://tampermonkey.net/ // @version 1.0.3 // @description Displays how long for storage to fill // @author God of Death // @match https://*.ogame.gameforge.com/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; //============ METAL ============ var m = document.getElementById('metal_box'); var metal = m.getAttribute('title'); metal = metal.toString(); var metal_simple = metal.replace(/[.]/g,''); var metal_numbers = metal_simple.match(/\d+/g).map(Number); //convert numbers to time remaining var metal_time = 0; // check for division by 0 if (metal_numbers[2] > 0) { metal_time = Math.round((metal_numbers[1]-metal_numbers[0])/metal_numbers[2]); } var metald = Math.floor(metal_time/24); var mRemainder1 = metal_time % 24; var metalh = Math.floor(mRemainder1); var metalm = Math.round((mRemainder1-metalh)*60); var mtotaltime = 0; // check for division by 0 if (metal_numbers[2] > 0) { mtotaltime = metal_numbers[1]/metal_numbers[2]; } var mtotald = Math.floor(mtotaltime/24); var mRemainder2 = mtotaltime % 24; var mtotalh = Math.floor(mRemainder2); var mtotalm = Math.round((mRemainder2-mtotalh)*60); //add time remaining underneath the resources var metalnode = document.getElementById('resources_metal').parentNode; var metalspan = document.createElement('SPAN'); var metaltxt; if(metal_numbers[0]>=metal_numbers[1]){ metaltxt = document.createTextNode('Full');} else if(metal_time>=24 && mtotaltime>=24){ metaltxt = document.createTextNode(metald+'d '+metalh+'h ('+mtotald+'d '+mtotalh+'h)');} else if(metal_time<24 && mtotaltime>=24){ metaltxt = document.createTextNode(metalh+'h '+metalm+'m ('+mtotald+'d '+mtotalh+'h)');} else{ metaltxt = document.createTextNode(metalh+'h '+metalm+'m ('+mtotalh+'h '+mtotalm+'m)');} metalspan.appendChild(metaltxt); metalspan.setAttribute("style","position: absolute; bottom: -11px; left: -35%; width: 170%;color:#AB7AFF;"); metalnode.appendChild(metalspan); //============ CRYSTAL ============ var c = document.getElementById('crystal_box'); var crystal = c.getAttribute('title'); crystal = crystal.toString(); var crystal_simple = crystal.replace(/[.]/g,''); var crystal_numbers = crystal_simple.match(/\d+/g).map(Number); //convert numbers to time remaining var crystal_time = 0; // check for division by 0 if (crystal_numbers[2] > 0) { crystal_time = Math.round((crystal_numbers[1]-crystal_numbers[0])/crystal_numbers[2]); } var crystald = Math.floor(crystal_time/24); var cRemainder1 = crystal_time % 24; var crystalh = Math.floor(cRemainder1); var crystalm = Math.round((cRemainder1-crystalh)*60); var ctotaltime = 0; // check for division by 0 if (crystal_numbers[2] > 0) { ctotaltime = crystal_numbers[1]/crystal_numbers[2]; } var ctotald = Math.floor(ctotaltime/24); var cRemainder2 = ctotaltime % 24; var ctotalh = Math.floor(cRemainder2); var ctotalm = Math.round((cRemainder2-ctotalh)*60); var crystalnode = document.getElementById('resources_crystal').parentNode; var crystalspan = document.createElement('SPAN'); var crystaltxt; if(crystal_numbers[0]>=crystal_numbers[1]){ crystaltxt = document.createTextNode('Full');} else if(crystal_time>=24 && ctotaltime>=24){ crystaltxt = document.createTextNode(crystald+'d '+crystalh+'h ('+ctotald+'d '+ctotalh+'h)');} else if(crystal_time<24 && ctotaltime>=24){ crystaltxt = document.createTextNode(crystalh+'h '+crystalm+'m ('+ctotald+'d '+ctotalh+'h)');} else{ crystaltxt = document.createTextNode(crystalh+'h '+crystalm+'m ('+ctotalh+'h '+ctotalm+'m)');} crystalspan.appendChild(crystaltxt); crystalspan.setAttribute("style","position: absolute; bottom: -11px; left: -35%; width: 170%;color:#AB7AFF;"); crystalnode.appendChild(crystalspan); //============ DEUTERIUM ============ var d = document.getElementById('deuterium_box'); var deuterium = d.getAttribute('title'); deuterium = deuterium.toString(); var deut_simple = deuterium.replace(/[.]/g,''); var deut_numbers = deut_simple.match(/\d+/g).map(Number); //convert numbers to time remaining var deut_time = 0; // check for division by 0 if (deut_numbers[2] > 0) { deut_time = Math.round((deut_numbers[1]-deut_numbers[0])/deut_numbers[2]); } var deutd = Math.floor(deut_time/24); var dRemainder1 = deut_time % 24; var deuth = Math.floor(dRemainder1); var deutm = Math.round((dRemainder1-deuth)*60); var dtotaltime = 0; // check for division by 0 if (deut_numbers[2] > 0) { dtotaltime = deut_numbers[1]/deut_numbers[2]; } var dtotald = Math.floor(dtotaltime/24); var dRemainder2 = dtotaltime % 24; var dtotalh = Math.floor(dRemainder2); var dtotalm = Math.round((dRemainder2-dtotalh)*60); //add time remaining underneath the resources var deutnode = document.getElementById('resources_deuterium').parentNode; var deutspan = document.createElement('SPAN'); var deuttxt; if(deut_numbers[0]>=deut_numbers[1]){ deuttxt = document.createTextNode('Full');} else if(deut_time>=24 && dtotaltime>=24){ deuttxt = document.createTextNode(deutd+'d '+deuth+'h ('+dtotald+'d '+dtotalh+'h)');} else if(deut_time<24 && dtotaltime>=24){ deuttxt = document.createTextNode(deuth+'h '+deutm+'m ('+dtotald+'d '+dtotalh+'h)');} else{ deuttxt = document.createTextNode(deuth+'h '+deutm+'m ('+dtotalh+'h '+dtotalm+'m)');} deutspan.appendChild(deuttxt); deutspan.setAttribute("style","position: absolute; bottom: -11px; left: -35%; width: 170%;color:#AB7AFF;"); deutnode.appendChild(deutspan); })();