Repository navigation
Expand file tree
/
Copy pathsample-extension.ts
More file actions
75 lines (63 loc) · 2.09 KB
/
Copy pathsample-extension.ts
File metadata and controls
75 lines (63 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// name: Sample TypeScript Extension
// version: 1.0.0
// author: OtakuWorld
// description: TypeScript reference/fixture extension with stubbed implementations of all required functions.
// iconUrl: https://example.com/sample-extension-icon.png
// updateUrl: https://example.com/sample-extension/update.json
interface Item {
title: string;
url: string;
imageUrl: string;
}
interface Request {
url: string;
headers: Record<string, string>;
}
function getPopularRequest(page: number): Request {
return { url: "https://example.com/popular?page=" + page, headers: {} };
}
function getPopularParse(page: number, responseBody: string): Item[] {
return [
{ title: "Sample Item", url: "https://example.com/item/1", imageUrl: null }
];
}
function getLatestRequest(page: number): Request {
return { url: "https://example.com/latest?page=" + page, headers: {} };
}
function getLatestParse(page: number, responseBody: string): Item[] {
return [
{ title: "Latest Sample Item", url: "https://example.com/item/2", imageUrl: null }
];
}
function searchRequest(query: string, page: number): Request {
return { url: "https://example.com/search?q=" + query + "&page=" + page, headers: {} };
}
function searchParse(query: string, page: number, responseBody: string): Item[] {
return [
{ title: "Search Result for " + query, url: "https://example.com/item/3", imageUrl: null }
];
}
function getDetailRequest(url: string): Request {
return { url: url, headers: {} };
}
function getDetailParse(url: string, responseBody: string) {
return {
title: "Sample Item",
url: url,
imageUrl: null,
description: "A sample item detail.",
genres: ["Action"],
chapters: [
{ name: "Chapter 1", url: "https://example.com/chapter/1", uploaded: null }
]
};
}
function getContentRequest(url: string): Request {
return { url: url, headers: {} };
}
function getContentParse(url: string, responseBody: string) {
return {
urls: ["https://example.com/content/1.png"],
headers: {}
};
}