Skip to content

Commit 98fab8b

Browse files
author
Lei Shi
committed
feat(install): default to official extension IDs from web stores
Each browser now has a built-in default extension ID matching the official Web Store / Add-ons listing, so `ptd install --browser chrome` works without specifying `--extension-id`. Extra IDs (e.g. for unpacked dev builds) can still be added and are merged alongside the defaults. - Chrome / Chromium: iloddidemhbedaopmipajgclofjocogb - Edge: kbijhmckhndmeckonoikakdfdlbnlkde - Firefox: unchanged (already uses ptdepiler.ptplugins@gmail.com)
1 parent 8c3ccf6 commit 98fab8b

1 file changed

Lines changed: 25 additions & 11 deletions

File tree

src/cli/commands/install.rs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ pub struct InstallArgs {
1010
#[arg(long)]
1111
pub browser: BrowserFamily,
1212

13-
/// Extension ID (required for Chrome-family browsers).
14-
/// Can be specified multiple times for multi-browser setups sharing one manifest
15-
/// (e.g. `--extension-id <chrome-id> --extension-id <edge-id>`).
13+
/// Extension ID for Chrome-family browsers.
14+
/// Defaults to the official Web Store / Add-ons ID for the target browser.
15+
/// Can be specified multiple times to allow additional IDs
16+
/// (e.g. for unpacked development builds).
1617
#[arg(long)]
1718
pub extension_id: Vec<String>,
1819
}
@@ -45,15 +46,28 @@ pub fn run(args: InstallArgs) -> Result<()> {
4546
"allowed_extensions": ["ptdepiler.ptplugins@gmail.com"]
4647
})
4748
} else {
48-
if args.extension_id.is_empty() {
49-
eprintln!("--extension-id is required for Chrome-family browsers.");
50-
eprintln!("Find it at chrome://extensions with Developer Mode enabled.");
51-
eprintln!("Multiple IDs can be specified: --extension-id <id1> --extension-id <id2>");
52-
std::process::exit(1);
53-
}
49+
// Official extension IDs from the Chrome Web Store / Edge Add-ons.
50+
let default_ids: &[&str] = match args.browser {
51+
BrowserFamily::Chrome => &["iloddidemhbedaopmipajgclofjocogb"],
52+
BrowserFamily::Edge => &["kbijhmckhndmeckonoikakdfdlbnlkde"],
53+
BrowserFamily::Chromium => &["iloddidemhbedaopmipajgclofjocogb"],
54+
_ => &[],
55+
};
56+
57+
let ids: Vec<&str> = if args.extension_id.is_empty() {
58+
default_ids.to_vec()
59+
} else {
60+
// User-specified IDs plus the official defaults.
61+
let mut combined: Vec<&str> = args.extension_id.iter().map(|s| s.as_str()).collect();
62+
for id in default_ids {
63+
if !combined.contains(id) {
64+
combined.push(id);
65+
}
66+
}
67+
combined
68+
};
5469

55-
let origins: Vec<String> = args
56-
.extension_id
70+
let origins: Vec<String> = ids
5771
.iter()
5872
.map(|id| format!("chrome-extension://{id}/"))
5973
.collect();

0 commit comments

Comments
 (0)