您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Shows the context sentence in the question during vocab reviews.
当前为
// ==UserScript== // @name WaniKani Context Sentences in Reviews // @namespace nelemnaru // @description Shows the context sentence in the question during vocab reviews. // @include *://www.wanikani.com/review/session* // @version 1.9 // @grant none // ==/UserScript== //Here you can change the scaling factor of the brightly-colored (purple, pink, blue) question area. Set to 0.75 for 75%. Default is 1 (which is 100%, no rescale). var rescale = 1; //Here you can set the vocab word to be highlighted in the sentence by setting to true. Default is false (no highlighting). var highlightword = false; //Here you can set the context sentence to only appear after a correct answer by setting to true. Default is false (show sentence all the time). var showaftercorrect = false; $("#character").wrap("<div style='font-size:" + rescale + "em'></div>"); $("#question-type").prepend("<div id='sentwrap' style='font-size:1.5em'><div id='sentj'></div><div id='sente'></div></div>"); $("#question-type").click(function() {//set to #question-type to make entire (black/white) bar clickable if ($.jStorage.get("questionType") === "meaning") { $("#sente").toggle(); } }); var current_item, japanese, english, jvoc, previous_item; //Show sentence after correct answer if (showaftercorrect) { $("#answer-form form button").on("click",function() { setTimeout(function(){ if (current_item.voc !== undefined && $("#answer-form form fieldset").hasClass("correct")){$("#sentwrap").show();} }, 100); }); } $.jStorage.listenKeyChange('currentItem', function() { $("#sente").hide(); if (showaftercorrect) {$("#sentwrap").hide();} current_item = $.jStorage.get('currentItem'); if (previous_item !== current_item.voc) { $("#sentj").html(" ");//blank sentence area while fetching json } else if (highlightword) {//immediately change highlight color when sentence stays same (smooth transition in Single Mode) if ($.jStorage.get('questionType') == "reading") {$(".highlighted").css({"color":"#2e2e2e","background-color":"#fff"});} if ($.jStorage.get('questionType') == "meaning") {$(".highlighted").css({"color":"#e9e9e9","background-color":"#555"});} } previous_item = current_item.voc; /*Following is code courtesy of rfindley to fetch sentences*/ // 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); }); /*End of code by rfindley*/ $("#sentj").html(japanese); $("#sente").html(english); if (highlightword) { jvoc = current_item.voc; while (japanese.indexOf(jvoc) === -1) { if (jvoc.length == 1) {console.log("Search failed");break} jvoc = jvoc.slice(0,jvoc.length - 1); } $("#sentj").html(japanese.replace(new RegExp(jvoc,'g'),"<span class='highlighted' style=text-shadow:none>"+jvoc+"</span>")); if ($.jStorage.get('questionType') == "reading") {$(".highlighted").css({"color":"#2e2e2e","background-color":"#fff"});} if ($.jStorage.get('questionType') == "meaning") {$(".highlighted").css({"color":"#e9e9e9","background-color":"#555"});} } }); } else { $("#sentj").html(""); $("#sente").html(""); } });
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址