0

I'm the creator of JANITOR – Java API Navigation Is The Only Rescue, a userscript which:

Inserts a navigation tree for modules, packages and types (interfaces, classes, enums, exceptions, errors, annotations) into the Javadoc pages of Java 11+.

JANITOR – Java API Navigation Is The Only Rescue

Due to changes in the DOM in Java 17+ from kind-of-type sections to a single table containing all types in alphabetic order I have to use synchronous XMLHttpRequests to get the kind (I, C, En, Ex, Er, A) of a type for the tree view.

I experienced that this can take a while to refresh the tree view (5-10 seconds) with packages with many types (e.g. java.io, java.lang) and I get:

⚠️ Synchronous XMLHttpRequest on the main thread is deprecated ...

... and in Synchronous XMLHttpRequest deprecated is mentioned:

[...] that my browser (Chromium) automatically updated to a new version that doesn't allow synchronous AJAX-requests anymore.

I experimented with a worker in the past but at reactivating it I get:

❗ Security Error: Content at https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/lang/Deprecated.html may not load data from https://gitlab.com/gerib/userscripts/-/raw/master/janitor/janitor-navigation-loader.js.

I guess this is to prevent XSS.

Is there a way to supply the worker with code other than with a file (e.g. String, template literal, Array, List, ... whatever) or am I out of luck now?

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
  • Have you tried postMessage()? https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage – offscriptdev Jun 09 '23 at 23:36
  • @offscriptdev I guess with the mentioned error msg the the worker isn't even started. Is this an [AI/ChatGPT-driven](https://meta.stackexchange.com/questions/389811/moderation-strike-stack-overflow-inc-cannot-consistently-ignore-mistreat-an) comment? – Gerold Broser Jun 09 '23 at 23:44
  • 2
    [how to create a web worker from a string](https://stackoverflow.com/questions/10343913/how-to-create-a-web-worker-from-a-string) , also [how can I load a shared web worker with a user script](https://stackoverflow.com/questions/38810002/how-can-i-load-a-shared-web-worker-with-a-user-script) – artem Jun 09 '23 at 23:56
  • @GeroldBroser--OnStrike Not ChatGPT, I just misunderstood your question. I thought you were trying to supply some kind of data to an already running web worker. – offscriptdev Jun 10 '23 at 01:36
  • @offscriptdev Fun fact: I commented on [one of the answers to your second-linked Q](https://stackoverflow.com/a/63287809/1744774) 2½ years ago (but apperantly I didn't remember :). – Gerold Broser Jun 10 '23 at 15:25

0 Answers0