JPDB add review button in vocabulary

Adds a button to force-review a word from its vocabulary page in JPDB

  1. // ==UserScript==
  2. // @name JPDB add review button in vocabulary
  3. // @namespace jpdb.io
  4. // @version 0.2
  5. // @description Adds a button to force-review a word from its vocabulary page in JPDB
  6. // @author daruko
  7. // @match https://jpdb.io/vocabulary/*/*
  8. // @match https://jpdb.io/search?*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=jpdb.io
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. document.querySelectorAll(".result.vocabulary").forEach(entry => {
  18. const menu = entry.querySelector(".menu");
  19. const v = entry.querySelector("form.link-like input[name='v']")?.value;
  20. const s = entry.querySelector("form.link-like input[name='s']")?.value;
  21. const href = `/review?c=vf,${v},${s}`;
  22. if (menu && s && v) {
  23. menu.after(createLink(href));
  24. }
  25. });
  26.  
  27. function createLink(href) {
  28. const wrapper = document.createElement("div");
  29. const a = document.createElement("a");
  30. a.href = href;
  31. a.appendChild(document.createTextNode("Review"));
  32. wrapper.appendChild(a);
  33. return wrapper;
  34. }
  35. })();