MCPcopy Create free account
hub / github.com/LeFroid/Viper-Browser / GM_xmlhttpRequest

Function GM_xmlhttpRequest

src/app/assets/javascript/GreaseMonkeyAPI.js:86–121  ·  view source on GitHub ↗
(details)

Source from the content-addressed store, hash-verified

84 }
85
86 function GM_xmlhttpRequest(details) {
87 details.method = details.method ? details.method.toUpperCase() : "GET";
88
89 if (!details.url) {
90 throw new Error("GM_xmlhttpRequest requires an URL.");
91 }
92
93 // build XMLHttpRequest object
94 const oXhr = new XMLHttpRequest();
95 // run it
96 if ("onreadystatechange" in details) {
97 oXhr.onreadystatechange = function() {
98 details.onreadystatechange(oXhr);
99 };
100 }
101 if ("onload" in details) {
102 oXhr.onload = function() { details.onload(oXhr); };
103 }
104 if ("onerror" in details) {
105 oXhr.onerror = function () { details.onerror(oXhr); };
106 }
107
108 oXhr.open(details.method, details.url, true);
109
110 if ("headers" in details) {
111 for (const header in details.headers) {
112 oXhr.setRequestHeader(header, details.headers[header]);
113 }
114 }
115
116 if ("data" in details) {
117 oXhr.send(details.data);
118 } else {
119 oXhr.send();
120 }
121 }
122
123 function GM_getResourceUrl(resourceName) {
124 return '';

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected