Open SakuraiNaomi opened 2 years ago
是說,如果用 1.5 版本就完全可以正常運作嗎?
因為我只有用自動轉換,bbs網站上的簡體字的確有轉換成繁體字, 其他功能不敢保證正常,68.11裝上1.5同一頁面這樣子才能啓動
你的 BBS 是指 term.ptt 還是純網頁。因為敘述看起來我不是很容易理解。 或是方便的話,請你稍微一小段影片展示兩個版本之間的差異,這樣比較觀察你碰到的是什麼問題。 目前 Github 已經支援上傳影片。
3dots > Addon > Addon Manager > 新同文堂 > 設定 2.1.4版白色頁面無法選擇自動轉換以啟動同文堂功能 1.5版正常
不確實是不是用了新語法導致錯誤,還需要再詳細研究。
(不好意思, 在 GitHub 上面我比較習慣使用英文 - 如果有寫不清楚的地方, 我可以再用中文說明)
I tried to fix the extension with these changes - not sure if these are the proper fixes we need, but at least on my phone the option page would not crash, and the auto-translation (from simplified Chinese to traditional Chinese) now works:
Firefox
on Android
does not support contextMenus
/ commands
. So, I am afraid that they would not work on mobile phones, but I am not sure how we should handle that either.New TongWenTang 2.1.6
Firefox Nightly (107.0a1)
Google Pixel 6
Android 13
I had tried to debug the extension with Firefox Nightly
based on this instruction and I had found that there are few errors preventing the extension from working on Android
Uncaught TypeError: can't access property "autoConvert", n is undefined
. when opening the option pageAfter some investigation, I think the error is thrown from here (GeneralSettings.tsx#L16
) and general
is undefined
.
I am suspecting that the general
object got overwritten to undefined
here (use-general-opt.ts#L38
) when the effect hook try to read the value from storage when the storage is empty (please correct me if I am wrong).
I think we can probably fix this by either:
<GeneralSettings />
(please see this for details: https://github.com/htbkoo/tongwentang-extension/compare/master...htbkoo:tongwentang-extension:fix-android-fenix-check-before-setting-value?expand=1)general
at use-general-opt.ts
if the value is undefined
(please see this for details: https://github.com/htbkoo/tongwentang-extension/compare/master...htbkoo:tongwentang-extension:fix-android-fenix-optional-chaining)Context Menu
option page and Word
option page failed to loadUnfortunately, the Context Menu
option page and Word
option page also failed to load.
Similarly, I had tried to fix them by avoid setting the value if the value is undefined
(Please see this commit for details: https://github.com/htbkoo/tongwentang-extension/commit/e3bf1e5b116837f356cb5b89efb153ff8a35c3ce)
After applying the above fixes, the option page would work but the translation still failed to run.
And I found that it is because the background script did not successfully run because some of the features (e.g. contextMenus
; commands
) are unsupported on Android
Firefox
and some functions
are undefined
(e.g. commands.onCommand
; browser.contextMenus.create
; browser.contextMenus.remove
).
FYI, this is also hinted by the warnings by Firefox
that some of the fields in manifest.json
(e.g. permissions
.contextMenus
; commands
) are unsupported
I ended up trying to fix the issue by adding optional chaining for all offending usages. (Please see this for details: https://github.com/htbkoo/tongwentang-extension/compare/fix-android-fenix-other-options-pages-error...htbkoo:tongwentang-extension:fix-android-fenix-background-script)
tabs.detectLanguage
is not a functionThis is quite strange but somehow tabs.detectLanguage
is undefined
on my Firefox
and that was the last obstacle that blocked the extension from working.
In order to fix the issue, I added a try-catch
around the usage and similarly defaulted the language to ZhType.und
when there is any error caught (Please refer to this commit for details: https://github.com/htbkoo/tongwentang-extension/commit/973f7d7464bb8e00589c98e04500a80f03487f57)
Please let me know if you need more information.
Thank you!
Just another small updates for your information:
I ended up switching to use the Kiwi Browser (kiwibrowser/src) instead.
And the extension just works out of the box (note that Kiwi Broswer provides native support for extensions).
So I guess the issues are exclusive for Fenix
on Android
. 🤔
first of all, thank you so much for giving such helpful and detail debug information 🙏
I think they removed the contextMenu completely from the mobile (I checked the MDN, can't find the contextMenu anymore...) also, the mobile browser has very limited APIs
using the contextMenu instead of menu is for better compatibility (chromium based browser do not support it, but I think they do now)
I.
I think the error is because the mobile doesn't support the sync storage, so end up the extension got the undefined
.
II.
if the chromium based browser did support the menu
APIthen I think replace the
contextMenuwith
menu` can resolve many error.
III. we can skip the command setup if the runtime is mobile.
IV. same, we can skip the lang detect if the runtime is mobile.
you information is helpful, I think we can solve the problems accurately. (adding optional chaining make the code smell, I don't think sweep the errors under the carpet is a good idea lol)
Has there been any progress on this? I'd love to switch to Firefox but am stuck on Kiwi as it's the only way for me to use this extension.
Even if the extension settings page isn't fixed to work on mobile, I would still be happy to at least know if a workaround to set the auto-convert mode on
hi @null-von-sushi the current target is MV3 migration. will take a look after the migration.
Firefox Android 68.11 Firefox Android Nightly 83.0a1 和 97.0a1 都相同情况,頁面只看見半秒就轉成全白不能選自動轉換 68.11最後一版不像Nighly加Collection必定只能加入最新2.1.4 放回同文1.5頁面就正常出來了
有爬過一會Closed issue知道作者繁忙,但是68已經有好些網站 不能正常運作,也花了一周沒找到好的替代方案... 祝聖誕快樂 :D