var tagger = { cache: {}, exprs: [ {re: /^(android-market|cyanogen|cyanogenmod|htc|home-screen|tmobile-g1|music-app|music|cliq|gmail|browser|contacts|donut|google|email-app|email|dialer|dialer-app|apk|apps|meta|adc)$/, 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();