WaniKani Regular Font Guru+

When reviewing items at guru level or higher, the font size is reduced to that of WaniKani's body text (14px)

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         WaniKani Regular Font Guru+
// @namespace    https://www.wanikani.com
// @version      1.0.2
// @description  When reviewing items at guru level or higher, the font size is reduced to that of WaniKani's body text (14px)
// @author       yndajas (they)
// @license      MIT
// @match        https://www.wanikani.com/review/session
// @grant        none
// ==/UserScript==

(function ($) {
  'use strict'

  // create style for Guru+ items

  const originalFontSizeEm = 6.125
  const waniKaniBodyFontSizeRem = 0.875
  const originalHeightEm = 3.21
  const originalHeightRem = originalFontSizeEm * originalHeightEm

  const css =
    'div#question div#character.guru-plus {' +
    `  font-size: ${waniKaniBodyFontSizeRem}rem;` +
    `  line-height: ${originalHeightRem}rem;` +
    `  height: ${originalHeightRem}rem;` +
    '  text-shadow: 0.045rem 0.045rem #0093dd;' +
    '}' +
    '' +
    'div#question div#character.guru-plus img {' +
    `  width: ${waniKaniBodyFontSizeRem}rem;` +
    `  height: ${waniKaniBodyFontSizeRem}rem;` +
    '}'

  const head = document.getElementsByTagName('head')[0]

  if (head) {
    const style = document.createElement('style')

    style.setAttribute('type', 'text/css')
    style.textContent = css
    head.appendChild(style)
  }

  // listen for changes to item and apply style if SRS level is Guru+

  const itemElement = document.getElementById('character')
  const guruPlusClass = 'guru-plus'
  const guruSrsLevel = 5

  $.jStorage.listenKeyChange('currentItem', () => {
    const srsLevel = $.jStorage.get('currentItem').srs
    const classActive = itemElement.classList.contains(guruPlusClass)

    if (srsLevel >= guruSrsLevel && !classActive) {
      itemElement.classList.add(guruPlusClass)
    }

    if (srsLevel < guruSrsLevel && classActive) {
      itemElement.classList.remove(guruPlusClass)
    }
  })
})(window.jQuery)