Testing Chrome Extensions in Brave

Jonathan Sampson
5 min readOct 5, 2017

--

A while back, I wrote a walk-through showing how developers can test their extensions in Brave. That approach required cloning the repo (which meant you’d need to have git installed), installing dependencies (which meant you’d need to also have node/npm installed), and modifying source files.

In the future, Brave will more easily be able to load arbitrary extensions for the purposes of developing and testing. That support isn’t here today, but this doesn’t mean you have to go through the arduous process mentioned above. Instead, there’s another way — an easier way — to test extensions.

The method of extension-loading that we’ll cover today involves the co-opting of an already-installed extension. We’re going to enable an extension, replace its contents, and have Brave load the modified extension on the next run. My goal is to have Wikiwand working in Brave by the end of this walk-through.

WARNING: I am about to load somebody else’s code into my browser, granting it access to authenticated sessions, potentially sensitive information, and more. I do not encourage this with all extensions. I have, however, reviewed Wikiwand 8.2, and feel safe proceeding.

With that said, let’s begin!

Step 1: Locate Chrome extensions

If you have Chrome installed, and you have your target extension installed already, you can locate it in your Chrome folder:

Windows
%localappdata%\Google\Chrome\User Data\
Default\Extensions

macOS
~/Library/Application Support/Google/Chrome/Default/Extensions

Note that in both cases that my data was in the “Default” folder. This may be different for you.

Step 2: Locate Brave extensions

The next thing we need to do is locate the directory in which Brave extensions reside.

Windows
%appdata%\brave\Extensions

macOS
~/Library/Application Support/brave/Extensions.

Chrome and Brave extension folders shown side-by-side

Step 3: Ready the Trojan Horse

As mentioned in the third paragraph of this walk-through, we’ll need to enable an extension that will serve as our Trojan Horse. I am not presently using Honey, so I will use it moving forward.

Navigate to about:preferences#extensions in Brave, and toggle Honey on. At this point, Brave will begin to download the extension in the background. Depending on your connection speed, this could take a few seconds, or up to a minute. For reference, Honey 9.7.7 is roughly 1.3 MB.

Enabling the Honey extension in Brave

Once downloaded, the extension may trigger a new tab, or some other type of UI change. Disregard these cues, and close Brave completely.

At this point, we should see a new folder in the Brave extensions directory named after the Honey ID: bmnlcjabgnpnenekpadlanbbkooimhnj. Immediately within this folder will be a version-folder, with a name like 9.7.7. We want to rename this folder to 9.7.7x (note the addition of a trailing ‘x’).

Renaming the Honey version folder to include a trailing ‘x’

Step 4: Load your extension

I am now one step away from loading Wikiwand into Brave. All that is needed is to copy the extension from the Chrome directory, and paste it into the Brave directory, giving it the name 9.7.7 (note here how we are co-opting the original folder name).

Note also that the Chrome extension directory has the same structure as the Brave extension directory — a list of folders (named according to extension IDs), which contain 1 or more folders (named according to version numbers). You want to copy/rename the version-number folder.

Copying Google’s Wikiwand into Brave’s Honey folder

All that’s left now is to launch Brave, and visit Wikipedia.

Wikiwand working in the Brave browser

Step 5: Cleaning up afterwards

It’s important to note that this walk-through is not a tutorial on loading extensions into Brave for long-term use. Instead, our goal was to quickly test an extension for compatibility.

When you’ve tested the extension, and have shared a list with the Brave team of scenarios that don’t work, it’s time to tear-down our work and restore Brave to its initial state. Fortunately, this is very simple to do.

Visit about:preferences#extensions and toggle-off your extension. Next, delete the folder we used as our Trojan Horse; in our case, it was the Honey folder with the id bmnlcjabgnpnenekpadlanbbkooimhnj.

Restart Brave, and you’re done.

Summary

Let’s wrap this up with a quick summary to drive home the first 4 steps above. We are able to load Wikiwand into Brave by co-opting the path of an already-enabled extension in Brave (Honey, in this case).

By replacing the contents of a loaded-extension with the contents of another extension, we’re able to get Brave to load the unsupported extension. This allows us to more easily test arbitrary extensions for support.

Caveats

I should mention that this approach, while largely reliable, has some hypothetical limitations. I say hypothetical because I have yet to encounter them―but I’m sure somebody will.

When you load an extension via these means, the extension will not have its correct ID. If you load an extension using Honey as the trojan horse, your extension will continue to have the Honey ID. If your extension attempts to query its own ID (via chrome.runtime.id for example), it will not get back the expected value.

Closing Comments

As always, I’m happy to assist with any questions you may have about this process. You can find me on Twitter as @jonathansampson. If you test an extension, and find it to be working quite well, shoot me a message. Perhaps we can fast-track it to getting official support in Brave.

--

--

Jonathan Sampson

Internetting since 90's. Stack Overflow Moderator from 2010-2013. Passionately tending to HTML, CSS, and JavaScript's needs. Ex-Microsoft. Engineer at Brave.com