// ==UserScript== // @name Wanikani Reorder Ultimate 2 BETA // @namespace https://www.wanikani.com // @description Learn in the order you want to. // @version 2.0.201 // @include *://www.wanikani.com/lesson/session* // @include *://www.wanikani.com/review/session* // @grant none // @downloadURL none // ==/UserScript== (function ($) {$.each(['hide', 'addClass'], function (i, ev) { var el = $.fn[ev]; $.fn[ev] = function () { this.trigger(ev); return el.apply(this, arguments); }; }); })(jQuery);/* * HTML5 Sortable jQuery Plugin * http://farhadi.ir/projects/html5sortable * * Copyright 2012, Ali Farhadi * Released under the MIT license. */ (function(e){var t,n=e();e.fn.sortable=function(r){var i=String(r);r=e.extend({connectWith:false},r);return this.each(function(){if(/^enable|disable|destroy$/.test(i)){var s=e(this).children(e(this).data("items")).attr("draggable",i=="enable");if(i=="destroy"){s.add(this).removeData("connectWith items").off("dragstart.h5s dragend.h5s selectstart.h5s dragover.h5s dragenter.h5s drop.h5s")}return}var o,u,s=e(this).children(r.items);var a=e("<"+(/^ul|ol$/i.test(this.tagName)?"li":"div")+' class="sortable-placeholder">');s.find(r.handle).mousedown(function(){o=true}).mouseup(function(){o=false});e(this).data("items",r.items);n=n.add(a);if(r.connectWith){e(r.connectWith).add(this).data("connectWith",r.connectWith)}s.attr("draggable","true").on("dragstart.h5s",function(n){if(r.handle&&!o){return false}o=false;var i=n.originalEvent.dataTransfer;i.effectAllowed="move";i.setData("Text","dummy");u=(t=e(this)).addClass("sortable-dragging").index()}).on("dragend.h5s",function(){if(!t){return}t.removeClass("sortable-dragging").show();n.detach();if(u!=t.index()){t.parent().trigger("sortupdate",{item:t})}t=null}).not("a[href], img").on("selectstart.h5s",function(){this.dragDrop&&this.dragDrop();return false}).end().add([this,a]).on("dragover.h5s dragenter.h5s drop.h5s",function(i){if(!s.is(t)&&r.connectWith!==e(t).parent().data("connectWith")){return true}if(i.type=="drop"){i.stopPropagation();n.filter(":visible").after(t);t.trigger("dragend.h5s");return false}i.preventDefault();i.originalEvent.dataTransfer.dropEffect="move";if(s.is(this)){if(r.forcePlaceholderSize){a.height(t.outerHeight())}t.hide();e(this)[a.index()An error has occurred within WaniKani Reorder Ultimate. Please post the error below on the forum thread.
https://www.wanikani.com/chat/api-and-third-party-apps/8471

' + err + '
' + err.stack + '

Logs:
' + console.dlog.join('
') + ''); } }, update: { apply: function() { try { utilities.log("Applying UID levels"); var queue = $.jStorage.get(dataset.active).concat($.jStorage.get(dataset.queue)); var current = $.jStorage.get('currentItem'); var list = $.jStorage.get('uids') || []; $.each(queue, function() { this.level = list[utilities.toUID(this)] || 0; if (current && utilities.toUID(this) === utilities.toUID(current)) { $.jStorage.set('currentItem', this); } if (activeLevels.indexOf(this.level) == -1) { activeLevels.push(this.level); } }); activeLevels.sort(function(a, b) { return a - b; }); var review = queue.splice((dataset.quick === 'r' ? 10 : $.jStorage.get('l/batchSize'))); $.jStorage.set(dataset.active, queue); $.jStorage.set(dataset.queue, review); dataset.updateVisual(); } catch (err) { $('#supplement-info, #information').first().after('
An error has occurred within WaniKani Reorder Ultimate. Please post the error below on the forum thread.
https://www.wanikani.com/chat/api-and-third-party-apps/8471

' + err + '
' + err.stack + '

Logs:
' + console.dlog.join('
') + '
'); } }, check: function() { try { utilities.log("Checking for UID updates"); var all = $.jStorage.get(dataset.queue).concat($.jStorage.get(dataset.active)); var list = $.jStorage.get('uids') || []; return list && all.every(function(ele) { return ele && list[utilities.toUID(ele)]; }); } catch (err) { $('#supplement-info, #information').first().after('
An error has occurred within WaniKani Reorder Ultimate. Please post the error below on the forum thread.
https://www.wanikani.com/chat/api-and-third-party-apps/8471

' + err + '
' + err.stack + '

Logs:
' + console.dlog.join('
') + '
'); } }, patch: function() { try { utilities.log("Gathering data for patch"); var count = 0; var all = {}; $('#information, #supplement-info').first().after('
WKU::Please Wait::Currently updating UID list... 0%
'); ["radicals", "kanji", "vocabulary"].forEach(function(ele1, ind1, arr1) { ["PLEASANT", "PAINFUL", "DEATH", "HELL", "PARADISE", "REALITY"].forEach(function(ele2, ind2, arr2) { $.get('https://www.wanikani.com/' + ele1 + '?difficulty=' + ele2, function(resp) { $('#id-percent').text(Math.round((++count / (arr1.length * arr2.length)) * 100) + "%"); $(resp).find('section[id^=level-]').each(function() { var level = $(this).attr('id').replace(/[^\d]/g, ""); $(this).find('.character-item').each(function() { var a = $(this).attr('id'); a = a.substr(0, 1) + a.replace(/[^\d]/g, ""); all[a] = level; }); }); if (count >= (arr1.length * arr2.length)) { $.jStorage.set('uids', all); utilities.log("DONE!"); $('#updateUID').remove(); setup.ui.create(); } }).fail(function() { $('#supplement-info, #information').first().after('
WaniKani Reorder Ultimate has failed to load [' + ele2 + ' level ' + ele1 + ']
Please reload the page.
'); }); }); }); } catch (err) { $('#supplement-info, #information').first().after('
An error has occurred within WaniKani Reorder Ultimate. Please post the error below on the forum thread.
https://www.wanikani.com/chat/api-and-third-party-apps/8471

' + err + '
' + err.stack + '

Logs:
' + console.dlog.join('
') + '
'); } } }, ui: { create: function() { setup.update.apply(); $('head').append(''); $.get('https://gist.githubusercontent.com/xMunch/a448f5999a682f114d61/raw/UI.HTML', function(data) { utilities.log("Creating UI..."); var info = $('#supplement-info, #information').first(); info.after(data); $('#version').text("v" + GM_info.script.version); if (dataset.quick === 'l') { $('.ui').find('#r-only').remove(); } if (!setup.update.check()) { $('.ui-small').first().before('