mock-violentmonkey
Version:
Mock violentmonkey's globals for testing userscripts
23 lines • 823 B
JavaScript
import { BetterMap } from '../utils/index.js';
import { VMStorage } from '../vm-storage.js';
const menuCommands = new VMStorage(() => new BetterMap());
const registerMenuCommand = (caption, onclick) => {
menuCommands.get(true).set(caption, onclick);
return caption;
};
const unregisterMenuCommand = caption => {
menuCommands.get(false)?.delete(caption);
};
const triggerMenuCommand = (caption) => {
menuCommands.get(false)?.get(caption)?.();
};
export { registerMenuCommand as GM_registerMenuCommand, unregisterMenuCommand as GM_unregisterMenuCommand, triggerMenuCommand, };
Object.defineProperties(globalThis, {
GM_registerMenuCommand: {
value: registerMenuCommand,
},
GM_unregisterMenuCommand: {
value: unregisterMenuCommand,
},
});
//# sourceMappingURL=menu-command.js.map