var tagger = { cache: {}, exprs: [ {re: /^(gmail|meta|browser|tmobile-g1|adc|google|apk|contacts|cyanogenmod|cyanogen|email-app|dialer-app|music|donut|android-market|music-app|email|htc|cliq|home-screen|apps|dialer)$/, replace: function(img) { return "http://www.siriusapplications.com/forceclose/images/tags/"+img+".png"; } } ], paint: function() { $(".post-tag").each(function() { var $tag = $(this), totest = $tag.text().replace(/^\s+|\s+$/g,''); $tag.find("img").remove(); if (!tagger.cache.hasOwnProperty(totest)) { tagger.cache[totest] = []; $.each(tagger.exprs,function(i, tester) { if (totest.match(tester.re)) { tagger.cache[totest].push(" "); } }); } $.each(tagger.cache[totest],function(i,img) { $tag.prepend(img); }); }); }, register: function() { $(tagger.paint); } }; tagger.register();