1

We are setting kiosk-type workstations with chromium browser running in incognito mode. There is a need to have redux-devtools extension for development purposes.

We managed in install it using scripts. Basically uploaded bundles and manifest.json to

/usr/share/chromium-browser/extensions

In non-incognito mode it works. And there is a way to enable it in incognito move using UI (settings for the extension).

But the thing is that we have no access for this interaction and we have to do it somehow programmatically. Looks like its not some browser setting but extension's one. Is there any way to do it using bash or smth. similar?

ikebastuz
  • 349
  • 1
  • 5
  • 13
  • "And there is a way to enable it in incognito move using UI" did you mean in non-incognito? – j2ko Sep 05 '19 at 13:28
  • No, if extension is already installed - you can enable it in UI even in incognito mode – ikebastuz Sep 05 '19 at 14:17
  • So you trying to find a way to programatically (through script) automate installing and enabling extension in incognito mode. Right? – j2ko Sep 05 '19 at 14:26
  • Exactly. We installed it, but still activating manually – ikebastuz Sep 05 '19 at 14:32
  • Are you using your own Chromium fork and can you modify its source code? You can modify Chromium's C++ source code and do that – Asesh Sep 06 '19 at 03:44

1 Answers1

2

There is no direct way to do it. But I've manage to do this in no so obvious way. I made it work by directly modifying preferences file. To make it work all chrome instances should be closed. Also instead of installing extension just unpack it somewhere you know. So here is how to start chrome

`chrome --incognito --load-extension=<path/to/unpacked/extension>`

This will start chrome with extension installed meaning that some preference entries will be created. Now we need to modify value that responsible for allowing extension in incognito mode. For this I wrote a small python3 script:

extension_incognito_enabled.py

    import json
    import os
    import sys

    google_chrome_preferences ="/home/j2ko/.config/google-chrome/Default/Preferences"

    incognito_value = (False, True)[sys.argv[1] == "true"]

    print("Closing all chrome instances")
    os.system('killall chrome')

    #As we load extension using --load-extension flag we can use path to it
    field_to_compare="path"
    field_value_to_compare_with="/home/j2ko/Downloads/isAllowedAccess"

    jsonPreferences =""
    with open(google_chrome_preferences, "r+") as jsonFile:
        jsonPreferences = json.load(jsonFile)


    settings = jsonPreferences["extensions"]["settings"]
    for extension_name in settings:
        extension_setting = settings[extension_name]
        if extension_setting[field_to_compare] == field_value_to_compare_with:
            extension_setting["incognito"] = incognito_value
            print("Successfully modified file. Now incognito mode value is ", incognito_value)
            break

    with open(google_chrome_preferences, "w+") as jsonFile:
        json.dump(jsonPreferences, jsonFile)

I've tested it using isAllowedAccess. So to suit your needs you need to modify script and provide proper values for field_value_to_compare_with (which actually equals to --load-extension value) and provide correct google_chrome_preferences value. You can use script as :

   extension_incognito_enabled.py true  # to enable
   extension_incognito_enabled.py false # to disable

If you only have python2 simply remove print lines and it should work as well.

j2ko
  • 2,479
  • 1
  • 16
  • 29