MCPcopy
hub / github.com/Tampermonkey/tampermonkey / createState

Function createState

src/xmlhttprequest.js:25–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23 }
24 var xmlhttp = new XMLHttpRequest();
25 var createState = function() {
26 var rh = '';
27 var fu = details.url;
28 if (xmlhttp.readyState > 2) {
29 rh = xmlhttp.getAllResponseHeaders();
30 if (xmlhttp.readyState == 4) {
31 if (rh) {
32 rh = rh.replace(/TM-finalURL\: .*[\r\n]{1,2}/, '');
33 }
34 var fi = xmlhttp.getResponseHeader('TM-finalURL');
35 if (fi) fu = fi;
36 }
37 }
38 var o = {
39 readyState: xmlhttp.readyState,
40 responseHeaders: rh,
41 finalUrl : fu,
42 status: (xmlhttp.readyState == 4 ? xmlhttp.status : 0),
43 statusText: (xmlhttp.readyState == 4 ? xmlhttp.statusText : '')
44 };
45 if (xmlhttp.readyState == 4) {
46 if (!xmlhttp.responseType || xmlhttp.responseType == '') {
47 o.responseXML = (xmlhttp.responseXML ? escape(xmlhttp.responseXML) : null);
48 o.responseText = xmlhttp.responseText;
49 o.response = xmlhttp.response;
50 } else {
51 o.responseXML = null;
52 o.responseText = null;
53 o.response = xmlhttp.response;
54 }
55 } else {
56 o.responseXML = null;
57 o.responseText = '';
58 o.response = null;
59 }
60 return o;
61 };
62 var onload = function() {
63 var responseState = createState();
64 if (responseState.readyState == 4 &&

Callers 3

onloadFunction · 0.85
onerrorFunction · 0.85
onreadystatechangeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…