mikesteele / dc2

12 stars 1 forks source link

Firefox support #21

Open siikamiika opened 5 years ago

siikamiika commented 5 years ago

I tried to install dc2 on Firefox, but got this message when togging on/off:

Dual Captions not found on page. Are you on YouTube or Netflix? Please try refreshing the page.

I can try to gather more information later, but is there any information about possible things breaking on Firefox?

mikesteele commented 5 years ago

Hey! I haven't tried using dc2 on Firefox, so I'm not sure if it will work. MDN has a compatibility page for Chrome extensions here (https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Chrome_incompatibilities) but I don't see anything that would be an issue.

That error specifically means that the content_script didn't respond when the popup asked it to turn on. Check if there are any errors in the console of the page on Netflix to see if the content_script bundle is throwing errors. If not, some part of dc2 might not work with Firefox. (I recommend Chrome)

siikamiika commented 5 years ago

Thanks for the tips! I'll see tomorrow if there's an obvious thing preventing the content script from responding. I'm using Chrome for displaying Chinese and English subtitles on Netflix currently, and I even got my OCR script working together with that. :smile: I believe that multiplatform support adds value to products although debugging incompatibilities can be frustrating sometimes. Anyway it makes sense to stick to one platform in the early stages to focus on developing the core idea instead of maintaining compatibility.

mikesteele commented 5 years ago

Oooh OCR script? Post a link if it's public, I'd love to take a look :-)

If I understand correctly you have dc2 working on Chrome, then? What are your thoughts? Any bugs? I'd like to release v2 some time soon, just been busy.

siikamiika commented 5 years ago

This one: https://github.com/siikamiika/scripts/tree/master/netflix-sub-ocr It's quite accurate although it runs locally because the Netflix subtitle images are quite high quality, but I haven't figured out yet why it can't read images with 1-2 characters so well. I also have a script that lets me seek 2 seconds instead of the default 10 and pause when I move mouse outside of the video player https://github.com/siikamiika/scripts/blob/master/netflix/netflix-extra-keybinds.user.js

dc2 works great once I first swap the subtitles to English from Netflix, select English from dc2 menu, and then switch back to Chinese from Netflix. I sometimes see a bug where the English text is missing a space in the middle (that's presumably been a line break before): 2019-08-05_08-21-08 It feels like the missing piece, because now I don't have to use full text machine translation on the OCR'd text when I don't understand a sentence based on single word translations alone (Google Translate was horrible most of the time). Great software :+1:

mikesteele commented 5 years ago

Thanks a lot for the feedback. :-) Send me a link to that video and I'll figure out why sometimes English is missing a line break, should be a quick thing to fix.

siikamiika commented 5 years ago

That particular caption is from 流星花园 episode 5 around 19:36. You might have to change your Netflix language to Chinese to get Chinese subtitles if the bug doesn't reproduce otherwise.

Here's a quick glossary for navigating the UI if you're not familiar with Chinese characters :smile: Subtitle names: 简体中文 = Simplified Chinese 英文 = English

Settings, for switching back to English: 帐户 = account 语言 = language

mikesteele commented 5 years ago

Fixed in PR #22 :-)

Capture d’écran 2019-08-05 à 21 38 47

Keep an eye on the repo as I want to make some UX improvements in the coming weeks and release v2.

siikamiika commented 5 years ago

Thanks a lot! I get a line break now too after updating.

I added myself as a watcher to this repo so I'll get a notification for any updates. It's exciting to follow the development of useful language learning tools closely because I've also written some in the past :D

siikamiika commented 5 years ago

Sorry for the long break, but I finally tried and managed to get dc2 to work on Firefox. The problem was accessing chrome behind the window namespace instead of global or simply chrome in the content script. Do you want me to create a pull request with a fix for Firefox? :)

mikesteele commented 5 years ago

Nice find, thanks :-) A PR would be great!

I was referencing chrome via window because of JSDOM which I'm using for testing. There aren't a lot of tests in this repo yet, but I think replacing window.chrome with global.chrome in src/tests/chrome-mock.js would fix tests. You can try by running yarn test.

siikamiika commented 5 years ago

I looked at the tests and they ran with both window.chrome and global.chrome, but if I understood the code correctly, src/tests/chrome-mock.js was testing the background page instead of the content scripts so I didn't change window to global in tests. I can still change it for the pull request if needed, though.