Skip to content

Commit 5247f5a

Browse files
committed
feat: channel playlists, history page headers, many fixes
1 parent 4d9889a commit 5247f5a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1978
-1920
lines changed

extension/src/manifest.chrome.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
"manifest_version": 3,
3-
"action": {},
4-
"background": {
5-
"service_worker": "service-worker.js"
6-
},
7-
"permissions": ["cookies", "storage", "declarativeNetRequest"],
8-
"host_permissions": [
9-
"https://*.youtube.com/*",
10-
"https://returnyoutubedislikeapi.com/*",
11-
"https://yt3.ggpht.com/*",
12-
"https://i.ytimg.com/*"
13-
]
2+
"manifest_version": 3,
3+
"action": {},
4+
"background": {
5+
"service_worker": "service-worker.js"
6+
},
7+
"permissions": ["cookies", "storage", "declarativeNetRequest"],
8+
"host_permissions": [
9+
"https://*.youtube.com/*",
10+
"https://returnyoutubedislikeapi.com/*",
11+
"https://yt3.ggpht.com/*",
12+
"https://i.ytimg.com/*"
13+
]
1414
}

extension/src/manifest.firefox.json

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
2-
"browser_specific_settings": {
3-
"gecko": {
4-
5-
}
6-
},
7-
"action": {},
8-
"manifest_version": 3,
9-
"background": {
10-
"scripts": ["service-worker.js"]
11-
},
12-
"permissions": [
13-
"cookies",
14-
"storage",
15-
"contextualIdentities",
16-
"declarativeNetRequest",
17-
"declarativeNetRequestFeedback"
18-
],
19-
"host_permissions": [
20-
"https://*.youtube.com/*",
21-
"https://returnyoutubedislikeapi.com/*",
22-
"https://yt3.ggpht.com/*",
23-
"https://i.ytimg.com/*"
24-
]
2+
"browser_specific_settings": {
3+
"gecko": {
4+
5+
}
6+
},
7+
"action": {},
8+
"manifest_version": 3,
9+
"background": {
10+
"scripts": ["service-worker.js"]
11+
},
12+
"permissions": [
13+
"cookies",
14+
"storage",
15+
"contextualIdentities",
16+
"declarativeNetRequest",
17+
"declarativeNetRequestFeedback"
18+
],
19+
"host_permissions": [
20+
"https://*.youtube.com/*",
21+
"https://returnyoutubedislikeapi.com/*",
22+
"https://yt3.ggpht.com/*",
23+
"https://i.ytimg.com/*"
24+
]
2525
}

extension/src/routes/proxy/convert.ts

+76-80
Original file line numberDiff line numberDiff line change
@@ -6,98 +6,94 @@
66

77
/// RequestInit
88
export interface TransferableRequestInit {
9-
/** A Base64 string or null to set request's body. */
10-
body?: string | null;
11-
/** A string indicating how the request will interact with the browser's cache to set request's cache. */
12-
cache?: RequestCache;
13-
/** A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials. */
14-
credentials?: RequestCredentials;
15-
/** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
16-
headers?: [string, string][] | Record<string, string>;
17-
/** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
18-
integrity?: string;
19-
/** A boolean to set request's keepalive. */
20-
keepalive?: boolean;
21-
/** A string to set request's method. */
22-
method?: string;
23-
/** A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode. */
24-
mode?: RequestMode;
25-
/** A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */
26-
redirect?: RequestRedirect;
27-
/** A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer. */
28-
referrer?: string;
29-
/** A referrer policy to set request's referrerPolicy. */
30-
referrerPolicy?: ReferrerPolicy;
9+
/** A Base64 string or null to set request's body. */
10+
body?: string | null
11+
/** A string indicating how the request will interact with the browser's cache to set request's cache. */
12+
cache?: RequestCache
13+
/** A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials. */
14+
credentials?: RequestCredentials
15+
/** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
16+
headers?: [string, string][] | Record<string, string>
17+
/** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
18+
integrity?: string
19+
/** A boolean to set request's keepalive. */
20+
keepalive?: boolean
21+
/** A string to set request's method. */
22+
method?: string
23+
/** A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode. */
24+
mode?: RequestMode
25+
/** A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */
26+
redirect?: RequestRedirect
27+
/** A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer. */
28+
referrer?: string
29+
/** A referrer policy to set request's referrerPolicy. */
30+
referrerPolicy?: ReferrerPolicy
3131
}
3232

3333
export const transferableRequestInitToRequestInit = (
34-
transferableRequest: TransferableRequestInit,
34+
transferableRequest: TransferableRequestInit,
3535
): RequestInit => ({
36-
body:
37-
transferableRequest.body && stringToArrayBuffer(transferableRequest.body),
38-
cache: transferableRequest.cache,
39-
credentials: transferableRequest.credentials,
40-
headers: new Headers(transferableRequest.headers),
41-
integrity: transferableRequest.integrity,
42-
method: transferableRequest.method,
43-
mode: transferableRequest.mode,
44-
redirect: transferableRequest.redirect,
45-
referrer: transferableRequest.referrer,
46-
referrerPolicy: transferableRequest.referrerPolicy,
47-
});
36+
body: transferableRequest.body && stringToArrayBuffer(transferableRequest.body),
37+
cache: transferableRequest.cache,
38+
credentials: transferableRequest.credentials,
39+
headers: new Headers(transferableRequest.headers),
40+
integrity: transferableRequest.integrity,
41+
method: transferableRequest.method,
42+
mode: transferableRequest.mode,
43+
redirect: transferableRequest.redirect,
44+
referrer: transferableRequest.referrer,
45+
referrerPolicy: transferableRequest.referrerPolicy,
46+
})
4847

4948
export const requestInitToTransferableRequestInit = async (
50-
requestInit: RequestInit,
49+
requestInit: RequestInit,
5150
): Promise<TransferableRequestInit> => ({
52-
...requestInit,
53-
body: requestInit.body && (await new Response(requestInit.body).text()),
54-
// @ts-expect-error Valid but Typescript doesn't recognize it
55-
headers:
56-
requestInit.headers instanceof Headers
57-
? requestInit.headers.entries()
58-
: requestInit.headers,
59-
});
51+
...requestInit,
52+
body: requestInit.body && (await new Response(requestInit.body).text()),
53+
// @ts-expect-error Valid but Typescript doesn't recognize it
54+
headers: requestInit.headers instanceof Headers ? requestInit.headers.entries() : requestInit.headers,
55+
})
6056

6157
/// Response
6258
type TransferableResponse = {
63-
/** Base64 encoded */
64-
body: null | string;
65-
headers: Record<string, string>;
66-
status: number;
67-
statusText: string;
68-
};
69-
export const responseToTransferableResponse = async (
70-
response: Response,
71-
): Promise<TransferableResponse> => ({
72-
body: response.body && (await response.text()),
73-
headers: headersToObject(response.headers),
74-
status: response.status,
75-
statusText: response.statusText,
76-
});
59+
/** Base64 encoded */
60+
body: null | string
61+
headers: Record<string, string>
62+
status: number
63+
statusText: string
64+
}
65+
export const responseToTransferableResponse = async (response: Response): Promise<TransferableResponse> => ({
66+
body: response.body && (await response.text()),
67+
headers: headersToObject(response.headers),
68+
status: response.status,
69+
statusText: response.statusText,
70+
})
7771

78-
export const transferableResponseToResponse = (
79-
transferableResponse: TransferableResponse,
80-
): Response =>
81-
new Response(
82-
transferableResponse.body && stringToArrayBuffer(transferableResponse.body),
83-
{
84-
headers: new Headers(transferableResponse.headers),
85-
status: transferableResponse.status,
86-
statusText: transferableResponse.statusText,
87-
},
88-
);
72+
export const transferableResponseToResponse = (transferableResponse: TransferableResponse): Response =>
73+
new Response(
74+
[101, 204, 205, 304].includes(transferableResponse.status)
75+
? null
76+
: transferableResponse.body
77+
? stringToArrayBuffer(transferableResponse.body)
78+
: undefined,
79+
{
80+
headers: new Headers(transferableResponse.headers),
81+
status: transferableResponse.status,
82+
statusText: transferableResponse.statusText,
83+
},
84+
)
8985

9086
/// Helpers
9187
const stringToArrayBuffer = (str: string) => {
92-
const encoder = new TextEncoder();
93-
return encoder.encode(str);
94-
};
88+
const encoder = new TextEncoder()
89+
return encoder.encode(str)
90+
}
9591
const headersToObject = (headers: Headers) => {
96-
const headersObject: Record<string, string> = {};
97-
// no type-safe way to do it with for of that I know of
98-
// biome-ignore lint/complexity/noForEach:
99-
headers.forEach((value, key) => {
100-
headersObject[key] = value;
101-
});
102-
return headersObject;
103-
};
92+
const headersObject: Record<string, string> = {}
93+
// no type-safe way to do it with for of that I know of
94+
// biome-ignore lint/complexity/noForEach:
95+
headers.forEach((value, key) => {
96+
headersObject[key] = value
97+
})
98+
return headersObject
99+
}

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@
3232
"react-dom": "^18.2.0",
3333
"styled-components": "^6.1.8",
3434
"vite-tsconfig-paths": "^4.3.1",
35-
"wouter": "^3.0.1"
35+
"wouter": "^3.0.2"
3636
},
3737
"devDependencies": {
3838
"@biomejs/biome": "^1.5.3",
3939
"@preact/preset-vite": "^2.8.1",
4040
"@styled/typescript-styled-plugin": "^1.0.1",
41-
"@types/react": "^18.2.61",
42-
"@types/react-dom": "^18.2.19",
41+
"@types/react": "^18.2.64",
42+
"@types/react-dom": "^18.2.20",
4343
"@types/webextension-polyfill": "^0.10.7",
4444
"@vitejs/plugin-react": "^4.2.1",
4545
"husky": "^9.0.11",
@@ -48,8 +48,8 @@
4848
"postcss-preset-mantine": "^1.13.0",
4949
"postcss-simple-vars": "^7.0.1",
5050
"prettier": "^3.2.5",
51-
"typescript": "^5.3.3",
52-
"vite": "^5.1.4",
51+
"typescript": "^5.4.2",
52+
"vite": "^5.1.5",
5353
"vite-bundle-visualizer": "^1.0.1",
5454
"vite-plugin-preload": "^0.3.1"
5555
},

0 commit comments

Comments
 (0)