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-length': '',
|
||||
},
|
||||
url: haystack.url,
|
||||
props: {
|
||||
response: { value: '' },
|
||||
responseText: { value: '' },
|
||||
responseXML: { value: null },
|
||||
responseURL: { value: haystack.url },
|
||||
},
|
||||
});
|
||||
xhrInstances.set(this, xhrDetails);
|
||||
|
@ -1405,6 +1405,7 @@ function preventXhrFn(
|
|||
xhrDetails.headers['content-length'] = `${xhrDetails.props.response.value}`.length;
|
||||
Object.defineProperties(xhrDetails.xhr, {
|
||||
readyState: { value: 4 },
|
||||
responseURL: { value: xhrDetails.url },
|
||||
status: { value: 200 },
|
||||
statusText: { value: 'OK' },
|
||||
});
|
||||
|
@ -1414,6 +1415,7 @@ function preventXhrFn(
|
|||
Promise.resolve(xhrText).then(( ) => xhrDetails).then(details => {
|
||||
Object.defineProperties(details.xhr, {
|
||||
readyState: { value: 1, configurable: true },
|
||||
responseURL: { value: xhrDetails.url },
|
||||
});
|
||||
safeDispatchEvent(details.xhr, 'readystatechange');
|
||||
return details;
|
||||
|
|
Loading…
Reference in New Issue