Make TRX capable of running in a locally hosted Tildes for development.
This commit is contained in:
parent
2256e67e86
commit
1a1758419d
|
@ -35,7 +35,7 @@ const sourceDir = toAbsolutePath("../source");
|
|||
await fsp.mkdir(outDir, {recursive: true});
|
||||
|
||||
// Write the WebExtension manifest file.
|
||||
const manifest = createManifest(browser);
|
||||
const manifest = createManifest(browser, dev);
|
||||
await fsp.writeFile(
|
||||
path.join(outDir, "manifest.json"),
|
||||
JSON.stringify(manifest),
|
||||
|
|
|
@ -6,9 +6,13 @@ import {type Manifest} from "webextension-polyfill";
|
|||
* Creates the WebExtension manifest based on the browser target.
|
||||
*
|
||||
* @param browser The browser target ("firefox" or "chromium").
|
||||
* @param dev Is this for development or production.
|
||||
* @returns The WebExtension manifest.
|
||||
*/
|
||||
export function createManifest(browser: string): Manifest.WebExtensionManifest {
|
||||
export function createManifest(
|
||||
browser: string,
|
||||
dev: boolean,
|
||||
): Manifest.WebExtensionManifest {
|
||||
const manifest: Manifest.WebExtensionManifest = {
|
||||
manifest_version: Number.NaN,
|
||||
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 = {
|
||||
128: "tildes-reextended.png",
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue