[Userscript] Forum and some websites: Prioritize Japanese glyphs (Han unification)

:warning: This is a third-party script/app and is not created by the WaniKani team. By using this, you understand that it can stop working at any time or be discontinued indefinitely.

It appears that forcing font can be quite overdone and unbeautiful. (Also, an ugly way to avoid styling code using !important.)

Anyway, my UserScript is born. Get it here - Wanikani Community Prioritize Japanese Glyphs.

// ==UserScript==
// @name         WaniKani Community prioritize Japanese glyphs
// @namespace    https://github.com/patarapolw
// @version      0.1.3
// @description  Prioritization of Japanese glyphs for Han unification
// @author       polv
// @license      MIT
// @match        https://community.wanikani.com/*
// @icon         https://www.google.com/s2/favicons?domain=community.wanikani.com
// @grant        none
// ==/UserScript==

(() => {
  function injectLangHTML(lang) {
    // I might not need to use MutationObserver at all...
    const obs = new MutationObserver(() => {
      if (document.documentElement.lang !== lang) {
        document.documentElement.lang = lang;
      }
    });
    obs.observe(document.documentElement, { attributeFilter: ["lang"] });

    // Only this part is the real thing.
    document.documentElement.lang = lang;
  }

  injectLangHTML("ja-JP");
})();

Edit: It appears to be extremely simple. Only <html lang="en"> needs to be edited. (And <html lang="ja"> doesn’t work in Firefox for Arch Linux for some reasons.)

2 Likes