Wanikani Context Move-Up

Move up Context Sentences and Patterns of Use in Review

  1. // ==UserScript==
  2. // @name Wanikani Context Move-Up
  3. // @namespace http://www.wanikani.com
  4. // @description Move up Context Sentences and Patterns of Use in Review
  5. // @icon https://www.google.com/s2/favicons?sz=64&domain=wanikani.com
  6. // @match https://www.wanikani.com/extra_study/session*
  7. // @match https://www.wanikani.com/review/session*
  8. // @match https://www.wanikani.com/subjects/review*
  9. // @match https://www.wanikani.com/subjects/extra_study*
  10. // @match https://preview.wanikani.com/extra_study/session*
  11. // @match https://preview.wanikani.com/review/session*
  12. // @match https://preview.wanikani.com/subjects/review*
  13. // @match https://preview.wanikani.com/subjects/extra_study*
  14. // @version 0.1.0
  15. // @author polv
  16. // @license MIT; http://opensource.org/licenses/MIT
  17. // @grant none
  18. // ==/UserScript==
  19.  
  20. (function () {
  21. const elInfo = document.querySelector('turbo-frame#subject-info');
  22. if (elInfo) {
  23. const obs = new MutationObserver(() => {
  24. const container = Array.from(elInfo.childNodes).find(
  25. (el) => el instanceof HTMLElement && el.classList.contains('container'),
  26. );
  27. if (!(container instanceof HTMLElement)) return;
  28.  
  29. const contextHref = container.querySelector('section > a#context');
  30. if (!contextHref) return;
  31.  
  32. const contextSection = contextHref.parentElement;
  33. if (!contextSection) return;
  34.  
  35. const meaningSection = container.querySelector(
  36. 'section > a#meaning',
  37. )?.parentElement;
  38. if (!meaningSection) return;
  39.  
  40. meaningSection.insertAdjacentElement(
  41. 'beforebegin',
  42. contextSection.cloneNode(true),
  43. );
  44.  
  45. contextSection.remove();
  46. });
  47. obs.observe(elInfo, {
  48. attributes: true,
  49. attributeFilter: ['src', 'complete'],
  50. });
  51. }
  52. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址