[Userscript] Community Mnemonics (v0.9.7.8)

This is a much required feature. Maybe I’ll get it fixed when I have the time.

Better yet, Wanikani develops their own mnemonic sharing feature.

There may be a solution for this. Do people use the built in custom notes feature in WK? If so, I could write a script let’s a user upload all of their notes when they install. If we get even a few users that have a decent sized personal library of notes, we could have a pretty good starting place.

Let me know if you or someone you know has personalized notes they’d be willing to share with the community and I can write the script that compiles them together.

Since I just mentioned this script in another thread: does anyone happen to be working on this? The script still seems to work in the vocabulary section but it is broken in the kanji section and the security issue that was mentioned above would need to be fixed.

I’m guessing @Samuel-H won’t be maintaining it anymore since he already reached level 60 and isn’t active much here anymore?

I was thinking about raising this script back from the dead and if I were to do it, the best time for this would be around christmas because I have more time available. But to be honest, I don’t enjoy coding in my free time as much as some other people here seem to do so I’m still hoping that someone else will do it :wink:

1 Like

Ow, I wish this script was working… I enjoy and connect with (almost) all mnemonics I’ve seen so far but it seems nice to have more options. Did you try to fix it @irrelephant? :pray::pray:

No I didn’t yet because I wasn’t sure how many people would be interested. Usually I would fix a script just for me but in this special case: if there is no one who wants to use it, it might be a bit difficult.

But it really might be worth it. I’ll have a look at the data that is currently already there on the weekend. Maybe there is already a lot that we can reuse.

In the meantime: if anyone else is interested in having this script back up and running: please let me know. I think the more people want to use it, the better. Not too much use in sharing mnemonics otherwise… :wink:

1 Like

This would be so great to have. There have already been a few items that haven’t clicked for me, so I’ve had to make up new mnemonics. Would be really cool if we could collectively learn the best ones from each other.

1 Like

I recently read another user’s post talking about how he’d like to store community mnemonics somehow but I can’t find it now. :\

You are probably referring to https://community.wanikani.com/t/should-wanikani-save-peoples-mnemonics ?There were also a lot of people who were not a big fan of the idea either since users could be submitting unpleasant stuff and too few people would be using it. I had a look at the data and there indeed doesn’t seem to be a lot there yet.

Ideally, some higher level users who already have written a lot of mnemonics could export these (I would have to write a little script for that unless there already is a note exporter script somewhere), go through them to see if there is anything they don’t want to share and I could import them into the dataset. But I don’t know if anyone would be interested in doing that.

So todos from my perspective would be:

  • Sanitize data to avoid XSS attacks as mentioned by above. There is already some of that logic in place to do this, I would probably just do that again before showing the data (in case someone had modified it directly in the Google doc)
  • Fix script so that it runs on all types of pages (at least lessons and kanji currently don’t seem to be working)
  • Optional, later: build a small tool that lets people bulk export their notes so that I can import them to the existing data set.
  • Also optional: have a small statistic somewhere that lists users and the votes that they received on their mnemonics so that people would be motivated to contribute and so that we can thank them for putting in the effort

I’m lying in bed sick right now and don’t have the energy to get started on this but I’m still not opposed to the idea.

2 Likes

Thanks to a great user pointing me to this topic. May I ask is there anyone who is still working to update the script? I think it’s not working at the moment?

If this is still working, I’m gonna jump on it. I’d love to have more community involvement like this in the learning process.

1 Like

Seeing that “4 months later” jump tells me it might not still be actively updated. But I really like it so far, so hopefully the original author or someone can pick up on it again?

Anyway, the formatting is thrown off.

It doesn’t always do this, but most of the time, if a mnemonic is provided by a community member, it shows up like this; mostly unreadable. This is in Chrome 66 on Windows 10. Additionally, many of the users (including myself) show up as “c” for a username?

I’m having this problem as well. The script refers to my account as “c” for the username.

I had a bunch of issues with lag and the entire script not loading
Here’s some fixes

===================================================================
+++ 新しいバージョン
--- 現在のバージョン
@@ +1,14 -1,12 @@
 // ==UserScript==
 // @name        WK Community Mnemonics
 // @namespace   wkcm
 // @description This script allows WaniKani members to contribute their own mnemonics which appear on any page that includes item info.
+// @require     https://rawgit.com/jsoma/tabletop/master/src/tabletop.js
+// @require     https://rawgit.com/jackmoore/autosize/v1/jquery.autosize.js
 // @exclude		*.wanikani.com
 // @exclude		*.wanikani.com/level/radicals*
 // @include     *.wanikani.com/level/*
 // @include     *.wanikani.com/kanji* 
 // @include     *.wanikani.com/vocabulary*
 // @include     *.wanikani.com/review/session
 // @include     *.wanikani.com/lesson/session
 // @version     0.9.7.8
@@ +25,9 -23,11 @@
 CMIsList = (!CMIsReview && !CMIsLesson && (new RegExp("level/[0-9]{1,2}$", "i").test(window.location.pathname.slice(window.location.pathname.indexOf("com/") + 2)) ||
            new RegExp("[kanji|vocabulary].[difficulty=[A-Z]$|$]", "i").test(window.location.pathname.slice(window.location.pathname.indexOf("com/") + 2))));
 CMIsChrome = (navigator.userAgent.toLowerCase().indexOf('chrome') > -1);
 
-$("head").prepend('<script src="https://rawgit.com/jsoma/tabletop/master/src/tabletop.js" type="text/javascript"></script>' +
-                  '<script src="https://rawgit.com/jackmoore/autosize/v1/jquery.autosize.js" type="text/javascript"></script>');
 
 if (CMIsReview || CMIsLesson) {
     $(document).ready(function() {
         var checkContentLoaded = setInterval(function() { 
             										if ((CMIsReview && $("#character span").html() !== "") || ($("#character").html() !== "" && $("#character").html() !== "&nbsp;")) {
@@ +37,13 -37,9 @@
                                                  }, 1000);
     });
 } else {
 
+    if (document.readyState === "loading") {
+        document.addEventListener("DOMContentLoaded", function() { checkCMNewestVersion(0); });
+    } else {
+        checkCMNewestVersion(0);
+    }
-    document.addEventListener("DOMContentLoaded", function() { checkCMNewestVersion(0); });
 
 }
 
 var public_spreadsheet_url = 'https://docs.google.com/spreadsheet/pub?hl=en_US&hl=en_US&key=1sXSNlOITCaNbXa4bUQSfk_5Uvja6qL3Wva8bPv-3B2o&output=html';
@@ +479,10 -475,10 @@
     var curRLength = 0;
     var curSortMap = [];
     var curPageMap = [];
     var newItem = true;
+    var addItems = data.length;
-    var addItems = Object.keys(data).length;
     
     CMTableData = data;
     
     if (!CMIsList) {
         
@@ +490,9 -486,9 @@
             decodeURIComponent(window.location.pathname.substring(window.location.pathname.lastIndexOf("/") + 1)));
         CMType = (CMIsReview) ? (($("#character").attr("class") !== "radical") ? (($("#character").attr("class") == "kanji") ? "k" : "v") : "r") :
             ((CMIsLesson) ? (($("#main-info").attr("class") !== "radical") ? (($("#main-info").attr("class") == "kanji") ? "k" : "v") : "r") : ((window.location.pathname.indexOf("kanji") > -1) ? "k" : "v"));
         
+        for (var a = 0; a < data.length; a++) {
-        for (var a = 0; a < Object.keys(data).length; a++) {
             if (data[a].Item.substring(1) == CMChar && data[a].Item.substring(0, 1) == CMType) {
                 newItem = false;
                 CMIndex = a + 2;
                 break;
@@ +510,24 -506,24 @@
             if ((urlString).indexOf("/kanji") > -1) CMIndex = 1;
             else CMIndex = 2;
         }
     }
     
     if (CMInitSettings || CMInitVotes) CMInitData = true;
 
+    if (!CMInitData && !newItem && data.length > (Object.keys(CMData.k).length + Object.keys(CMData.v).length)) {
-    if (!CMInitData && !newItem && Object.keys(data).length > (Object.keys(CMData.k).length + Object.keys(CMData.v).length)) {
         var lastItem = data[Object.keys(CMData.k).length + Object.keys(CMData.v).length - 1].Item;
         if (lastItem == "k" + Object.keys(CMData.k)[Object.keys(CMData.k).length - 1] || lastItem == "v" + Object.keys(CMData.v)[Object.keys(CMData.v).length - 1]) addItems = Object.keys(CMData.k).length + Object.keys(CMData.v).length;
         else {
             CMInitData = true;
             CMData = {"k": [], "v": []};
         }
+    } else if (!CMInitData && data.length < (Object.keys(CMData.k).length + Object.keys(CMData.v).length)) {
-    } else if (!CMInitData && Object.keys(data).length < (Object.keys(CMData.k).length + Object.keys(CMData.v).length)) {
         CMInitData = true;
         CMData = {"k": [], "v": []};
     }
     
+    for (var d = 0; d < data.length; d++) {
-    for (var d = 0; d < Object.keys(data).length; d++) {
         
         if (CMInitData || d + 2 == CMIndex || d >= addItems) {
         	
             curItem = data[d].Item.substring(1);
@@ +574,16 -570,16 @@
                                         
             curM = [];
             curR = [];
             
+            if (!CMInitData && addItems == data.length) break;
-            if (!CMInitData && addItems == Object.keys(data).length) break;
             
         }
     }
     
     if (newItem) {
         if (CMChar.length > 0 && CMChar !== "&nbsp" && CMType !== "r") {
+            CMIndex = (CMInitSettings) ? d : data.length + 2;
-            CMIndex = (CMInitSettings) ? d : Object.keys(data).length + 2;
             CMSettings[CMType][CMChar] = {"m": {"p": "", "c": false}, "r": {"p": "", "c": false}};
             CMVotes[CMType][CMChar] = {"m": [], "r": []};
             CMData[CMType][CMChar] = {"i": d + 2, "m": {"t": [""], "s": [], "u": [""]}, "r": {"t": [""], "s": [], "u": [""]}};
             CMSortMap = getCMSortMap([], []);

1 Like

I’m not sure if this thread is still active, but I really like the idea of this and hope people keep using it!

While I don’t have the same problem as others and am able to read the menmonics by community members (using Firefox and Windows 10), I can’t upvote any of them. Probably not a big deal, but I noticed the program refers to me (and obviously others) as “c”, and when trying to upvote another person’s memnonic I get the following problem message:

1 Like

It looks like that bug only exists in the reviews / lessons views, so for now if you do your voting and posting from the info page (WaniKani / Vocabulary / 親友 for example) it should work fine

1 Like

Where do I copy this fix in the script’s code?

It’s a diff, you have to search and delete the red lines and add the green lines. The @@ line gives more information where the change is.

Would be easier to just post a fixed script, though :slight_smile:

Yea, I don’t understand anything about code so for me it’s pretty confusing! :sweat_smile:

Ahh sorry, I had sort of intended it for the original author, though given that the script hasn’t been touched in like two years maybe that wasn’t such a good idea…
For now you can grab this and paste it over the current script, though I should think about distributing it in a more reasonable way later
…Does anyone know of a way to fork a script on GreasyFork (so that the change history is properly carried over)? You would think that, with a name like GreasyFork, they would support this but I haven’t been able to find a button to do such a thing.

1 Like

Done!

Will come back with feedback once I work on some lessons today :sunglasses: