wshanks / tbkeys

Custom keybindings for Thunderbird
Other
190 stars 13 forks source link

Recover settings from disabled add-on. #178

Open MrQwerky opened 1 month ago

MrQwerky commented 1 month ago

Using Thunderbird 102.15.1. Today tbkeys (not lite) updated, and became disabled because the new version is not compatible with this version of Thunderbird. I've download the tbkeys 2.2.4 .xpi, which I believe is the latest version compatible with this version of Thunderbird. But since the current add-on is disabled, it won't allow me to access its settings. So where are tbkeys setting saved, or how can I recover the current settings before removing the new version of the add-on and installing the 2.2.4 version, and then how to restore those settings?

morat523035 commented 1 month ago

How addon settings are stored http://github.com/wshanks/tbkeys/issues/164

If the tbkeys addon is disabled using the Addons Manager tab, then I can't run the following code snippet to show the extension storage contents using the Debugging tab.

Menu Bar > Tools > Developer Tools > Debug Addons > tbkeys > Inspect

browser.storage.local.get(null).then(function (aResult) {
  console.log(aResult.mainkeys);
  console.log(aResult.composekeys);
});

If the tbkeys addon is removed using the Addons Manager tab, then the data should be removed.

When an extension is removed is anything left behind (see cor-el's comment) http://support.mozilla.com/questions/1412114

As a test, I removed the tbkeys addon, then restarted the app. The <Profile Folder>\storage\default\moz-extension+++<Internal UUID> folder was removed for me.

The following preferences are set to false by default.

Are you saying that you have two tbkeys addons installed? (1 disabled and 1 enabled)

Maybe you could edit the tbkeys@addons.thunderbird.net internal UUID in the extensions.webextensions.uuids pref in the prefs.js file to access the extension storage contents. (just guessing here)

wshanks commented 1 month ago

Sorry about that @MrQwerky. Your experience is the exact opposite of what was supposed to happen which was the addon marking itself as not compatible with older Thunderbird so that the older Thunderbird would not try to install it. I would like to experiment with this and see why tbkeys is updating to an incompatible version. Maybe I will need to roll back that change.

I don't know much beyond what @morat523035 wrote -- basically tbkeys stores its settings in Thunderbird's local storage (a hunk of json stored in a sqlite database, I think). I am surprised that you can't downgrade the tbkeys version and recover the settings. I wonder if you could hack the version number of tbkeys to be a higher version marked as compatible with TB 102 and then access the settings.

morat523035 commented 1 month ago

I hacked manifest.json file in the <Profile Folder>\extensions\tbkeys@addons.thunderbird.net.xpi archive as a test.

- "strict_min_version": "68.0",
+ "strict_min_version": "128.0",
  "strict_max_version": "*",

On startup, tbkeys addon was disabled. There was a yellow notification "tbkeys is incompatible with Thunderbird 115.13.0" in the Addons Manager tab.

Then I replaced the hacked archive with the original archive. On startup, tbkeys addon was enabled, but the Addon Options button was grayed out, so I quickly disabled the tbkeys addon, then enabled it. Now the tbkeys addon works like normal.

tbkeys 2.2.4 (not lite) Thunderbird 115.13.0 Windows 10 Pro 22H2 32-bit

I guess a similar hack should be able to access the extension storage contents for @MrQwerky.

- "strict_min_version": "115.0",
+ "strict_min_version": "68.0",
  "strict_max_version": "*",
MrQwerky commented 1 month ago

Thanks for the replies. I just noticed that the tbkeys add-on which is disabled is shown as version 2.3.0, but there is no way to enable it. This is the only version of the add-on installed at this time. So it seems that TB didn't install the new version (sorry to mislead), but it did disable the old version, and can't be re-enabled.

@morat523035, using Menu Bar > Tools > Developer Tools > Debug Addons, like you, the add-on is not listed, so can't be debugged. I set to TRUE the two preferences which you listed. Does this mean that if I uninstall the add-on, the storage will remain? But how do I find that storage? I can't seem even to find what the UUID for this add-on is, since it is disabled. Is there a way to find the UUID? Okay, I see that in prefs.js the UUID is listed. Now how can I make use of that to find the storage?

Are you saying that I should edit the .xpi file? And that every time TB restarts, it attempts to access that file?

morat523035 commented 1 month ago

In my opinion, the easy method to recover the key bindings would be to hack the manifest.json file in the <Profile Folder>\extensions\tbkeys@addons.thunderbird.net.xpi archive.

tbkeys 2.3.0 manifest.json file http://github.com/wshanks/tbkeys/blob/b7bff64ff0c1df5157fe2ffd307c1fc4f4d6cabc/addon/manifest.json

For example:

wshanks commented 1 month ago

I haven't had a chance to test different scenarios so far. I hope @morat523035's suggestion works. For now, I pulled 2.3.0 from the updates file so clients should stop updating to it. I think the updates file needs to be specifying the minimum Thunderbird version for every add-on release, but I haven't had a chance to test that that solves the problem yet.

MrQwerky commented 1 month ago

@morat523035 Thanks. I followed your procedure, then opened TB and went to the Addons tab. Unfortunately, tbkeys is still disabled. I unzipped the file again and checked the manifest.json file, and it does correctly contain the change in "strict_min_version" that I made as per your instructions.

Apart from that change, the manifest.json file does appear exactly as the one you linked. The manifest from version 2.2.4 which I downloaded, is:

{
  "manifest_version": 2,
  "browser_specific_settings": {
    "gecko": {
      "id": "tbkeys@addons.thunderbird.net",
      "strict_min_version": "68.0",
      "strict_max_version": "*",
      "update_url": "https://raw.githubusercontent.com/wshanks/tbkeys/main/updates.json"
    }
  },
  "name": "tbkeys",
  "description": "Custom Thunderbird keybindings",
  "author": "Will Shanks",
  "version": "2.2.4",
  "background": {
    "scripts": ["background.js"]
  },
  "options_ui": {
    "browser_style": true,
    "page": "options.html"
  },
  "permissions": ["storage"],
  "experiment_apis": {
    "tbkeys": {
      "schema": "schema.json",
      "parent": {
        "scopes": ["addon_parent"],
        "paths": [["tbkeys"]],
        "script": "implementation.js"
      }
    }
  }
}

And the manifest.json from the .xpi that I originally installed the add-on from, is:

{
  "manifest_version": 2,
  "applications": {
    "gecko": {
      "id": "tbkeys@addons.thunderbird.net",
      "strict_min_version": "68.0",
      "update_url": "https://raw.githubusercontent.com/wshanks/tbkeys/main/updates.json"
    }
  },
  "name": "tbkeys",
  "description": "Custom Thunderbird keybindings",
  "author": "Will Shanks",
  "version": "2.2.0",
  "background": {
    "scripts": ["background.js"]
  },
  "options_ui": {
    "browser_style": true,
    "page": "options.html"
  },
  "permissions": ["storage"],
  "experiment_apis": {
    "tbkeys": {
      "schema": "schema.json",
      "parent": {
        "scopes": ["addon_parent"],
        "paths": [["tbkeys"]],
        "script": "implementation.js"
      }
    }
  }
}

Not sure what those differences mean. Also, I see that the tbkeys UUID in prefs.js is different than the UUID in extensions.json; not sure what that means, either.

What is needed is either a way to enable the disabled add-on (sad that the above didn't work), or else to recover the date from where it is restored in the profile. At this point, I have no idea how to do either.

wshanks commented 1 month ago

Hmm, it sounds like what you tried should work. Have you tried downloading the 2.2.4 xpi from the releases page here and using Gear button -> "Install Add-on from File..." to install it? In my testing, when I updated to 2.3.0 and then downgraded in this way, the add-on was enabled again and I was able to access the settings again.

I think I fixed the problem of the add-on updating to an incompatible version with #180.

MrQwerky commented 1 month ago

@wshanks Thank you, thank you, thank you! I just did that, and now tbkeys is once again active, and it seems on first glance that the keybindings are also intact. For good measure, I've set the add-on's "Check for Updates" to off, though I doubt that there will be a new update of the add-on for TB 102.15.1.

MrQwerky commented 1 month ago

So, today tbkeys once again offered to update?

morat523035 commented 1 month ago

It's a good idea not to update your addons if you are using an obsolete version.

Addons Manager tab > Gear icon > [click] Reset All Addons to Update Manually

If any addons have been set to update automatically, clicking this option will reset all addons to update manually.

MrQwerky commented 1 month ago

Understood. That's the setting I use. But each day I click Check for Updates in the gear icon to see if there is anything new. And when I do, it offers to update tbkeys, which I had hoped would no longer be the case when the updated version was incompatible with the TB version?

morat523035 commented 1 month ago

I would use 115.0 not 115 for the strict_min_version value in the updates.json file.

Valid application versions http://addons.thunderbird.net/thunderbird/pages/appversions/

tbkeys updates.json http://github.com/wshanks/tbkeys/blob/main/updates.json

PostGuard updates.json http://github.com/encryption4all/postguard-tb-addon/blob/main/resources/updates.json