From a3388efb971462163b068e941bc7080aa48f5f85 Mon Sep 17 00:00:00 2001 From: Ryze <50497128+ryze312@users.noreply.github.com> Date: Wed, 14 Feb 2024 16:30:15 +0300 Subject: [PATCH] Add command for Chromium manifest --- src/command.rs | 14 +++++++++++--- src/main.rs | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/command.rs b/src/command.rs index 7b6c184..77bcd8d 100644 --- a/src/command.rs +++ b/src/command.rs @@ -10,6 +10,7 @@ use crate::error::FF2MpvError; pub enum Command { ShowHelp, ShowManifest, + ShowManifestChromium, ValidateConfig, FF2Mpv } @@ -19,7 +20,8 @@ impl Command { pub fn execute(&self) -> Result<(), FF2MpvError> { match self { Command::ShowHelp => Self::show_help(), - Command::ShowManifest => Self::show_manifest(), + Command::ShowManifest => Self::show_manifest(false), + Command::ShowManifestChromium => Self::show_manifest(true), Command::ValidateConfig => Self::validate_config(), Command::FF2Mpv => Self::ff2mpv() } @@ -37,14 +39,20 @@ impl Command { Ok(()) } - fn show_manifest() -> Result<(), FF2MpvError>{ + fn show_manifest(chromium: bool) -> Result<(), FF2MpvError> { let executable_path = env::current_exe()?; + let allowed_keyvalue = if chromium { + ("allowed_origins", "chrome-extension://ephjcajbkgplkjmelpglennepbpmdpjg") + } else { + ("allowed_extensions", "ff2mpv@yossarian.net") + }; + let manifest = json!({ "name": "ff2mpv", "description": "ff2mpv's external manifest", "path": executable_path, "type": "stdio", - "allowed_extensions": ["ff2mpv@yossarian.net"] + allowed_keyvalue.0: [allowed_keyvalue.1] }); let manifest = serde_json::to_string_pretty(&manifest)?; diff --git a/src/main.rs b/src/main.rs index 1fbc2a9..263fc09 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,6 +19,7 @@ fn get_command(name: &str) -> Command { match name { "help" => Command::ShowHelp, "manifest" => Command::ShowManifest, + "manifest_chromium" => Command::ShowManifestChromium, "validate" => Command::ValidateConfig, _ => Command::FF2Mpv, }