Collective.glossary not working

I have finally collective.glossary working in all its glory in Plone 5.1. Sort of, I think my patch would frighten to death any Javascript developer, but one can't have everyone liking his code.

Here it is!

--- main.js.ori	2018-01-27 15:32:19.204510000 +0000
+++ main.min.js	2018-01-30 14:04:13.737996391 +0000
@@ -1,5 +1,6 @@
 // Plone 5 does not include global variables anymore
 var portal_url = (portal_url === undefined) ? $('body').attr('data-portal-url') : portal_url;
+if (portal_url == undefined) { portal_url = this.PORTAL_URL }
 
 $(function(){
   $('#content-core').glossarizer({

why this syntax is better now with Plone 5.1 is a JQuery mystery. It's far beyond my ken at the moment. Advice welcome if a master is passing here. I am ready to learn.

However, what of the resources ? I was completely wrong. The Javascript resources of collective.glossary were well and truly loaded all the time. I was missing them because they are hidden in the plone-legacy bundle. Yes your beautiful code is branded 'legacy' by the Plone core developers. I'm not responsible, that's just the fact. What had made me miss it is that I was not expecting it at all. There is also that they are minified by default so they are not exactly obvious in this awful Firefox debugger (you may have noticed that I have renamed your main.js to main.min.js to fool Plone into thinking it was already minified Javascript because debugging in a minified file with Firebug or whatever is not doable for me at least.)
And yes there is a resource bug, but not where you think; when unregistering an add-on the resources are not removed from the plone-legacy bundle. I'm planning to address that.
But with Plone 5.1 latest, the only sane way I have found to change the cooked code of an add-on inside plone-legacy is:

  1. uninstall the add-on
  2. remove by hand the resources from the plone-legacy bundle (click on the x for each collective.glossary resource); click Save, if Plone is loaded in foreground mode the console will display messages about cooking your javascript files
  3. change the files in whatever way you want: I used it to rename the resources to min.js to avoid minification and modified your main.js as shown
  4. install again the add-on; Plone will recook the plone-legacy bundle automatically again, with the changed code.