Resurrecting items

I’m trying to understand the API but I have a really basic question that does not involve the API. The resurrect button of an item opens some url like:

https://www.wanikani.com/assignments/6/resurrect

If I click the button, the item is resurrected. However, if I just copy this URL to the address bar of the browse and click on it, the item is not resurrected… Why the difference in behavior? Any ideas @rfindley 先輩, @Kumirei 先輩, @seanblue 先輩?

1 Like

Without investigating, it’s probably a GET versus POST thing.

https://www.w3schools.com/tags/ref_httpmethods.asp

1 Like

You have to include an “authenticity_token”. See my Burn Manager script for an example.

If I remember correctly, you have to extract the token from the header of the page that the button is on.

2 Likes

Here’s how I’ve done in one of my extensions:

fetch( `https://www.wanikani.com/assignments/${item.idNumber}/resurrect`,
     {
         headers: {
          "Content-Type": "application/x-www-form-urlencoded"
         },
       method: "POST",
          body: `_method=put&authenticity_token=${encodeURIComponent(
       window.wrappedJSObject.$.rails.csrfToken()
    )}`
   }
    ).then(() => {
     alert("resurrection complete")
     })
    }}
3 Likes

Thanks y’all!

2 Likes

Not sure but with the API, one will still need to get authenticity_token. I want to either adapt the burn manager or do some script to allow me to unburn in bulk my previous leeches but it is the end of the semester (lots of grading) and I’m still learning basics of javascript.

1 Like

If you are interested, I can publish a personal script I’ve written. I know, selfish me, keeping the script to myself. But I kind of got a bit of anger from folks last time I published an extension that wasn’t a greasemonkey script :joy: So it’s a bit of a “no soup for you situation.” I just like making web extensions for myself at this point.

I have a bunch of personal extensions that I use on Wanikani right now. One is called Moeru, and it’s sole purpose is to let you go back through the levels and quiz / burn things if you want to. I haven’t worked on it in a while because it’s basically up to the quality of working just fine for me. I wanted to be able to go back through and quiz myself on burned items and then decide if I want to resurrect things. I’ll post a video below of how it looks today.

If there’s interest, I can look to publishing this as an extension and a script (greasemonkey or what have you). Although, there’s a few bits I’d want to clean up first (and let me know if you have requests for a specific feature!).

2 Likes

Hey Andrew, it looks neat! I don’t care if it is greasymonkey, python, etc… If you add a link to the code in github or the repository you use, I’d like to take a look. Thanks!

2 Likes