For Python instructions, see post 8 below.
To disable/re-enable this easily, see post 13 below.
Hey all,
This is something I made for myself that I find very useful for me. It’s a small script that runs every hour and checks if there’s a new WaniKani review session available. If there is, it will open up WaniKani for me, or else it will just let me know how many hours are left until review time and disappear.
The major benefit for this method is that you are taken to the reviews as soon as they are ready. This means that you won’t have to check for reviews on your own, and it’s great for people like me who want to go through WaniKani as quickly as possible and stay on top of their Japanese studies.
These instructions are written for my computer environment, which is Windows 10 and Google Chrome and with PHP software. If any of you work with Mac OS/Firefox/Python/etc and want to convert these commands over and share them here, please do .
1) Install PHP
If you already have a web server installed and you know how to run PHP from the command line, then you can skip this step.
Go here, http://php.net/downloads.php, and click “Windows downloads” under the most recent Current Stable PHP version. And then click on the “Zip” download link under either “VC15 x64 Thread Safe” or “VC15 x86 Thread Safe”, depending on your operating system. If you don’t know, it’s probably “x64”, and if x64 doesn’t run, then try x86.
When the Zip file is downloaded, open it, and extra it to C:\php. You may have to create this folder first if it doesn’t exist. After you extract it, you should end up with a file located at C:\php\php.exe.
To test if this worked correctly, open a Command Prompt and type the command C:\php\php.exe -?
. If it comes back with an error message, go back and try again.
2) Create the code file
Open up Notepad or your favorite code editor. Copy and paste the code section below, and modify the API key and your timezone as necessary. Your API key is found at https://www.wanikani.com/api. The available timezone values are found at http://php.net/manual/en/timezones.php.
Save this file somewhere where you can find it. I recommend putting it in your user folder, which is located at C:\Users(your username), but placing it on your desktop or in your root directory will work, too. For my example, I placed it in C:\Users\Ben\wanikani.txt.
To test that it works, open up a command prompt and run the script from php. This is the command to run it on my computer:
C:\php\php.exe -dextension=openssl C:\Users\Ben\wanikani.txt
If everything works good so far, you should see a window like this (or WaniKani will open if it’s review time).
The code file:
<?php
$api_key = "YOUR_API_KEY";
$timezone = "America/New_York";
date_default_timezone_set($timezone);
$api_call = json_decode(file_get_contents("https://www.wanikani.com/api/user/$api_key/study-queue"), true);
$seconds_til_review = $api_call["requested_information"]["next_review_date"] - time();
$hours_til_review = round($seconds_til_review / 60 / 60, 2);
if ($hours_til_review < 0.15) {
print shell_exec('SCHTASKS /F /Create /TN PHP_OPEN /TR "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --new-window https://www.wanikani.com/review\'" /SC DAILY /RU INTERACTIVE') . "<br />\n";
print shell_exec('SCHTASKS /RUN /TN PHP_OPEN') . "<br />\n";
print shell_exec('SCHTASKS /DELETE /TN PHP_OPEN /F') . "<br />\n";
}
else {
print "Hours til review: " . $hours_til_review;
sleep(10);
}
3) Create a scheduled task
Open up Task Scheduler. The quick way to do this is to hit the Start Button and type “task scheduler”.
Inside Task Scheduler, on the right, click “Create Task…”.
Under the General tab, enter WaniKani in the Name field. Also, check the “Run with highest privileges” checkbox.
Under the Triggers tab, click “New…”. Set the Start time to the next hour plus 5 seconds or us (for example 4:00:05 PM). The five seconds gives room for time differences between your computer and WaniKani’s servers. If you find that the WaniKani window opens but the reviews aren’t actually ready, then change the 5 seconds to 15 seconds or more. Also, check off the “Repeat task every” checkbox, and change the “for a duration of” field to “Indefinitely”. Click OK to close the “New Trigger” window.
Under the Actions tab, click “New…”. For “Program/script”, type C:\php\php.exe
, and for “Add arguments”, type -dextension=openssl C:\Users\Ben\wanikani.txt
. Modify these two textboxes as necessary to fit where you installed PHP and where you saved the code file. Click OK to close the “New Action” window.
Click OK to create the task. To check if it worked, click on “Task Scheduler Library” on the left, and you should see your “Wanikani” task. If you don’t see it, go back from the top of step 3 and try again. Right-click on the task and click Run, and you should get a little Command Prompt window that stays open for 10 seconds, or a WaniKani window.
4) 日本語を勉強する!
Thank you for checking this out. If it helps, let me know