Knowledge required to Create a Script


#1

I see so many people here creating scripts to help fellow wankanians out , and I wanted to learn how to create some of these scripts as well. Considering knowledge of a few programming languages, can someone point me in the right direction on how to learn developing these scripts ?

Thanks in advance! 


API V2 Alpha Documentation
#2

The language you will need is Javascript, and the jQuery framework (https://jquery.com/) is very useful.

jStorage is where the data is held (http://www.jstorage.info/)

Also download the source of some of the existing scripts. Find some good ones in ShotgunLagoon’s excellent list thread (https://www.wanikani.com/chat/api-and-third-party-apps/7895) and see what people are doing - how to set up the Greasemonkey part for example.

Also, greasy fork is a good place to host your script (https://greasyfork.org/en)


#3

You will need to know how to code I presume, I’m no programmer but I’m pretty sure you will need to know JSON in order to do it as well as the fundamentals of the coding languages.


#4

One thing I would keep in mind is a clear idea of what exactly you’re trying to create, and how that fits within certain programming frameworks.  I know that a lot of people have all of these ideas for browser add-ons, but there are quite a few that really shouldn’t be add-ons - they only make a very small number of requests for info from the website, and the rest of the program would be a lot more involved in terms of then using that data as desired.  In those cases, you would be better served with another scripting language, like Python or Ruby, that makes those occasional requests, and just packaging that as a program people can download, rather than a browser add-on.  Just something to keep in mind.


#5

What is the answer other than HTML, CSS and Javascript? jQuery and jStorage?

BTW, there is no Userscript or Tampermonkey/Greasemonkey course in Udemy, but there is jQuery.

https://www.google.co.th/search?safe=off&dcr=0&source=hp&ei=bh0dWsDRCIHbvgSas73ABw&q=userscript+tutorial&oq=userscript+t&gs_l=psy-ab.3.0.0l5j0i22i30k1l5.2077.3556.0.5652.13.8.0.0.0.0.489.1151.2-1j1j1.3.0…0…1c.1.64.psy-ab…10.3.1151.0…0i203k1.0.UA7CqQ9xfuY doesn’t seem useful to me. Not even http://commons.oreilly.com/wiki/index.php/Greasemonkey_Hacks

$ is something new to me.

I did create [Userscript] WaniKani Hide Buttons in Review, but I didn’t use $, and I couldn’t add complex stuff…

Also, what IDE do I need for making a Userscript?


#6

The jstorage website looks to be trying to install a malicious plugin. You can get documentation direct from the github page instead.


#7

Also you can see wanikani JS API and global objects by printing window object in console.
This would return different results based on which page you are on. For example during a lesson session, a review session or on dashboard.

Also other script which define global objects can also be inspected here. Like Dashboard Progress Plus script has following global object name wkdpp


#8

This thread is two years old :wink:


#9

$ is a shorthand for jquery functions. There are plenty of courses on that around. If you wanna store values/settings, then jStorage is good to look into yea.

There probably aren’t many tutorials on user scripts because there’s nothing much to teach i guess? It’s not really like teaching someone to make a general-purpose program. Each script is a hack for a specific website, so you just need to start doing it to learn it. Any GM specific functions you can learn from looking at their documentation (although I prefer my scripts without them). Tampermonkey is just a program that executes whatever javascript you feed it, so you should just learn how to program in JS…

I use no IDE. I just try out some javascript in the browser console and the rest i type directly into the Tampermonkey ‘new script’ window. And then test/debug after I’ve finished.

Especially if you don’t know how to program yet and/or are new to JS, try to set realistic expectations for yourself. Learn how the WK website works, look at lots of other scripts (good to learn how somebody solved a problem you may have) and start with some easy stuff. If you look at my early scripts, they’re not that mind-blowing either. I just tried to make something with what I knew I could do at the time.


#10

oh wow. didn’t see that. :smiley:


#11

What knowledge is required to

  1. Run the script after entering the correct answer in *://www.wanikani.com/review/session*, that is, after the website has changed? Event Listener?
  2. Inspect Elements not shown visually on the website, e.g. Javascript

BTW, this is my current script – https://www.dropbox.com/s/o238yjizxl17d1c/blacklist.js?dl=0


#12

For 1., take a look at my script at github:
https://github.com/mwil/wanikani-userscripts/blob/master/utility/wk_interaction.js

For the reviews I currently look how the jStorage changes after a question was answered. You could probably reuse it by @require’ing it and listening for its events. Check my other scripts on github on how to use it.

For 2. you can see the other sources in your browser’s developer pane. But it’s not clear what you want to do.


#13

For example, I couldn’t figure out how to remove Meaning, here, and add a box like Part of Speech.


#14

@polv You can reference the pitch info script, they add new elements into the left side (it’s div#item-info-col1).

You can also hide and delete elements in the developer pane on the actual page when you right-click on the element, you can see what will happen. In your code you have to select it (for example by its ID item-info-meaning) and just delete it.


#15

Eventually, I use waitForKeyElements and it works.

My current script: https://www.dropbox.com/s/gbx4y7c5i0gzbdd/blacklist-stable-0.1.2.js?dl=0

I am trying to create “Looking for a different answer”, and I now require [Userscript] Prevent “Your answer was a bit off” answers from being accepted a.k.a. “Close But No Cigar” to work with [UserScript] WaniKani Double Check and also with my script… because I feel my script looks partly like No Cigar (and probably partly like [Userscript] Wanikani Multiple Answer Input in concept).

About MutationObserver and observer(), the answer must be https://stackoverflow.com/questions/13277212/mutation-observer-for-creating-new-elements


What do you want now? (Request extensions here)