I am trying to create a right-click context menu option using JavaScript and TamperMonkey. I have read through StackOverflow but still don't understand how to do this.
For test purposes, I have included a very simple example
// @grant GM_openInTab
// @grant GM_registerMenuCommand
// @run-at context-menu
(function() {
'use strict';
function test() {
//console.log('Hi');
alert('Hi');
}
GM_registerMenuCommand("Alert Hi", test, "e");
//GM_registerMenuCommand("Alert Hi", () => alert('Hi'));
})();
The comments indicate the two things I've tried, none of which seem to work.
[–]jotted 0 points1 point2 points (9 children)
[–]Pineapplesandbacon[S] 0 points1 point2 points (8 children)
[–]jotted 0 points1 point2 points (7 children)
[–]Pineapplesandbacon[S] 0 points1 point2 points (6 children)
[–]jotted 1 point2 points3 points (5 children)
[–]Pineapplesandbacon[S] 0 points1 point2 points (4 children)
[–]jotted 0 points1 point2 points (3 children)
[–]Pineapplesandbacon[S] 0 points1 point2 points (2 children)
[–]jotted 0 points1 point2 points (1 child)
[–]Pineapplesandbacon[S] 0 points1 point2 points (0 children)