mirror of https://github.com/gorhill/uBlock.git
Minor code review of scriptlets
This commit is contained in:
parent
3f3f383473
commit
cce3f3efc1
|
@ -1365,9 +1365,12 @@ function jsonPruneXhrResponse(
|
||||||
if ( xhrDetails === undefined ) {
|
if ( xhrDetails === undefined ) {
|
||||||
return innerResponse;
|
return innerResponse;
|
||||||
}
|
}
|
||||||
if ( xhrDetails.latestResponseLength != innerResponse.length ) {
|
const responseLength = typeof innerResponse === 'string'
|
||||||
|
? innerResponse.length
|
||||||
|
: undefined;
|
||||||
|
if ( xhrDetails.lastResponseLength !== responseLength ) {
|
||||||
xhrDetails.response = undefined;
|
xhrDetails.response = undefined;
|
||||||
xhrDetails.latestResponseLength = innerResponse.length;
|
xhrDetails.lastResponseLength = responseLength;
|
||||||
}
|
}
|
||||||
if ( xhrDetails.response !== undefined ) {
|
if ( xhrDetails.response !== undefined ) {
|
||||||
return xhrDetails.response;
|
return xhrDetails.response;
|
||||||
|
@ -3694,12 +3697,18 @@ function trustedReplaceXhrResponse(
|
||||||
if ( xhrDetails === undefined ) {
|
if ( xhrDetails === undefined ) {
|
||||||
return innerResponse;
|
return innerResponse;
|
||||||
}
|
}
|
||||||
if ( typeof innerResponse !== 'string' ) {
|
const responseLength = typeof innerResponse === 'string'
|
||||||
xhrDetails.response = innerResponse;
|
? innerResponse.length
|
||||||
|
: undefined;
|
||||||
|
if ( xhrDetails.lastResponseLength !== responseLength ) {
|
||||||
|
xhrDetails.response = undefined;
|
||||||
|
xhrDetails.lastResponseLength = responseLength;
|
||||||
}
|
}
|
||||||
let outerResponse = xhrDetails.response;
|
if ( xhrDetails.response !== undefined ) {
|
||||||
if ( outerResponse !== undefined ) {
|
return xhrDetails.response;
|
||||||
return outerResponse;
|
}
|
||||||
|
if ( typeof innerResponse !== 'string' ) {
|
||||||
|
return (xhrDetails.response = innerResponse);
|
||||||
}
|
}
|
||||||
const textBefore = innerResponse;
|
const textBefore = innerResponse;
|
||||||
const textAfter = textBefore.replace(rePattern, replacement);
|
const textAfter = textBefore.replace(rePattern, replacement);
|
||||||
|
@ -3711,8 +3720,7 @@ function trustedReplaceXhrResponse(
|
||||||
`\n\treplacement: ${replacement}`,
|
`\n\treplacement: ${replacement}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
xhrDetails.response = textAfter;
|
return (xhrDetails.response = textAfter);
|
||||||
return textAfter;
|
|
||||||
}
|
}
|
||||||
get responseText() {
|
get responseText() {
|
||||||
const response = this.response;
|
const response = this.response;
|
||||||
|
|
Loading…
Reference in New Issue