That gets me closer. I'm trying to dynamically load what was previously an overlay using
// boring bits
const prefwindow = win.document.querySelector('prefwindow#zotero-prefs')
if (!prefwindow) return log.error('prefs.start: prefwindow not found')
let xml = Zotero.File.getContentsFromURL('chrome://zotero-better-bibtex/content/Preferences.xul')
const url = xml.match(/<!DOCTYPE window SYSTEM "([^"]+)">/)[1]
const dtd: Record<string, string> = dtdparser.parse(Zotero.File.getContentsFromURL(url))
for (const [key, value] of Object.entries(dtd)) {
xml = xml.replace(new RegExp(`&${key};`, 'g'), escapeHtml(value))
}
// interesting bit starts here
const parser = new DOMParser
const xul = parser.parseFromString(xml, 'text/xml')
const prefpane = xul.querySelector('prefpane')
const id: string = prefpane.getAttribute('id') + '2' // eslint-disable-line @typescript-eslint/restrict-plus-operands
log.debug('prefs id=', id)
if (win.document.querySelector(`prefpane#${id}`)) return // already loaded
log.debug('prefpane: strip load')
prefpane.removeAttribute('load')
log.debug('prefpane: append')
prefwindow.appendChild(prefpane) // nope
log.debug('prefpane: appended')
The top isn't really interesting, it just makes sure I have valid XML content. Everything works fine until the line commented with "nope", that gets me
JavaScript error: chrome://global/content/bindings/tabbox.xml, line 250: TypeError: children[i].getAttribute is not a function
JavaScript error: chrome://global/content/bindings/menulist.xml, line 236: TypeError: val.setAttribute is not a function
JavaScript error: chrome://global/content/bindings/menulist.xml, line 236: TypeError: val.setAttribute is not a function
JavaScript error: chrome://global/content/bindings/menulist.xml, line 236: TypeError: val.setAttribute is not a function
JavaScript error: chrome://global/content/bindings/menulist.xml, line 236: TypeError: val.setAttribute is not a function
JavaScript error: chrome://global/content/bindings/menulist.xml, line 236: TypeError: val.setAttribute is not a function
JavaScript error: chrome://global/content/bindings/menulist.xml, line 236: TypeError: val.setAttribute is not a function
JavaScript error: chrome://global/content/bindings/menulist.xml, line 236: TypeError: val.setAttribute is not a function
JavaScript error: chrome://global/content/bindings/menulist.xml, line 236: TypeError: val.setAttribute is not a function
JavaScript error: chrome://global/content/bindings/menulist.xml, line 236: TypeError: val.setAttribute is not a function
JavaScript error: chrome://global/content/bindings/menulist.xml, line 236: TypeError: val.setAttribute is not a function
JavaScript error: chrome://global/content/bindings/tabbox.xml, line 250: TypeError: children[i].getAttribute is not a function
JavaScript error: chrome://global/content/bindings/menulist.xml, line 236: TypeError: val.setAttribute is not a function
JavaScript error: chrome://global/content/bindings/menulist.xml, line 236: TypeError: val.setAttribute is not a function
JavaScript error: chrome://global/content/bindings/tabbox.xml, line 250: TypeError: children[i].getAttribute is not a function
JavaScript error: chrome://global/content/bindings/menulist.xml, line 229: TypeError: oldval.removeAttribute is not a function
but I can't find those bits of code anywhere in BBT or in Zotero.