cschiller / zhongwen

Official source code of the "Zhongwen" Chrome extension
https://chrome.google.com/webstore/detail/zhongwen-chinese-english/kkmlkkjojmombglmlpbpapmhcaljjkde
GNU General Public License v2.0
322 stars 54 forks source link

[Firefox] Settings not retained after clearing cookies and/or offline website data #39

Closed Thomasc5 closed 3 years ago

Thomasc5 commented 4 years ago

To reproduce:

  1. Zhongwen options: Set "display characters in a larger font size"
  2. Firefox: "Clear Recent History..." (includes Cookies and/or Offline Website Data)
  3. Zhongwen font size setting not retained

Capture

p.s. The unofficial fork of zhongwen doesn't have this problem.

Thank you

cschiller commented 4 years ago

I cannot confirm this. It works for me. Please test this again.

cschiller commented 4 years ago

One more question: In your screenshot it looks like you're not clearing the offline website data, but the title of this issue suggests you're clearing the data. Of course, when you're clearing offline website data it won't keep your settings because you're clearing them! So my advice would be: If you want to keep your settings then don't clear them.

Thomasc5 commented 4 years ago

This is how I reproduce the problem:

  1. Change some default settings: A

  2. Enable Zhongwen and it works as expected: B

  3. Disable Zhongwen. Clear everything out in the browser before closing it. C

  4. Wait a few seconds. Launch browser. Go to the same page and enable Zhongwen. The settings would return to default: D

p.s. If the above problem can't be reproduced, try clear the browser and relaunch it a few more times. p.p.s. I had tried the following test cases: 1. clear everything except cookies; 2 clear everything except offline website data. None of these seems to help keeping the Zhongweng's settings. p.p.p.s. Just tested the unofficial fork on the same PC (Firefox 72.0.2 on Win 7), it doesn't have this problem.

Thank you so much.

cschiller commented 4 years ago

It looks like you are clearing your offline website data. This will clear your Zhongwen settings as well. So it works as expected.

Thomasc5 commented 4 years ago

I know nothing about programming. But shouldn't an extension settings be saved somewhere else that they won't get reset when users clear their browsing history?

e.g. "Although this API is similar to Window.localStorage it is recommended that you don't use Window.localStorage in extension code. Firefox will clear data stored by extensions using the localStorage API in various scenarios where users clear their browsing history and data for privacy reasons, while data saved using the storage.local API will be correctly persisted in these scenarios."

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/local

cschiller commented 4 years ago

The problem is, Zhongwen for Chrome - which shares the same codebase with Zhongwen for Firefox -has been using the localStorage API for many years. At the time it was written, the storage.local API didn't even exist. If I were to change it now, then tens of thousands of users would lose their settings. If I were to start all over again, I would use the storage.local API, but making such a critical change that will affect such a large number of users in my opinion is not worth the trouble. I don't know how often you clear your offline website data, probably not on a daily basis. Even so, if the only problem for you is having to change the font size afterwards then I would hope this is acceptable to you.

Thomasc5 commented 4 years ago

The problem is even if I just clear the "cookies" (i.e. leave the offline website data untouched), the settings would still be reset to default.

Capture

Anyway, I understand the dilemma. I'll try figure out how to hardcode the large font size as the default.

Thank you

kondeeza commented 3 years ago

The problem is even if I just clear the "cookies" (i.e. leave the offline website data untouched), the settings would still be reset to default.

Capture

Anyway, I understand the dilemma. I'll try figure out how to hardcode the large font size as the default.

Thank you

If you're still having problem then I suggest checking out Stylus extension (Extension to modify any CSS on the fly). I do not know if user config is persistent after clearing offline website data though. Here's the CSS to increase Zhongwen Lookup Dict size btw

/* Chinese Lookup Dict - Zhongwen */
#zhongwen-window .w-hanzi-small,
#zhongwen-window .w-pinyin-small {
    font-size: 40px !important;
}

#zhongwen-window .w-def-small {
    font-size: 34px !important;
}
cschiller commented 3 years ago

I tested it again with FF 84.0.1. Even when clearing everything (cookies, site preferences and offline website data), after a browser restart all my Zhongwen specific settings are retained.

I'm closing this since I cannot reproduce the problem.