extensions including chrome://zotero/content/include.js

62 views
Skip to first unread message

Emiliano Heyns

unread,
Oct 18, 2021, 6:42:24 AM10/18/21
to zotero-dev
Should overlay extensions include chrome://zotero/content/include.js, or assume it has already ran? I see I've always done this to make sure the Zotero object is always available, but with both BBT and the sci-hub extension doing the same, the onpaneload handler in BBTs overlay is never triggered, and it is triggered if I remove includes of chrome://zotero/content/include.js from the sci-hub extension.

Currently my tests are running on a BBT build that just never includes chrome://zotero/content/include.js, and they seem to pass just fine, so - is this include of chrome://zotero/content/include.js required? desirable? To be avoided?

Emiliano Heyns

unread,
Oct 18, 2021, 6:45:38 AM10/18/21
to zotero-dev
Is ESM supported in addons? If so, there may be no need to host addon code on the Zotero object. ESM modules are singletons, so I could just import what I need when I need it. It would simplify a lot about BBT, and also make it more robust.

adoma...@gmail.com

unread,
Oct 18, 2021, 10:45:47 AM10/18/21
to zotero-dev
Oh, I responded about this in another thread. No, you only need to include `include.js` if you create your own windows. If you are extending existing Zotero UIs where Zotero has the include, you don't need to do it again and it might break things.

We have a hacky rudimentary support for ESM modules, but it's limited to things included with Zotero and it sometimes creates problems with caching. You may be able to set up a require function yourself that points to resources included in BBT. See require.js in Zotero codebase.

Emiliano Heyns

unread,
Oct 19, 2021, 4:19:09 AM10/19/21
to zotero-dev
I've seen that, but the reason I'm asking is that eg https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/ says "With the release of Firefox 60 in May (2018), all major browsers will support ES modules" and I wondered if that extended to chrome code. They're talking about import statements though, not require calls. If import statements work (which I'll try over the weekend), addons would not ned to graft themselves onto the Zotero object. They could just do relative imports to access all their code.

Emiliano Heyns

unread,
Jan 17, 2022, 12:04:57 PM1/17/22
to zotero-dev
Is the zotero object guaranteed to exist in an overlay of zoteropane.xul?
Reply all
Reply to author
Forward
0 new messages