Inserio

WaniKani go to item's page script

Jun 1st, 2015
280
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;; ctrl+y = Go to the WaniKani page for the current Radical, Kanji, or Vocabulary
  2. ;; Likely to have some bugs.
  3. ;; Does not work for some radicals and must have made a guess and opened the info for radicals during reviews
  4. ;; Kanji and Radicals are untested for Lessons
  5. ;; Made a proposed fix for lessons pages and optimized the script to do only what's necessary
  6.  
  7. SetTitleMatchMode 2
  8. #If WinActive("WaniKani / Reviews") || WinActive("WaniKani / Lessons")
  9. ~^y::
  10.     site :=
  11.     ClipSaved := ClipboardAll
  12.     clipboard :=
  13.     MouseGetPos, mouseX, mouseY
  14.     IfWinActive WaniKani / Lessons
  15.         Click 856, 359
  16.     Else
  17.         Click 1317, 361
  18.     MouseMove, mouseX, mouseY
  19.     Send, {Ctrl Down}ac{Ctrl Up}
  20.     ClipWait
  21.     Send {tab 3}
  22.     page := clipboard
  23.     VocabCheck :=
  24.     VocabCheck := RegExReplace(page, "si).*\n([〜\p{Han}\p{Katakana}\p{Hiragana}]+).*(Vocabulary).*", "$2")
  25.     If (VocabCheck = "Vocabulary")
  26.     {
  27.         Vocab :=
  28.         Vocab := RegExReplace(page, "si).*\n([〜\p{Han}\p{Katakana}\p{Hiragana}]+).*(Vocabulary).*", "$1")
  29.         site = vocabulary/%Vocab%
  30.         ; Send ^{t}
  31.         ; Sleep 20
  32.         ; Send https://www.wanikani.com/vocabulary/%Vocab%
  33.         ; Sleep 5
  34.         ; Send {enter}
  35.     }
  36.     Else
  37.     {
  38.         RadCheck :=
  39.         RadCheck := RegExReplace(page, "si).*\n([\p{Han}]+)\r\n(Radical).*(User Synonyms).*", "$2")
  40.         If (RadCheck = "Radical")
  41.         {
  42.             Rad :=
  43.             Rad := RegExReplace(page, "si).*\n([\w ]+).*(User Synonyms).*", "$1")
  44.             Rad := RegExReplace(Rad, "(\w)", "$l1")
  45.             Rad := RegExReplace(Rad, "(\s)", "-")
  46.             site = radicals/%Rad%
  47.             ; Send ^{t}
  48.             ; Sleep 20
  49.             ; Send https://www.wanikani.com/radicals/%Rad%
  50.             ; Sleep 5
  51.             ; Send {enter}
  52.         }
  53.         Else
  54.         {
  55.             KanjiCheck :=
  56.             KanjiCheck := RegExReplace(page, "si).*\n([\p{Han}]+).*(Kanji).*", "$2")
  57.             If (KanjiCheck = "Kanji")
  58.             {
  59.                 Kanji :=
  60.                 Kanji := RegExReplace(page, "si).*\n([\p{Han}]+).*(Kanji).*", "$1")
  61.                 site = kanji/%Kanji%
  62.                 ; Send ^{t}
  63.                 ; Sleep 20
  64.                 ; Send https://www.wanikani.com/kanji/%Kanji%
  65.                 ; Sleep 5
  66.                 ; Send {enter}
  67.             }
  68.         }
  69.     }
  70.     Send ^{t}
  71.     Sleep 20
  72.     Send https://www.wanikani.com/%site%
  73.     Sleep 5
  74.     Send {enter}
  75.     Clipboard := ClipSaved  ; puts the original clipboard contents back
  76. Return
  77. #If ; default
RAW Paste Data