When you write a plug-in, you suddenly find that you need a switch button.
What should I do?
Call the underlying API to implement?
It may not be too much trouble,
and after deleting the menu, the new menu will change its position up and down.
In short, dig the pit slowly.
Well, there is a switch menu library packaged today,
which perfectly solves the problem of batch adding switch menus.
OK, have a good time!

See here for details:
https://openuserjs.org/libs/wishingking/SwitchMenu

You see:
enter image description here

example:

//GM_registerMenuCommand GM_unregisterMenuCommand must be granted
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// @require      https://openuserjs.org/src/libs/wishingking/SwitchMenu.js

SwitchMenu.add([
    {
        on : {
            default : true,
            name : "Open",
            callback : function(){
                alert("I'm Open.");
            }
        },
        off : {
            name : "Close",
            callback : function(){
                alert("I'm Close.");
            }
        }
    },
    {
        on : {
            name : "Edit",
            accessKey: 'E',
            callback : function(){
                alert("I am editing");
            }
        },
        off : {
            default : true,
            name : "Exit Edit",
            accessKey: 'X',
            callback : function(){
                alert("I'm exit.");
            }
        }
    }
]);
SwitchMenu.create();

Or:

SwitchMenu.add({
    on : {
        default : true,
        name : "Open",
        callback : function(){
            alert("I'm Open.");
        }
    },
    off : {
        name : "Close",
        callback : function(){
            alert("I'm Close.");
        }
    }
});
SwitchMenu.add({
    on : {
        default : true,
        name : "Open",
        callback : function(){
            alert("I'm Open.");
        }
    },
    off : {
        name : "Close",
        callback : function(){
            alert("I'm Close.");
        }
    }
});
SwitchMenu.create();

The last code of the above example is copied incorrectly. The correct code should be as follows:

SwitchMenu.add({
    on : {
        name : "Edit",
        accessKey: 'E',
        callback : function(){
            alert("I am editing");
        }
    },
    off : {
        default : true,
        name : "Exit Edit",
        accessKey: 'X',
        callback : function(){
            alert("I'm exit.");
        }
    }
});

@wishingking

If you are just going to delete the library after announcing it you might want to not consider advertising it here.

We do have the listing on the Libraries page, sorted by recently updated just like Userscripts, to do this sort of thing along with the Script Info as you already know.

OUJS Admin

Re: @wishingking:

but I don't know why it became a new library.

That is how it works. If you change @name it makes sense that's a new script.


Btw if you flag a library for moderation again and mark it as a "favorite" that could be grounds for removal for flagging abuse.

Use the up and down arrows if you like or dislike a script library not the Flag for moderation.

Appreciate your cooperation,
OUJS Admin

The above picture is not visible. The effect is as follows:
enter image description here

Why forum posts are not allowed to be modified?