JPDB add review button in vocabulary

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

目前为 2023-07-30 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name JPDB add review button in vocabulary
  3. // @namespace jpdb.io
  4. // @version 0.1
  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. // @icon https://www.google.com/s2/favicons?sz=64&domain=jpdb.io
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. const menu = document.querySelector(".result.vocabulary .menu");
  17. const v = document.querySelector("form.link-like input[name='v']")?.value;
  18. const s = document.querySelector("form.link-like input[name='s']")?.value;
  19. const href = `/review?c=vf,${v},${s}`;
  20. if (menu && s && v) {
  21. menu.after(createLink(href));
  22. }
  23.  
  24. function createLink(href) {
  25. const wrapper = document.createElement("div");
  26. const a = document.createElement("a");
  27. a.href = href;
  28. a.appendChild(document.createTextNode("Review"));
  29. wrapper.appendChild(a);
  30. return wrapper;
  31. }
  32. })();