Add accordion and fix minor issues (#742)
* Add docs v0.0.1 * Add icon size warning * Fix sourcenover caution * Fix semver descriptions * Filters fix * Quickfix quickstart * Add icon warning v2 * Fix typos * Add NovelItem * Update plugins host * Update plugins host * Remove unnecesarry .js and .dist * Update plugins host * Add host.ps1 * Fix readme.txt * Fix READNE.txt, again * Remove .js and .dist * Add accordion * Working pagination * readme update with ost * Add linux/windows hosting functions * Add tswatch * Fix fetch function * Change plugin versions * Fix chrome * Fix workflows * Fix search not showing results * remove unnecesarry code * Revert novelupdates changes * Reverted NobleMTL instead of novelupdates, fixing that * Revert nobleMTL to e346c7d0 * WTF NobleMTL?
This commit is contained in:
+21
-18
@@ -1,8 +1,13 @@
|
||||
type FetchInit = {
|
||||
headers?: Record<string, string> | Headers;
|
||||
headers?: Record<string, string | undefined> | Headers;
|
||||
method?: string;
|
||||
body?: FormData | string;
|
||||
[x: string]: string | Record<string, string> | undefined | FormData | Headers;
|
||||
[x: string]:
|
||||
| string
|
||||
| Record<string, string | undefined>
|
||||
| undefined
|
||||
| FormData
|
||||
| Headers;
|
||||
};
|
||||
|
||||
const makeInit = async (init?: FetchInit) => {
|
||||
@@ -31,21 +36,19 @@ const makeInit = async (init?: FetchInit) => {
|
||||
};
|
||||
}
|
||||
return init;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch with (Android) User Agent
|
||||
* @param url
|
||||
* @param init
|
||||
* @param url
|
||||
* @param init
|
||||
* @returns response as normal fetch
|
||||
*/
|
||||
export async function fetchApi(
|
||||
url: string,
|
||||
init?: FetchInit
|
||||
) {
|
||||
export async function fetchApi(url: string, init?: FetchInit) {
|
||||
init = await makeInit(init);
|
||||
console.log(url, init);
|
||||
return await fetch(url, init);
|
||||
// console.log(init.headers);
|
||||
// console.log(url, init);
|
||||
return await fetch(url, init as RequestInit);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,12 +62,12 @@ export const fetchFile = async function (url: string, init?: FetchInit) {
|
||||
init = await makeInit(init);
|
||||
console.log(url, init);
|
||||
try {
|
||||
const res = await fetch(url, init);
|
||||
if (!res.ok) return '';
|
||||
const res = await fetch(url, init as RequestInit);
|
||||
if (!res.ok) return "";
|
||||
const arrayBuffer = await res.arrayBuffer();
|
||||
return Buffer.from(arrayBuffer).toString("base64");
|
||||
} catch (e) {
|
||||
return '';
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
@@ -79,17 +82,17 @@ export const fetchFile = async function (url: string, init?: FetchInit) {
|
||||
export const fetchText = async function (
|
||||
url: string,
|
||||
init?: FetchInit,
|
||||
encoding?: string,
|
||||
encoding?: string
|
||||
): Promise<string> {
|
||||
init = await makeInit(init);
|
||||
console.log(url, init);
|
||||
try {
|
||||
const res = await fetch(url, init);
|
||||
if (!res.ok) return '';
|
||||
const res = await fetch(url, init as RequestInit);
|
||||
if (!res.ok) return "";
|
||||
const arrayBuffer = await res.arrayBuffer();
|
||||
const decoder = new TextDecoder(encoding);
|
||||
return decoder.decode(arrayBuffer);
|
||||
} catch (e) {
|
||||
return '';
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user