// ==UserScript== // @name TW Market++ // @namespace http://home.deds.nl/~lekensteyn/p/ // @description TW Market enhancer // @include http://nl*.tribalwars.nl/game.php?*screen=market* // @exclude http://nl*.tribalwars.nl/game.php?*mode=other_offer* // @exclude http://nl*.tribalwars.nl/game.php?*mode=traders* // ==/UserScript== /** * Tribal Wars BB code enhancer (c) 2009 Lekensteyn * Support: www.tribetool.nl * Created: 14032009-1 * Version: 14032009-1 * Please retain this original copyright. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. */ location.href = 'javascript:('+encodeURIComponent(uneval(function(){ function fmtNumber(n, m){ var r = n.replace(/[^km\d,.]+/i, ''); r = r.replace(/[,.]+/g, '.'); if(r.match(/\./g) && r.match(/\./g).length > 1) r.replace(/\./g, ''); var t = 1; if(r.match(/k/i)) t = 1000; if(r.match(/m/i)) t = 1000000; r = r.replace(/[km]+/i, ''); if(isNaN(r*1) || r*1 == 0) r = r+'1'; r = r*t; if(r > m) return m; return r >= 1 ? r : ''; } if(document.forms.length){ var f = document.forms[0]; var m = parseFloat(f.parentNode.getElementsByTagName('table')[0].rows[0].cells[1].textContent.replace(/[^\d]+/g, '')); var fn = function(){this.value=fmtNumber(this.value, m);}; if(location.href.match(/mode=own_offer/)){ f.sell.onchange = fn; f.buy.onchange = fn; } else if(document.forms.units){ f.wood.onchange = fn; f.stone.onchange = fn; f.iron.onchange = fn; } } }))+')();void 0;';