Hmm, I think dactyl is a Module as defined in
https://github.com/5digits/dactyl/blob/master/common/modules/main.jsm but not in the Javascript Code Module way that I meant. I don't have time to make a minimal add-on right now that just creates an empty module (though it shouldn't be hard to do), but if you want you could install my add-on Zutilo (available here:
https://addons.mozilla.org/en-US/firefox/addon/zutilo-utility-for-zotero/). If you don't use the Zotero add-on, it will complain about Zotero not being installed but you can check a box to suppress the warning in the future. Then Zutilo will basically do nothing other than export an object named Zutilo from its Javascript Code Module. Then you could put this in your autocommands.js plugin:
if (!('commands_loaded' in Zutilo)) {
Zutilo.commands_loaded = true
commands.execute(':autocmd PageLoad
duckduckgo.com -js alert("test")')
}
With this, the autocmd is only defined inside the first window and not in subsequent windows. A couple things to keep in mind:
If you close that first window, you will lose your autocommand.
If you rehash Pentadactyl, the Zutilo attribute will already be defined so the autocommand will not be added in the new Pentadactyl session. (You could do ":js delete Zutilo.commands_loaded" and then rehash again to have it defined again).