1
Fork 0

Make TRX capable of running in a locally hosted Tildes for development.

This commit is contained in:
Bauke 2023-12-22 14:50:21 +01:00
parent 2256e67e86
commit 1a1758419d
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
2 changed files with 13 additions and 2 deletions

View File

@ -35,7 +35,7 @@ const sourceDir = toAbsolutePath("../source");
await fsp.mkdir(outDir, {recursive: true}); await fsp.mkdir(outDir, {recursive: true});
// Write the WebExtension manifest file. // Write the WebExtension manifest file.
const manifest = createManifest(browser); const manifest = createManifest(browser, dev);
await fsp.writeFile( await fsp.writeFile(
path.join(outDir, "manifest.json"), path.join(outDir, "manifest.json"),
JSON.stringify(manifest), JSON.stringify(manifest),

View File

@ -6,9 +6,13 @@ import {type Manifest} from "webextension-polyfill";
* Creates the WebExtension manifest based on the browser target. * Creates the WebExtension manifest based on the browser target.
* *
* @param browser The browser target ("firefox" or "chromium"). * @param browser The browser target ("firefox" or "chromium").
* @param dev Is this for development or production.
* @returns The WebExtension manifest. * @returns The WebExtension manifest.
*/ */
export function createManifest(browser: string): Manifest.WebExtensionManifest { export function createManifest(
browser: string,
dev: boolean,
): Manifest.WebExtensionManifest {
const manifest: Manifest.WebExtensionManifest = { const manifest: Manifest.WebExtensionManifest = {
manifest_version: Number.NaN, manifest_version: Number.NaN,
name: "Tildes ReExtended", name: "Tildes ReExtended",
@ -29,6 +33,13 @@ export function createManifest(browser: string): Manifest.WebExtensionManifest {
], ],
}; };
if (dev) {
// Add the localhost permissions in development so TRX can run on a locally
// hosted Tildes.
manifest.permissions!.push("*://localhost/*");
manifest.content_scripts![0].matches.push("https://*.localhost/*");
}
const icons: Manifest.IconPath = { const icons: Manifest.IconPath = {
128: "tildes-reextended.png", 128: "tildes-reextended.png",
}; };