Skip to content

Commit

Permalink
Improve prevent-xhr scriptlet
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Nov 8, 2024
1 parent 41616df commit ce4908b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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' },
});
Expand All @@ -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;
Expand Down

0 comments on commit ce4908b

Please sign in to comment.