resource:// URI for Zotero 7 plugins

82 views
Skip to first unread message

Joachim Herb

unread,
Nov 14, 2023, 3:32:47 AM11/14/23
to zotero-dev
In the dcoumentation for plugin developers for Zotero 7 (https://www.zotero.org/support/dev/zotero_7_for_developers) it is explained, how to replace chrome:// and locale:// URI but not, how to do this for resource://. Here is an example to do it in the bootstrap javascript/truescript file:

const resProto = Cc['@mozilla.org/network/protocol;1?name=resource'].getService(Ci.nsISubstitutingProtocolHandler);
const uri = Services.io.newURI(`${rootURI  }resource/`);
resProto.setSubstitutionWithFlags('zotero-api-endpoint', uri, resProto.ALLOW_CONTENT_ACCESS);


(zotero-api-endpoint is the plugin name like make-it-red in the example for chrome)

The resource folder in this example is located in the root of the packed .xpi file.

The content of this folder can then be accessed with URI like:
resource://zotero-api-endpoint/schema/add-attachment-from-file.json

Perhaps this information can be added to the documentation page on the website. It was hard to find it. I found it here:
Reply all
Reply to author
Forward
0 new messages