The problem is, at boot time, a plugin may want to listen to a plugin hook for a plugin which is loaded, but hasn't yet run its own setup, so addHook() will fail. The correct way to add callbacks for plugin hooks is something along the lines of the following:
function setup() {
function addMyHooks() {
window.addHook('pluginDrawTools', function(e) {
// actual hook code here
});
}
if(window.iitcLoaded) {
addMyHooks();
} else {
window.addHook('iitcLoaded', addMyHooks);
}
}
but that's (a) ugly and (b) unobvious, so every plugin author just calls pluginCreateHook.
I think the right fix is just to not check for VALID_HOOKS in addHook.
Example here, but it's literally every plugin which depends on another plugin which isn't fragile:
https://github.com/iitc-project/ingress-intel-total-conversion/blob/0fabfb68943fc833153d89454220fa638a8b9fb6/plugins/cross_link.user.js#L296
The problem is, at boot time, a plugin may want to listen to a plugin hook for a plugin which is loaded, but hasn't yet run its own setup, so addHook() will fail. The correct way to add callbacks for plugin hooks is something along the lines of the following:
but that's (a) ugly and (b) unobvious, so every plugin author just calls pluginCreateHook.
I think the right fix is just to not check for VALID_HOOKS in addHook.