From a1efe412eeae2bf5cd03b6a89f81805df5d448a9 Mon Sep 17 00:00:00 2001 From: WardPearce Date: Sat, 14 Feb 2026 05:40:35 +1300 Subject: [PATCH] Minor fixes --- materialious/electron/src/index.ts | 3 +- materialious/package-lock.json | 46 +++++++++++++++++++ materialious/package.json | 1 + materialious/src/lib/components/Player.svelte | 4 +- .../src/lib/components/Transcript.svelte | 14 ++++-- materialious/src/routes/.d.ts | 1 + .../src/routes/api/poToken/+server.ts | 3 +- .../routes/api/proxy/[urlToProxy]/+server.ts | 1 - materialious/tsconfig.json | 17 ++----- 9 files changed, 67 insertions(+), 23 deletions(-) diff --git a/materialious/electron/src/index.ts b/materialious/electron/src/index.ts index e5d5cdc5..2fd3adcb 100644 --- a/materialious/electron/src/index.ts +++ b/materialious/electron/src/index.ts @@ -85,8 +85,7 @@ ipcMain.handle( { url: youtubeUrl, referrer: youtubeUrl, - origin: youtubeUrl, - USER_AGENT + userAgent: USER_AGENT } ); diff --git a/materialious/package-lock.json b/materialious/package-lock.json index 075729ec..5fdb4bb2 100644 --- a/materialious/package-lock.json +++ b/materialious/package-lock.json @@ -62,6 +62,7 @@ "@types/event-source-polyfill": "^1.0.5", "@types/he": "^1.2.3", "@types/human-number": "^1.0.2", + "@types/jsdom": "^27.0.0", "@types/mousetrap": "^1.6.15", "@vite-pwa/sveltekit": "^1.0.0", "altcha-lib": "^1.4.1", @@ -4633,6 +4634,44 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/jsdom": { + "version": "27.0.0", + "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-27.0.0.tgz", + "integrity": "sha512-NZyFl/PViwKzdEkQg96gtnB8wm+1ljhdDay9ahn4hgb+SfVtPCbm3TlmDUFXTA+MGN3CijicnMhG18SI5H3rFw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "@types/tough-cookie": "*", + "parse5": "^7.0.0" + } + }, + "node_modules/@types/jsdom/node_modules/entities": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz", + "integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/@types/jsdom/node_modules/parse5": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz", + "integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "entities": "^6.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -4691,6 +4730,13 @@ "integrity": "sha512-+OpjSaq85gvlZAYINyzKpLeiFkSC4EsC6IIiT6v6TLSU5k5U83fHGj9Lel8oKEXM0HqgrMVCjXPDPVICtxF7EQ==", "license": "MIT" }, + "node_modules/@types/tough-cookie": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.5.tgz", + "integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/trusted-types": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", diff --git a/materialious/package.json b/materialious/package.json index 5450ac1d..ab0e0147 100644 --- a/materialious/package.json +++ b/materialious/package.json @@ -27,6 +27,7 @@ "@types/event-source-polyfill": "^1.0.5", "@types/he": "^1.2.3", "@types/human-number": "^1.0.2", + "@types/jsdom": "^27.0.0", "@types/mousetrap": "^1.6.15", "@vite-pwa/sveltekit": "^1.0.0", "altcha-lib": "^1.4.1", diff --git a/materialious/src/lib/components/Player.svelte b/materialious/src/lib/components/Player.svelte index 4efd39ff..8fb7cda5 100644 --- a/materialious/src/lib/components/Player.svelte +++ b/materialious/src/lib/components/Player.svelte @@ -576,10 +576,10 @@ if (data.video.captions) { for (const caption of data.video.captions) { let captionUrl: string; - if (!import.meta.env.VITE_DEFAULT_COMPANION_INSTANCE) { + if (!import.meta.env.VITE_DEFAULT_COMPANION_INSTANCE && $instanceStore) { captionUrl = caption.url.startsWith('http') ? caption.url - : `${new URL(get(instanceStore)).origin}${caption.url}`; + : `${new URL($instanceStore).origin}${caption.url}`; } else { captionUrl = `${import.meta.env.VITE_DEFAULT_COMPANION_INSTANCE}${caption.url}`; } diff --git a/materialious/src/lib/components/Transcript.svelte b/materialious/src/lib/components/Transcript.svelte index e4e7ff4e..985b62a5 100644 --- a/materialious/src/lib/components/Transcript.svelte +++ b/materialious/src/lib/components/Transcript.svelte @@ -46,11 +46,19 @@ return; } + let urlConstructed = ''; + + if (video.fallbackPatch === 'youtubejs') { + urlConstructed = url; + } else if ($instanceStore) { + urlConstructed = new URL($instanceStore).origin + url; + } else { + return; + } + isLoading = true; transcript = null; - const resp = await fetch( - `${!video.fallbackPatch ? new URL(get(instanceStore)).origin : ''}${url}` - ); + const resp = await fetch(urlConstructed); transcript = await parseText(await resp.text(), { strict: false }); transcriptCues = transcript.cues; diff --git a/materialious/src/routes/.d.ts b/materialious/src/routes/.d.ts index ede24701..c8cd8ff7 100644 --- a/materialious/src/routes/.d.ts +++ b/materialious/src/routes/.d.ts @@ -1 +1,2 @@ declare module 'virtual:pwa-info'; +declare module 'psl'; diff --git a/materialious/src/routes/api/poToken/+server.ts b/materialious/src/routes/api/poToken/+server.ts index 79cd644c..7f3263ce 100644 --- a/materialious/src/routes/api/poToken/+server.ts +++ b/materialious/src/routes/api/poToken/+server.ts @@ -32,8 +32,7 @@ export async function POST({ request, locals }) { { url: youtubeUrl, referrer: youtubeUrl, - origin: youtubeUrl, - USER_AGENT + userAgent: USER_AGENT } ); diff --git a/materialious/src/routes/api/proxy/[urlToProxy]/+server.ts b/materialious/src/routes/api/proxy/[urlToProxy]/+server.ts index eb82276c..d4bcf26b 100644 --- a/materialious/src/routes/api/proxy/[urlToProxy]/+server.ts +++ b/materialious/src/routes/api/proxy/[urlToProxy]/+server.ts @@ -2,7 +2,6 @@ import { isOwnBackend } from '$lib/shared'; import psl from 'psl'; import { env } from '$env/dynamic/private'; import { error } from '@sveltejs/kit'; -import { verifyCaptcha } from '$lib/server/captcha.js'; const allowedDomains: string[] = [ 'youtube.com', diff --git a/materialious/tsconfig.json b/materialious/tsconfig.json index 0fe20b84..4c9537a5 100644 --- a/materialious/tsconfig.json +++ b/materialious/tsconfig.json @@ -10,21 +10,12 @@ "sourceMap": true, "strict": true, "moduleResolution": "bundler", - "types": [ - "shaka-player" - ] + "types": ["shaka-player"] }, - "include": [ - "src/**/*.d.ts", - "src/**/*.ts", - "src/**/*.svelte" - ], - "exclude": [ - "node_modules", - "dist" - ] + "include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.svelte", ".svelte-kit/ambient.d.ts"], + "exclude": ["node_modules", "dist"] // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias // // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes // from the referenced tsconfig.json - TypeScript does not merge them in -} \ No newline at end of file +}