Tampermonkey - Right click menu

一世执手 提交于 2019-12-04 03:19:58

As per wOxxOm comment, it is possible using @run-at context-menu.

Example:

// ==UserScript==
// @name            Go to Website.Net
// @namespace       http://tampermonkey.net/
// @description     Context menu to execute UserScript
// @version         0.1
// @author          author
// @include         *
// @grant           GM_openInTab
// @run-at          context-menu
// ==/UserScript==]


(function() {
    'use strict';
    GM_openInTab("https://website.net");
})();

Result: (works nicely :)

Instead of GM_registerMenuCommand("hello", test(), "h") you should have GM_registerMenuCommand("hello", test, "h")

The first version calls the test function immediately, and then passes its result to GM_registerMenuCommand function. The second passes the function itself instead of its result.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!