Skip to content

Instantly share code, notes, and snippets.

@varenc
Forked from klausondrag/README.md
Created May 5, 2020 07:01
Show Gist options
  • Save varenc/397794631f644679d031c30d9f88df9e to your computer and use it in GitHub Desktop.
Save varenc/397794631f644679d031c30d9f88df9e to your computer and use it in GitHub Desktop.
Pinyin support for Language Learning with Netflix Extension

First, you need to install this extension: https://chrome.google.com/webstore/detail/requirify/gajpkncnknlljkhblhllcnnfjpbcmebm/related

Then:

  1. Go to netflix.com and start a movie
  2. Press the extension button so that "On" is displayed
  3. Open developer tools by pressing F12
  4. If not selected, go to the Console tab
  5. Execute require("ctp", "chinese-to-pinyin");
  6. Wait until you see Finished getting chinese-to-pinyin
  7. Execute
let subtitlesSelector = ".lln-subs-font-adjust";
$("body").on('DOMSubtreeModified', subtitlesSelector, function() {
    $(subtitlesSelector).find("span").each(function() {
        let oldText = $(this).text();
        let newText = ctp(oldText);
        if (oldText !== newText) {
            $(this).text(newText);
        }
    });
});
  1. Press F12 again to close the developer tools
  2. Enjoy the movie!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment