// ==UserScript== // @name quackulator.js // @namespace http://example.org // @description tells you your new ratio if you download a torrent without seeding // @include http://www.norbits.net/details.php?id=* // @include http://norbits.net/details.php?id=* // @include https://www.norbits.net/details.php?id=* // @include https://norbits.net/details.php?id=* // ==/UserScript== (function(){ if(location.hostname.indexOf('norbits.net') == -1 || location.pathname.indexOf('/details.php') == -1) { return false; } function getNodes(expression, startElement) { startElement = startElement || document; var nodes = document.evaluate( expression, startElement, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null ); return nodes; } function trim(str) { return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); } function getGigaBytes(text){ var gigabytes, numbers, suffix; text = trim(text); if(text == 'Inf.' || text == '---') { return 0; } var _tmp = text.split(' '); numbers = Number(_tmp[0]); suffix = _tmp[1]; //alert('suffix er: "' + suffix + "'") switch(suffix){ case 'GB': gigabytes = numbers; break; case 'TB': gigabytes = numbers*1024; break; case 'MB': gigabytes = numbers*0.0009765625; break; case 'kB': //no point in doing calculations with that low numbers gigabytes = 0; break; default: gigabytes = 0; break; } return gigabytes; } function _t(e) { try { var tableRow = getNodes('//tr//td[@class="rowhead" and' + ' contains(text(), "St") and contains(text(), "rrelse")]/..').snapshotItem(0); if(!tableRow) { return; } //