MCPcopy Create free account
hub / github.com/Tampermonkey/tampermonkey / TM_registerMenuCommand

Function TM_registerMenuCommand

src/environment.js:648–667  ·  view source on GitHub ↗
(name, fn)

Source from the content-addressed store, hash-verified

646/* ######### TM/GM Functions ############ */
647
648var TM_registerMenuCommand = function(name, fn) {
649 var menuId = TM_context_id + '#' + name;
650 var onUnload = function() {
651 if (V) console.log("env: unRegisterMenuCMD due to unload " + fn.toString());
652 chromeEmu.extension.sendMessage({method: "unRegisterMenuCmd", name: name, id: menuId}, function(response) {});
653 };
654 var resp = function(response) {
655 // response is send, command is unregisterd @ background page
656 window.removeEventListener('unload', onUnload, false);
657 if (response.run) {
658 if (V) console.log("env: execMenuCmd " + fn.toString());
659 window.setTimeout(function () { fn(); }, 1);
660 // re-register for next click
661 TM_registerMenuCommand(name, fn);
662 }
663 };
664 window.addEventListener('unload', onUnload, false);
665 if (V) console.log("env: registerMenuCmd " + fn.toString());
666 chromeEmu.extension.sendMessage({method: "registerMenuCmd", name: name, id: TM_context_id, menuId: menuId}, resp);
667};
668
669var TM_openInTab = function(url, options) {
670 // retrieve tabId to have a chance of closing this window lateron

Callers 2

respFunction · 0.85
GM_EMUFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…