(function () { Object.defineProperties(util, { "getBody" : { value : function(f) { if (f && f instanceof Function) { var m = f.toString().match(/\{([\s\S]*)\}/m)[1]; m = m.replace(/^\s*\/\/.*$/mg, ''); m = m.replace(/^[ \t\r\v\f]*/, ''); if (m[0] == "\n") return m.substring(1); else return m; } return null; } }, "getSelection" : { value : function() { var frames = tabs.current.allFrames; for (var i=frames.length-1; i>=0; --i) { var selection = JSON.parse(frames[i].inject("return document.getSelection().toString()")); if (selection.length > 0) return selection; } return null; } }, "uncamelize" : { value : function(text) { if (! text || text.length === 0) return text; var c = text.charAt(0); var uncamelized = c == c.toUpperCase() ? c.toLowerCase() : c; for (var i=1, l=text.length; i=0; --i) { if (this[i] == v) return i; } return -1; } }); } if (! RegExp.escape) { Object.defineProperty(RegExp, "escape", { value : function(string) { return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); } }); } })();