gazellegames ggn: show gold per terabytehour

calculates gold per terabytehour on ggn| Greasemonkey 4.1: ✔ Tampermonkey 4.4: ✔

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        gazellegames ggn: show gold per terabytehour
// @namespace   gazellegames
// @description calculates gold per terabytehour on ggn| Greasemonkey 4.1: ✔ Tampermonkey 4.4: ✔ 
// @include     https://gazellegames.net/torrents.php?id=*
// @version     1.2
// @grant       none
// ==/UserScript==


var games = document.getElementsByClassName('group_torrent');


for(i = 0; i < games.length; i++){

try{
   var childTd = games[i].getElementsByTagName('td')[2];
   var gameSize = childTd.innerHTML;
   var goldGeneration = games[i].nextElementSibling.firstElementChild.firstElementChild.getElementsByTagName('span')[1];
   
   //alert(goldGeneration.innerHTML);
   gameSize = toTeraByte(gameSize);
   goldGeneration.innerHTML = Math.round( goldGeneration.innerHTML/gameSize) + ' Gold/TBh  OR  ' + goldGeneration.innerHTML
}
catch(err){console.log(err.message);}

}

function toTeraByte(str){
    var re = /(.*?)\s(.*)/;
    var size = str.match(re) [2];
    var number =  str.match(re) [1];

    switch(size) {
    case 'KB':
        number = number / 1073741824 ;
        break;
    case 'MB':
        number = number / 1048576 ;
        break;
    case 'GB':        
        number = number / 1024 ;
        break;          
    default:
        number = number;
   } 
    
  return number;
}