Update http.js

This commit is contained in:
Namhyeon Go 2022-04-25 17:49:10 +09:00 committed by GitHub
parent 503641bdb0
commit 915d72ebbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -642,6 +642,32 @@ var HTTPObject = function(engine) {
this.saveTo = filename;
};
this.parseScripts = function() {
var scripts = [];
if (typeof this.responseBody !== "string")
return scripts;
var tagName = "script";
var a = this.responseBody.indexOf('<' + tagName + ' ');
var b = a < 0 ? -1 : this.responseBody.indexOf('</' + tagName + '>', a);
while (a > -1 && b > -1) {
var outerHTML = this.responseBody.substring(a, b + tagName.length + 3);
var innerHTML = this.responseBody.substring(this.responseBody.indexOf('>', a), b);
scripts.push({
'outerHTML': outerHTML,
'innerHTML': innerHTML
});
a = this.responseBody.indexOf('<' + tagName + ' ', b + tagName.length + 3);
b = a < 0 ? -1 : this.responseBody.indexOf('</' + tagName + '>', a);
}
return scripts;
};
this.create();
};