karsttech.com/content/personal-blog/modifying-firefox-extensions/index.md

63 lines
3.1 KiB
Markdown

+++
title = 'Modifying A Buggy Browser Extension'
description = '1Password has been misbehaving lately, lets fix it!'
date = 2026-01-06T16:20:00-05:00
draft = false
categories = ['guides']
tags = ['Firefox', 'Browser Extensions', '1Password']
disableToc = false
+++
# The 1Password browser extension has been misbehaving lately... lets fix it!
<!--more-->
The problem that I have been having is a recent bug introduced into 1Password where it will not autofill on local http websites. The reason for this is a problem importing window.crypto.randomUUID() within a non-secure context and is outlined [here](https://www.1password.community/discussions/1password/re-enable-auto-fill-for-localhost-local-ip-network-device-websites/165052).
This guide will walk you through how to fix this issue, and also how to modify other Firefox extensions.
## Step 1: Figure out where your Firefox profile is stored
Open a new firefox tab and type **about:support** into the url bar. Then find the **Profile Directory** section and click the **Open Directory** button.
![Firefox about:support](firefox-profile-dir.png)
## Step 2: Extract the extension
Within the Firefox profile directory, go into the **extensions** folder and you will find one .xpi file for each extension you are using in Firefox. One of these extensions will be the one you want.
![Firefox Profile Extensions](extensions-folder.png)
I have found the easiest way to figure out which .xpi file is correct is to open them up in an archive manager (you can rename the file to *.zip first if you want), then check inside the **credits.html** file.
![Extension Archive](extension-archive.png)
The extension name is near the top under &lt;meta content=[EXTENSION_NAME]/&gt;
![Credits HTML](credits-html.png)
## Step 3: Edit the extension
To solve our particular problem, extract this whole .xpi file into a new folder. We will want to edit the /[Folder Name]/inline/injected.js file.
Open a new terminal window here (in the folder with injected.js) and run:
```sh
sed -i 's/QDe=yte==="client"?window\.crypto\.randomUUID()\.slice(0,8):void 0/QDe=yte==="client"\&\&window.crypto.randomUUID?window.crypto.randomUUID().slice(0,8):void 0/g' injected.js
```
This uses sed to find and replace a string. We are replacing the existing call to window.crypto.randomUUID() to a ternary operator which will check if window.crypto.randomUUID exists and if so use it, if not fall back to void 0 (undefined) which will cause the existing 1Password code to fall back to a counter-based ID instead.
Note that this sed statement will not work if the 1Password extension significantly changes, so you may need to modify it. Hopefully if the extension changes it means the maintainers have fixed this bug and we don't need to do this in the first place!
## Step 4: Add the modified extension into Firefox
In a Firefox tab go to **about:debugging#/runtime/this-firefox**
Click the **Load Temporary Add-on** button.
![Temporary Addon](load-temporary-addon.png)
Load the addon by pointing to your **/[Folder Name]/manifest.json** file.
1Password should now offer to autofill on http websites as normal.
All done!!!