[Userscript] Search WaniKani via browser search bar

I created a little script inspired by this feature request: https://community.wanikani.com/t/search-wanikani-via-chrome-search-bar/

It allows you to search WaniKani by using the parameter “q” in the URL, such as: WaniKani — Log in

This in turn will make it possible to define a custom search keyword e.g. in Chrome so that you can e.g. type “wk”, then hit space and enter the term you want to search for:
26

It is available via greasyfork: WaniKani URL Keyword search
Only tested it (briefly… ) in Chrome.

9 Likes

Hey, thank you for sharing your work!

Unfortunately, it’s not working for me (Firefox 64). The search string gets pasted into the search box, but after that the page reloads and WaniKani displays the error message “You are already signed in.”

1 Like

Oh :-/
I have to admit that I only tested it in Chrome where it is still working fine. I will try to look into this but I have two other things on my list of things I promised to look into first and am somewhat busy at the moment so I can’t promise when I’ll get to it.

1 Like

@irrelephant, not sure if you’re still around and maintaining scripts, but a small fix is needed due to changes WaniKani made a few months ago. Even though the search still executes, it doesn’t actually get displayed until you click the search icon (which makes the input and results visible). I added the following to the end of the submitSearch method to trigger the click event so the results show right away:

var searchButton = document.getElementById('search__trigger');
searchButton.click();

(Also, you should probably get rid of the console logs while you’re at it.)

2 Likes

@seanblue thank you for this update proposition.

I added the code

var searchButton = document.getElementById('search__trigger');
searchButton.click();

to the end of the submitSearch method, but for me on Chrome Version 100.0.4896.127 (Official Build) (x86_64), the search doesn’t get executed either…
Obviously, coming after 2 years, it was likely not to work properly :weary:
Anyone has a clue ?

1 Like

This script isn’t needed anymore since WaniKani made a dedicated search page several months ago. Just execute a search on WaniKani to see what the search URL looks like and then add a custom search engine to chrome.

3 Likes

Guess that saves me googling “WaniKani [some word]” when I’m too lazy to open up the website.

1 Like

Correct ! I could make it work with adding this search engine to chrome :
https://www.wanikani.com/search?query=%s&button=
Thank you @seanblue :+1:

1 Like

adding &button= on the end actually breaks it for some reason, I had to remove that to get it to work.

Never mind it works with that now, maybe it’s an issue with the face I was on the IME still and so it wasn’t recognising the %s as the same characters.

I’m sure that’s what it was now :smiley:

image
Since the s has gaps.