String.SCRIPT_FRAGMENT = '<script[^>]*>([\\S\\s]*?)<\/script>';

String.prototype.extractScripts = function() {
    var matchAll = new RegExp(String.SCRIPT_FRAGMENT, 'img');
    var matchOne = new RegExp(String.SCRIPT_FRAGMENT, 'im');
    return (this.match(matchAll) || []).map(function(scriptTag) {
        return (scriptTag.match(matchOne) || ['', ''])[1];
    });
};

String.prototype.evalScripts = function() {
    return this.extractScripts().map(function(script) {
        return eval(script);
    });
};

if (!String.prototype.trim) {
    String.prototype.trim = function() {
        return this.replace(/^\s+|\s+$/g, "");
    };
}


