spenibus.net
2014-04-22 01:02:19 GMT

Firefox/Greasemonkey - Metrication of a subreddit.

Because americans have yet to ditch their antiquated measurement units, it's up to us to metricate the shit out of them. And today, the fascinating [/r/progresspics/](http://www.reddit.com/r/progresspics/) gets a metric punch in the face. This will not convert everything but it's certainly more readable. Be warned, this is not subtle code but it works. Original ```txt M/38/6'0" [245lbs > 195lbs = 50lbs] ``` Converted ```txt M/38/183cm* [111.1kg* > 88.5kg* = 22.7kg*] ``` The code -- (updated 2014-04-22 19:35 GMT) ```` var loc = document.location; /************************************* reddit.com/r/progresspics/ metrication */ if(loc.hostname.substr(-10) == 'reddit.com' && loc.pathname.substr(0,15) == '/r/progresspics') { window.addEventListener('load', function(){ var metricPound = 0.45359237; // kilogram var metricFoot = 0.3048; // metre var metricInch = 0.0254; // metre // weight document.body.innerHTML = document.body.innerHTML.replace( /(\d+)\s*?lbs?/gi, function replacer(m, m1, offset, str){ return (m1 * metricPound).toFixed(1) + 'kg*'; } ); // height document.body.innerHTML = document.body.innerHTML.replace( /(\d+)'(\d+)"?/gi, function replacer(m, m1, m2, offset, str){ return Math.round((m1*metricFoot + m2*metricInch) * 100)+'cm*'; } ); }, false); } ````