您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
This allows you to sort the items in your WaniKani lessons, either putting the Radicals and Kanji first, or the Vocabulary first. By RhosVeedcy, based on scripts originally by Alucardeck.
当前为
// ==UserScript== // @name WaniKani Lesson Ordering II // @namespace https://www.wanikani.com // @description This allows you to sort the items in your WaniKani lessons, either putting the Radicals and Kanji first, or the Vocabulary first. By RhosVeedcy, based on scripts originally by Alucardeck. // @version 1.2 // @include https://www.wanikani.com/lesson/session // @include http://www.wanikani.com/lesson/session // @grant none // ==/UserScript== function get(id) { if (id && typeof id === 'string') { id = document.getElementById(id); } return id || null; } function simulateKeyPressA() { var f4Event = document.createEvent("KeyboardEvent"); var evtTarget = get("lesson"); f4Event.initKeyEvent( "keydown", // event type true, // if your event can bubble true, // if your event is cancelable window, // abstract view (an obscure DOM requirement) false, // if ctrlKey is down false, // if altKey is down false, // if shiftKey is down false, // if the "meta" key is down (usually, the Windows key) 65, // the keyCode -- 65 is keyCode for “a” 65 // the charCode ); evtTarget.dispatchEvent(f4Event); console.log('simulateKeyPressA() keydown'); var f4Event2 = document.createEvent("KeyboardEvent"); f4Event2.initKeyEvent( "keyup", // event type true, // if your event can bubble true, // if your event is cancelable window, // abstract view (an obscure DOM requirement) false, // if ctrlKey is down false, // if altKey is down false, // if shiftKey is down false, // if the "meta" key is down (usually, the Windows key) 65, // the keyCode -- 65 is keyCode for “a” 65 // the charCode ); evtTarget.dispatchEvent(f4Event2); console.log('simulateKeyPressA() keyup'); } function init(){ console.log('init() start'); var stats = $("#stats")[0]; var t = document.createElement('div'); var t2 = document.createElement('div'); stats.appendChild(t); stats.appendChild(t2); t.innerHTML = '<div id="divSt">Click below to reorder lesson items</div>'+ '<button id="reorderBtn" type="button" onclick="window.dispatchEvent(new Event(\'reorderRKevt\'));">Radicals and Kanji first</button>'+ '</div>'; t2.innerHTML = '<button id="reorderVBtn" type="button" onclick="window.dispatchEvent(new Event(\'reorderVevt\'));">Vocabulary items first</button>'+ '</div>'; window.addEventListener('reorderRKevt',reorder); window.addEventListener('reorderVevt',reorderV); console.log('init() end'); } function hideButtons(){ var reorderBtn = get("reorderBtn"); var reorderVBtn = get("reorderVBtn"); reorderBtn.style.visibility="hidden"; reorderVBtn.style.visibility="hidden"; } function reorder(){ console.log('reorder() start'); //var divSt = get("divSt"); //hideButtons(); //divSt.innerHTML = 'Reordering.. please wait!'; var actList = $.jStorage.get("l/activeQueue"); var lesList = $.jStorage.get("l/lessonQueue"); var removedCount = 0; for(var i=0;i<actList.length;i++){ var it = actList[i]; actList.splice(i--,1); lesList.push(it); removedCount++; } console.log('Items removed from ActiveQueue: '+removedCount); for(var i=lesList.length-1;i>=0;i--){ var it=lesList[i]; if(it.kan){ lesList.splice(i,1); lesList.push(it); } } for(var i=lesList.length-1;i>=0;i--){ var it=lesList[i]; if(it.rad){ lesList.splice(i,1); lesList.push(it); } } for(var i=0;i<removedCount;i++){ actList.push(lesList.pop()); } lesList.reverse(); console.log('Ordered LessonQueue:'); for(var i=0;i<lesList.length;i++){ var it=lesList[i]; if(it.rad) console.log('rad '+it.rad); else if(it.kan) console.log('kan '+it.kan); else if(it.voc) console.log('voc '+it.voc); } $.jStorage.set("l/lessonQueue",lesList); $.jStorage.set("l/activeQueue",actList); for(var i=0;i<actList.length;i++){ simulateKeyPressA(); } divSt.innerHTML = 'Ordered: radicals and kanji first'; hideButtons(); console.log('reorder() end'); } function reorderV(){ console.log('reorderV() start'); //var divSt = get("divSt"); //hideButtons(); //divSt.innerHTML = 'Reordering.. please wait!'; var actList = $.jStorage.get("l/activeQueue"); var lesList = $.jStorage.get("l/lessonQueue"); var removedCount = 0; for(var i=0;i<actList.length;i++){ var it = actList[i]; actList.splice(i--,1); lesList.push(it); removedCount++; } console.log('Items removed from ActiveQueue: '+removedCount); for(var i=lesList.length-1;i>=0;i--){ var it=lesList[i]; if(it.voc){ lesList.splice(i,1); lesList.push(it); } } for(var i=0;i<removedCount;i++){ actList.push(lesList.pop()); } lesList.reverse(); console.log('Ordered LessonQueue:'); for(var i=0;i<lesList.length;i++){ var it=lesList[i]; if(it.rad) console.log('rad '+it.rad); else if(it.kan) console.log('kan '+it.kan); else if(it.voc) console.log('voc '+it.voc); } $.jStorage.set("l/lessonQueue",lesList); $.jStorage.set("l/activeQueue",actList); for(var i=0;i<actList.length;i++){ simulateKeyPressA(); } divSt.innerHTML = 'Ordered: vocabulary first'; hideButtons(); console.log('reorderV() end'); } init(); console.log('script load end');