Load unpacked Chrome extension programmatically

前端 未结 4 2217
广开言路
广开言路 2021-02-14 00:31

Is it possible to load and unload unpacked Chrome extensions from the Command Line?

相关标签:
4条回答
  • 2021-02-14 00:53

    Yes, although only temporarily *:

    chromium --load-extension=path/to/extension
    

    If you want to load multiple extensions, just separate the path by a comma:

    chromium --load-extension=path/to/extension,path/to/another/extension
    

    Replace chromium with chrome.exe (or whatever is used to start your Chrome/Chromium browser).

    * When you close the browser, and starts it again without the command line argument, then the extension will disappear from the list of installed extensions.

    0 讨论(0)
  • 2021-02-14 00:56

    3 ways install/use Chrome extensions offline:


    Method A: Drag & Drop (Simple)

    • Drag & drop ABP.crx on: chrome://extensions to install

    Pros: Installs web & non-westore extensions

    Cons: Google quickly & permanently disables non-webstore extensions


    Method B: Load unzipped extension/7zip to unzip/ABP used as example

    • UnZip ABP.crx: C:\ABP
    • Load 1: Shortcut: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --load-extension="C:\ABP"
    • Load 2: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --load-extension="C:\ABP,C:\IEtab"

    Pros: Permanently enables non-webstore extensions, so long as your using custom shortcut

    Cons: Extensions only load via custom shortcut

    ~~~~~~~~~~~~~~~ 3 fixes for extracted extension errors: ~~~~~~~~~~~~~~~

    • Won't load: Create shortcut to folder containing manifest file, for example: akkmfdhlogbapbcgojknhfgppcionopk\5.4.7_0

    • Metadata: Extension\delete _metadata folder

    • Disabled: Open manifest.json with notepad & locate:

    "name": "MSG_appName",

    "offline_enabled": true,

    Create: "offline_enabled": true, if it doesn't exist


    Method C: WinRar SFX (Mass install local/non-local profile apps)

    Chrome extracts all plugins to: %LocalAppData%\Google\User Data\Default\Extensions

    Extensions list by web-store ID. Example: ABP=cfhdojbkjhnklbpkdaibdccddilifddb

    ABP needs 3 files: Some extensions may only require 2

    • Install all plugins needed, remove all not needed. Exit Chrome.
    • Backup: %LocalAppData%\Google to: C:\Backup\Google
    • Copy: %LocalAppData%\Google\Chrome\User Data\Default\Extensions to: C:\Google\Chrome\User Data\Default\Extensions
    • Copy: %LocalAppData%\Google\Chrome\User Data\Default\secure preferences to: C:\Google\Chrome\User Data\Default\secure preferences
    • Copy: %LocalAppData%\Google\Chrome\User Data\Default\Local Extension Settings to: C:\Google\Chrome\User Data\Default\Local Extension Settings
    • Create WinRar SFX: Extract C:\Google to: %LocalAppData%\Google

    (ABP stores settings: %LocalAppData%\Google\User Data\Default\Local Extension Settings)

    Pros: Mass install web & non-webstore apps, from local/nonlocal pc's

    Cons: Google quickly & permanently disables non-webstore extensions

    When SFX imports secure preferences file, it replaces old extensions/settings with imported

    Restore Chrome Backup:

    • Exit Chrome & delete %LocalAppData%\Google\Chrome
    • Copy C:\Backup\Google to: %LocalAppData%\Google
    • Launch Chrome
    0 讨论(0)
  • 2021-02-14 00:59

    It is possible to install using --load-and-launch-app=path/to/app

    it is working for both apps and extensions. (I tested on chrome Version 35.0.1916.153 m)

    I am not sure that there is another command for uninstalling. I found this list of chromium commands which is very useful.

    0 讨论(0)
  • 2021-02-14 01:09

    Try to kill all existing instances of Chrome from task manager : TASKKILL /IM chrome.exe /F and then chrome.exe --load-extension=path/to/extension should work

    This working C# code for console application can help

    class Program
        {
            static void Main(string[] args)
            {
                Process cmd = new Process();
    
                cmd.StartInfo.FileName = "cmd.exe";
                cmd.StartInfo.RedirectStandardInput = true;
                cmd.StartInfo.RedirectStandardOutput = true;
                cmd.StartInfo.CreateNoWindow = true;
                cmd.StartInfo.UseShellExecute = false;
    
                cmd.Start();
                //kill all chrome instances
                cmd.StandardInput.WriteLine("TASKKILL /IM chrome.exe /F");
                //path to chrome.exe
                cmd.StandardInput.WriteLine("cd C:\\Program Files (x86)\\Google\\Chrome\\Application");
                //load extension
                cmd.StandardInput.WriteLine("chrome.exe --load-extension={path-to-extension}");
    
                cmd.StandardInput.Flush();
                cmd.StandardInput.Close();
                Console.WriteLine(cmd.StandardOutput.ReadToEnd());
    
            }
        }
    
    0 讨论(0)
提交回复
热议问题