// ==UserScript== // @name WaniKani Review Asc/Desc SRS Order (Radical -> Kanji -> Vocab) // @namespace Mempo // @description Sorts WaniKani reviews by type and ascending or descending SRS level // @version 4 // @include https://www.wanikani.com/review/session // @include http://www.wanikani.com/review/session // @grant none // @downloadURL https://update.greasyfork.icu/scripts/23503/WaniKani%20Review%20AscDesc%20SRS%20Order%20%28Radical%20-%3E%20Kanji%20-%3E%20Vocab%29.user.js // @updateURL https://update.greasyfork.icu/scripts/23503/WaniKani%20Review%20AscDesc%20SRS%20Order%20%28Radical%20-%3E%20Kanji%20-%3E%20Vocab%29.meta.js // ==/UserScript== var indicatorRadKanVoc = true; var indicatorPerSRSLevel = false; function get(id) { if (id && typeof id === 'string') { id = document.getElementById(id); } return id || null; } function init(){ console.log('init() start'); var stats = $("#stats")[0]; var t = document.createElement('div'); t.style = "width: 20vw;" stats.appendChild(t); if(indicatorRadKanVoc){ t.innerHTML = '
'+ ''+ ''+ ''+ '
Rad
Kan
Voc
'; } if(indicatorPerSRSLevel){ t.innerHTML = t.innerHTML + '
'+ ''+ ''+ ''+ ''+ '
Apprentice
Guru
Master
Enlightened
'; } t.innerHTML = t.innerHTML + '
' + ' asc ' + ' desc
' + '
'+ ''+ ''+ ''; $.jStorage.listenKeyChange("activeQueue",displayUpdate); window.addEventListener('reorderWKSingle',reorderSingle); window.addEventListener('reorderWKBulk',reorderBulk); displayUpdate(); console.log('init() end'); } function reorderBulk(){ //Reordering method following original parameters of 10 activeQueue list method = "BULK"; reorder(); } function reorderSingle(){ //Reordering method following the 1 activeQueue list, that makes both reading/meaning coming in pairs. //method = "SINGLE"; //reorder(); try{ unsafeWindow.Math.random = function() { return 0; } }catch(e){ Math.random = function() { return 0; } } reorderBulk(); } function reorder(){ console.log('reorder() start'); //var divSt = get("divSt"); var reorderBtn1= get("reorderBtn1"); var reorderBtn2= get("reorderBtn2"); reorderBtn1.style.visibility="hidden"; reorderBtn2.style.visibility="hidden"; //divSt.innerHTML = 'Reordering.. please wait!'; var cur = $.jStorage.get("currentItem"); var qt = $.jStorage.get("questionType"); var actList = $.jStorage.get("activeQueue"); var revList = $.jStorage.get("reviewQueue"); console.log('current item: '); console.log( cur); console.log('//////////////'); var curt = cur.kan?'kan':cur.voc?'voc':'rad'; var removedCount = 0; for(var i=0;i genius! i=0 except if current item is encountered. revList.push(it); removedCount++; } } console.log('Items removed from ActiveQueue: '+removedCount); var ord = $("input[name=srs]:checked").val() + ""; console.log("/// checked input is: " + ord); var start=-1; var stop=-1; if(ord==="asc"){ for(var srs=10; srs>=0; srs--){ //order in desc SRS for(var i=revList.length-1;i>=0;i--){ var it=revList[i]; if(it.srs==srs){ revList.splice(i,1); revList.push(it); // always push decreasing srs to the end of the queue. Eventually descending order will form. } } } }else{ for(var srs=0; srs<=10; srs++){ //order in asc SRS for(var i=revList.length-1;i>=0;i--){ var it=revList[i]; if(it.srs==srs){ revList.splice(i,1); revList.push(it); // always push increasing srs to the end of the queue. Eventually ascending order will form. } } } } //all asc/desc srs done, item types still mixed //put all kanji at the back var index = 0; //actual index in list. for(var i=0;i>=revList.length-1;i++){ //i is absolute number of reordenings. var it=revList[index]; if(it.kan){ revList.splice(index,1); revList.push(it); //console.log('kan '+it.kan); }else{ index++; } } index=0; for(var i=0;i>=revList.length-1;i++){ //put all radicals at the back var it=revList[index]; if(it.rad){ revList.splice(index,1); revList.push(it); //console.log('rad '+it.rad); } } //Vocab>kanji>rad with vocab at bottom of stack and index=0 //array.pop will give rad, then kanji, then vocab if(method=='BULK') for(var i=0;iApp Store').insertBefore($('.navbar .dropdown-menu .nav-header:contains("Account")')); window.appStoreRegistry = window.appStoreRegistry || {}; window.appStoreRegistry[GM_info.script.uuid] = GM_info; localStorage.appStoreRegistry = JSON.stringify(appStoreRegistry); } catch (e) {} console.log('script load end');