[Userscript] Move up Context Sentences and Patterns of Use's section in Review

Move Context Sentences and Patterns of Use section up in Review.

I think Japanese usage is still more important than English meanings. Also, examples could infer meanings. As Wanikani has native Context and Pattern of Use listings, they should be made for better use.

Hide English translations optionally, thanks to [Userscript]: Hide Context Sentence Translation

Also move up for Reading questions, but collapsed

2 Likes

It appears to be of great help (via convenience), especially when [Userscript] WaniKani JJ External Definition from Weblio (JP) and Kanjipedia can’t find a definition.

Hello, thanks for this! It seems to work great, but it breaks the “advanced context sentence” script. Any solutions?

I am not using WaniKani anymore, but you might start troubleshooting from looking at errors in JavaScript console. Also, not sure how exactly it breaks, not appearing at all?

Follow this guide.

thank you for answering!

I fixed it by changing a few lines. This was all poking in the dark, I’ve never edited code before. I want to post it here but I don’t even know how to do that.

essentially, the problem was coming from the node being cloned then deleted, so I removed that and it worked

I’d like to post the changes here but I don’t even know how to do that

Plus I’ll try to request another change from someone more experienced, to get the context sentences at the very top

1 Like

3 back ticks at the start, a new line, the code, a new line, then 3 back ticks at the end.

It's markdown.
I believe Discourse uses markdown-it engine.
1 Like

(function () {
  const elInfo = document.querySelector('turbo-frame#subject-info');
  if (elInfo) {
    const obs = new MutationObserver(() => {
      const container = Array.from(elInfo.childNodes).find(
        (el) => el instanceof HTMLElement && el.classList.contains('container'),
      );
      if (!(container instanceof HTMLElement)) return;

      const contextHref = container.querySelector('section > a#context');
      if (!contextHref) return;

      const contextSection = contextHref.parentElement;
      if (!contextSection) return;

      container.insertAdjacentElement(
        'afterbegin',contextSection
      );

    });
    obs.observe(elInfo, {
      attributes: true,
      attributeFilter: ['src', 'complete'],
    });
  }
})();

it works! thanks a lot :slight_smile:

1 Like