Configure Chrome Extension at Runtime - google-chrome

We're currently building multiple copies of our Chrome CRX, one for each of our dev/test environments, with custom entries in each manifest file.
Often we don't know in advance the hostname of certain test environments prior to building/packaging our code & crx. Is there a way to pass parameters to a Chrome Extension, or have my Extension read its own filename to look for a naming convention etc.

There is no way to pass arguments to CRX or read extension filename, but you can change extension variables in runtime using Developer Tools console.

Related

Chrome APIs for packaged apps - need access to bookmarks, cookies, history, etc

I am the author of a Firefox extension named FEBE (Firefox Environment Backup Extension) and would like to port it to Chrome. Before I get too far into it, I have a few questions.
FEBE relies heavily on low-level APIs (XPCOM) that allow unfettered access to manipulate most browser components - extensions, cookies, bookmarks, user login/passwords, history, etc. I've noticed so far that chrome.bookmarks, chrome.cookies, and chrome.history seem to be only available to extensions, and chrome.fileSystem only to apps. Because of this, I envision the chrome counterpart of FEBE to be a hybrid extension/packaged app that communicates through chrome.runtime.sendMessage. Since chrome bookmarks are stored as JSON files and cookies, history and others are stored as SQL files, I suppose I could also manage them with my own javascript code and release it as an app only. Is this allowed? By this I mean do developers have to use chrome apis exclusively or can they write their own.
I could also probably repackage a user's extensions into crx files, but does chrome allow the installation of local crx files (i.e., restoring backed up extensions from a local drive)?

Chrome Devtools API: Programmatically mapping files to local workspace via SourcesPanel

I'm curious whether Chrome's Devtools API allows for programmatically mapping served files to local workspaces. I imagine that this would involve a) getting a list of served files and b) matching that up with similarly named files in the local workspace.
Accessing the SourcesPanel seems easy enough, but the functionality seems limited. Am I missing something?
Screenshot for clarity

Disable update of specific chrome extension

With recent news of adblock being sold to some unknown company, first thing i want to do is disable any possible update for that extension.
I've found number of questions but they are outdated. So chrome pros please tell how do we disable a specific plugin? and please take into consideration that there are many instances which synchronize it is important that the change gets synchronized to other computers, if it is not how do we do that?.
And a secondary question : where do we find sources of already installed extension? so that we could later pack and run it?
Chrome does not offer a way of disabling an update for a specific extension.
If you want to make sure that you run some specific version of an extension, you could try any of the following options:
Read-only extension folder
Go to the directory containing the extension, and mark the directory as read-only. To find that directory, visit chrome://version and look at the path at "Profile Path". The extension will then be at [value of Profile path]/Extensions/[32-character extension id].
Download the source code
Download the source code of the extension, and load it as an unpacked extension (or upload it to the Chrome Web store, and then install it).
There are several ways to get the source code (including just copying it from the directory as I mentioned at the previous step).
If you want to download a Chrome extension without installing it (e.g. because the new version contains unwanted "features" that you want to remove), then you could use my Chrome extension source viewer to download the code.
Some extensions expect to be run with a specific extension ID. You can forge this extension ID if you load the extension in unpacked mode (but you cannot upload the extension to the CWS if you do that). For instructions on fixing the extension ID, see How to change chrome packaged app id Or Why do we need key field in the manifest.json?.

Chrome Extension / JavaScript Bookmarklet to trigger local script

I programmed a local script to extract screenshots. The script takes an url as input parameter. Now I'd like to make a plugin/bookmarklet to trigger this local script which is located in c:/scripts/myscript.bat. Is this anyhow possible?
The question is rather broad; so the answer is similarly broad.
It is possible with a Chrome Extension, if you use Native Messaging. This is a shining-new documentation with fresh examples, thanks to Rob W.
It lets you execute a local program (as defined in the registry) and communicate with it over stdio. Unfortunately, you can't pass a command line parameter to it; you will have to implement the JSON-based protocol Chrome uses.

Chrome extension API to manipulate other installed Chrome extensions?

I'm writing a Google Chrome extension that needs to do a lot of things with other extensions, such as:
List installed extensions and read their IDs
Request extension installation, update and removal (preferably without bothering the user)
Modify extension settings
and so on. Which of these are possible, and which are not (due to e.g. security considerations)?
P.S. I haven't been able to find answers in the inter-extension messaging section of the official docs (or anywhere else, actually).
You can do most of those things today with chrome.management API. For example:
Get a list of information about installed extensions and apps:
chrome.management.getAll(function callback)
Uninstall a currently installed app or extension:
chrome.management.uninstall(string id, object options, function callback)
Chromium developer Brian Kennish states here suggests writing an NPAPI plugin as the most rational option to achieve the desired effect.
This is not directly possible via the extension API. To be honest, I wouldn't recommend using NPAPI for this either since you'd have to modify files which are in-use by the browser, which is unreliable at best.