fix Vencloud not working on UserScript (#2213)
Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
parent
3ebde1aae8
commit
9179f55bf2
|
@ -62,7 +62,7 @@ function GM_fetch(url, opt) {
|
||||||
resp.arrayBuffer = () => blobTo("arrayBuffer", blob);
|
resp.arrayBuffer = () => blobTo("arrayBuffer", blob);
|
||||||
resp.text = () => blobTo("text", blob);
|
resp.text = () => blobTo("text", blob);
|
||||||
resp.json = async () => JSON.parse(await blobTo("text", blob));
|
resp.json = async () => JSON.parse(await blobTo("text", blob));
|
||||||
resp.headers = new Headers(parseHeaders(resp.responseHeaders));
|
resp.headers = parseHeaders(resp.responseHeaders);
|
||||||
resp.ok = resp.status >= 200 && resp.status < 300;
|
resp.ok = resp.status >= 200 && resp.status < 300;
|
||||||
resolve(resp);
|
resolve(resp);
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,9 +39,7 @@ function validateUrl(url: string) {
|
||||||
async function eraseAllData() {
|
async function eraseAllData() {
|
||||||
const res = await fetch(new URL("/v1/", getCloudUrl()), {
|
const res = await fetch(new URL("/v1/", getCloudUrl()), {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: new Headers({
|
headers: { Authorization: await getCloudAuth() }
|
||||||
Authorization: await getCloudAuth()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
|
|
|
@ -106,7 +106,7 @@ export async function authorizeCloud() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(location, {
|
const res = await fetch(location, {
|
||||||
headers: new Headers({ Accept: "application/json" })
|
headers: { Accept: "application/json" }
|
||||||
});
|
});
|
||||||
const { secret } = await res.json();
|
const { secret } = await res.json();
|
||||||
if (secret) {
|
if (secret) {
|
||||||
|
|
|
@ -118,10 +118,10 @@ export async function putCloudSettings(manual?: boolean) {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(new URL("/v1/settings", getCloudUrl()), {
|
const res = await fetch(new URL("/v1/settings", getCloudUrl()), {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: new Headers({
|
headers: {
|
||||||
Authorization: await getCloudAuth(),
|
Authorization: await getCloudAuth(),
|
||||||
"Content-Type": "application/octet-stream"
|
"Content-Type": "application/octet-stream"
|
||||||
}),
|
},
|
||||||
body: deflateSync(new TextEncoder().encode(settings))
|
body: deflateSync(new TextEncoder().encode(settings))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -162,11 +162,11 @@ export async function getCloudSettings(shouldNotify = true, force = false) {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(new URL("/v1/settings", getCloudUrl()), {
|
const res = await fetch(new URL("/v1/settings", getCloudUrl()), {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: new Headers({
|
headers: {
|
||||||
Authorization: await getCloudAuth(),
|
Authorization: await getCloudAuth(),
|
||||||
Accept: "application/octet-stream",
|
Accept: "application/octet-stream",
|
||||||
"If-None-Match": Settings.cloud.settingsSyncVersion.toString()
|
"If-None-Match": Settings.cloud.settingsSyncVersion.toString()
|
||||||
}),
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.status === 404) {
|
if (res.status === 404) {
|
||||||
|
@ -251,9 +251,7 @@ export async function deleteCloudSettings() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(new URL("/v1/settings", getCloudUrl()), {
|
const res = await fetch(new URL("/v1/settings", getCloudUrl()), {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: new Headers({
|
headers: { Authorization: await getCloudAuth() },
|
||||||
Authorization: await getCloudAuth()
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
|
|
Loading…
Reference in a new issue