mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-07 13:43:03 -04:00
UserScript: fix 'headers.get is not a function' error
This commit is contained in:
parent
c7f3889713
commit
e447dec67b
2 changed files with 5 additions and 9 deletions
|
@ -17,9 +17,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function parseHeaders(headers) {
|
function parseHeaders(headers) {
|
||||||
|
const result = new Headers();
|
||||||
if (!headers)
|
if (!headers)
|
||||||
return {};
|
return result;
|
||||||
const result = {};
|
|
||||||
const headersArr = headers.trim().split("\n");
|
const headersArr = headers.trim().split("\n");
|
||||||
for (var i = 0; i < headersArr.length; i++) {
|
for (var i = 0; i < headersArr.length; i++) {
|
||||||
var row = headersArr[i];
|
var row = headersArr[i];
|
||||||
|
@ -27,13 +28,7 @@ function parseHeaders(headers) {
|
||||||
, key = row.slice(0, index).trim().toLowerCase()
|
, key = row.slice(0, index).trim().toLowerCase()
|
||||||
, value = row.slice(index + 1).trim();
|
, value = row.slice(index + 1).trim();
|
||||||
|
|
||||||
if (result[key] === undefined) {
|
result.append(key, value);
|
||||||
result[key] = value;
|
|
||||||
} else if (Array.isArray(result[key])) {
|
|
||||||
result[key].push(value);
|
|
||||||
} else {
|
|
||||||
result[key] = [result[key], value];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
// @license GPL-3.0
|
// @license GPL-3.0
|
||||||
// @match *://*.discord.com/*
|
// @match *://*.discord.com/*
|
||||||
// @grant GM_xmlhttpRequest
|
// @grant GM_xmlhttpRequest
|
||||||
|
// @grant unsafeWindow
|
||||||
// @run-at document-start
|
// @run-at document-start
|
||||||
// @compatible chrome Chrome + Tampermonkey or Violentmonkey
|
// @compatible chrome Chrome + Tampermonkey or Violentmonkey
|
||||||
// @compatible firefox Firefox Tampermonkey
|
// @compatible firefox Firefox Tampermonkey
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue