mirror of https://github.com/gorhill/uBlock.git
Improve `prevent-xhr` scriptlet
This commit is contained in:
parent
41616df866
commit
ce4908b341
|
@ -1345,11 +1345,11 @@ function preventXhrFn(
|
||||||
'content-type': '',
|
'content-type': '',
|
||||||
'content-length': '',
|
'content-length': '',
|
||||||
},
|
},
|
||||||
|
url: haystack.url,
|
||||||
props: {
|
props: {
|
||||||
response: { value: '' },
|
response: { value: '' },
|
||||||
responseText: { value: '' },
|
responseText: { value: '' },
|
||||||
responseXML: { value: null },
|
responseXML: { value: null },
|
||||||
responseURL: { value: haystack.url },
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
xhrInstances.set(this, xhrDetails);
|
xhrInstances.set(this, xhrDetails);
|
||||||
|
@ -1405,6 +1405,7 @@ function preventXhrFn(
|
||||||
xhrDetails.headers['content-length'] = `${xhrDetails.props.response.value}`.length;
|
xhrDetails.headers['content-length'] = `${xhrDetails.props.response.value}`.length;
|
||||||
Object.defineProperties(xhrDetails.xhr, {
|
Object.defineProperties(xhrDetails.xhr, {
|
||||||
readyState: { value: 4 },
|
readyState: { value: 4 },
|
||||||
|
responseURL: { value: xhrDetails.url },
|
||||||
status: { value: 200 },
|
status: { value: 200 },
|
||||||
statusText: { value: 'OK' },
|
statusText: { value: 'OK' },
|
||||||
});
|
});
|
||||||
|
@ -1414,6 +1415,7 @@ function preventXhrFn(
|
||||||
Promise.resolve(xhrText).then(( ) => xhrDetails).then(details => {
|
Promise.resolve(xhrText).then(( ) => xhrDetails).then(details => {
|
||||||
Object.defineProperties(details.xhr, {
|
Object.defineProperties(details.xhr, {
|
||||||
readyState: { value: 1, configurable: true },
|
readyState: { value: 1, configurable: true },
|
||||||
|
responseURL: { value: xhrDetails.url },
|
||||||
});
|
});
|
||||||
safeDispatchEvent(details.xhr, 'readystatechange');
|
safeDispatchEvent(details.xhr, 'readystatechange');
|
||||||
return details;
|
return details;
|
||||||
|
|
Loading…
Reference in New Issue