[Userscript]: Anime Context Sentences

After updating Item Info Injector last week, I was wondering how long it will take until someone mentions the change in one of the dependent scripts. :smiley:

I have already created a pull request for fixing the problem with the unnamed tab (but this fix still keeps the Anime Sentences section as a separate tab). @psdcon, if you want to place the Anime Sentences section in the Context tab, the append() has to be changed into appendSubsection(). You now also have the option to change notify() [1] into notifyWhenVisible() [2] – both of them work, but have small differences (currently only during the lesson quiz).

  1. The callback function will be called once the user opens the item info. At this point, the Context tab is still closed and its content is not in the DOM, so when you try to append your section, Item Info Injector outputs a warning in the console that your section could not be injected. However, your section is cached and appended automatically once the user opens the Context tab, so everything should still work. β†©οΈŽ

  2. The callback function will be called once the user expands the Context tab. In this case, appendSubsection() works without problem and you don’t get a warning. However, if the user collapses and then expands the Context tab once more, the callback function is also called again – so your section gets recomputed every time the tab is expanded.

    So in the case of Anime Sentences, the main difference between these two options is: with notify(), Anime Sentences gets loaded even if the user opens the item info without ever looking into the Context tab, while notifyWhenVisible() will delay the loading until the user actually opens the Context tab, but this also means that the user then has to wait until the data has been fetched from Immersion Kit before they can see the sentences. β†©οΈŽ

1 Like