WaniKani Context Sentences in Reviews

Shows the context sentence in the question during vocab reviews. For Meaning questions, click to show English sentence.

当前为 2017-01-30 提交的版本,查看 最新版本

// ==UserScript==
// @name        WaniKani Context Sentences in Reviews
// @namespace   nelemnaru
// @description Shows the context sentence in the question during vocab reviews. For Meaning questions, click to show English sentence.
// @include     *://www.wanikani.com/review/session*
// @version     1.5
// @license     Please improve and repost!
// @grant       none
// ==/UserScript==


//Here you can change the scaling factor of the brightly-colored question area
var rescale = 0.75;


$("#character").wrap("<div style='font-size:" + rescale + "em'></div>");
$("#question-type").prepend("<div style='font-size:1.5em'><div id='sentj'></div><div id='sente'></div></div>");
$("#question-type").click(function() {
  if ($.jStorage.get("questionType") === "meaning") {
    $("#sente").toggle();
  } 
});

var japanese, english;

$.jStorage.listenKeyChange('currentItem', function() {

  $("#sente").hide();

//Following is code courtesy of rfindley
  var current_item = $.jStorage.get('currentItem');

  // Only vocab has context sentences.
  if (current_item.voc !== undefined) {
      var url = '/json/vocabulary/' + current_item.id;

      // Grab the item info from WK server.  Process result when it arrives.
      $.getJSON(url, function(json) {
          // Extract the sentences from the item info.
          var context_sentences = json.sentences;
          //console.log('Sentences for ' + current_item.voc + ':');

          // Output each sentence to the console.
          $.each(context_sentences, function(idx, sentence) {
              japanese = sentence[0];
              english = sentence[1];
              //console.log('  J: ' + japanese);
              //console.log('  E: ' + english);
          });
      $("#sentj").html(japanese);
      $("#sente").html(english);
      });
  } else {
      $("#sentj").html("");
      $("#sente").html("");
  }

});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址