Mozilla サポートの検索

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

詳しく学ぶ

このスレッドはアーカイブに保管されました。 必要であれば新たに質問してください。

How can I delete all data associated with a temporary add-on?

  • 3 件の返信
  • 1 人がこの問題に困っています
  • 11 回表示
  • 最後の返信者: Wesley Branton

more options

I have an add-on which I load via the about:debugging page. This add-on stores data using the localStorage and IndexedDB APIs. If I remove the add-on and then restart Firefox, the data is still there. How can I remove all data associated with an add-on?

I have an add-on which I load via the about:debugging page. This add-on stores data using the localStorage and IndexedDB APIs. If I remove the add-on and then restart Firefox, the data is still there. How can I remove all data associated with an add-on?

すべての返信 (3)

more options

Before you remove the add-on, press the Inspect button in the about:debugging page and then click the Console tab within the tab that opens.

Then enter the following code:

storage.local.clear();
storage.sync.clear();

That clears the data from both the local and sync storage areas.

Hope this helps.

more options

Your answer of course works but is not really satisfactory since it's a bit of a hack, as I'm sure you realize. What if your add-on has a behavior which causes it to modify stored data every few seconds, or continually? Then that wouldn't work.

What I've decided to do is to not give my extension an ID ( remove the `applications.gecko.id` field in the manifest). This seems to cause FF to clear both storage and indexDB when the extension is removed and re-added on the about:debugging screen.

I suppose in a sense, this is the canonical way of doing what I'm trying to do. You set up a development version of your add-on so that Firefox treats it as a fresh install each time, so you can test how it behaves on a fresh machine. It still seems odd that there isn't a way to clear add-on data. Does that mean the data is just going to be sitting there taking up space until I uninstall Firefox? It's only a few hundred KB, but it still seems unfortunate.

more options

Extensions use two main types of storage: Local and Sync.

The local data is stored in your Firefox profile folder. It gets removed if you uninstall your extension or if you are using a temporary extension.

The sync data gets stored on the Firefox Sync cloud, so it's a little more permanent. It stays, even when the add-on is removed. That's why it will come back when you reinstall your extension.

I'm not sure if there's a more efficient way to do it, but if your extension constantly modifies data, it's still possible to clear the data. The method I would probably recommend for your situation is to create a dummy copy of your extension with the same ID. Make sure it's a blank extension that doesn't do anything. Then you can remove your real extension, install the dummy extension and you should be able to run the console commands I put in my above post.

Another alternative would be to include a runtime.onInstalled listener in your background script. It will trigger when you install or update your browser extension. You can include the code that I provided above in there instead to erase the data when the extension is first updated.

Hope this helps.