From d6ff2ce38b3a3344ed10f56a3d52e15941f373ad Mon Sep 17 00:00:00 2001 From: Magic Date: Thu, 26 Sep 2024 10:28:36 -0700 Subject: [PATCH] v6.7.2 Signed-off-by: Magic --- dist/magic-userjs.meta.js | 4 +++- dist/magic-userjs.user.js | 35 ++++++++++++++++++++++++++++++++++- package.json | 4 +++- src/UserJS/main.js | 31 +++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 3 deletions(-) diff --git a/dist/magic-userjs.meta.js b/dist/magic-userjs.meta.js index 731d156..615991a 100644 --- a/dist/magic-userjs.meta.js +++ b/dist/magic-userjs.meta.js @@ -1,5 +1,5 @@ // ==UserScript== -// @version 6.7.1 +// @version 6.7.2 // @name Magic Userscript+ : Show Site All UserJS // @name:ar Magic Userscript+: عرض جميع ملفات UserJS // @name:de Magic Userscript+ : Website anzeigen Alle UserJS @@ -45,12 +45,14 @@ // @grant GM_getValue // @grant GM_openInTab // @grant GM_setValue +// @grant GM_registerMenuCommand // @grant GM_xmlhttpRequest // @grant GM.addElement // @grant GM.info // @grant GM.getValue // @grant GM.openInTab // @grant GM.setValue +// @grant GM.registerMenuCommand // @grant GM.xmlHttpRequest // @match https://*/* // @noframes diff --git a/dist/magic-userjs.user.js b/dist/magic-userjs.user.js index 958b4a6..e70d53a 100644 --- a/dist/magic-userjs.user.js +++ b/dist/magic-userjs.user.js @@ -1,5 +1,5 @@ // ==UserScript== -// @version 6.7.1 +// @version 6.7.2 // @name Magic Userscript+ : Show Site All UserJS // @name:ar Magic Userscript+: عرض جميع ملفات UserJS // @name:de Magic Userscript+ : Website anzeigen Alle UserJS @@ -45,12 +45,14 @@ // @grant GM_getValue // @grant GM_openInTab // @grant GM_setValue +// @grant GM_registerMenuCommand // @grant GM_xmlhttpRequest // @grant GM.addElement // @grant GM.info // @grant GM.getValue // @grant GM.openInTab // @grant GM.setValue +// @grant GM.registerMenuCommand // @grant GM.xmlHttpRequest // @match https://*/* // @noframes @@ -755,6 +757,31 @@ const StorageSystem = { } } }; +class jsCommand { + constructor() { + this.cmds = []; + } + register(text, command) { + if (!isGM) { + return; + } + + if (isFN(command)) { + const found = this.cmds.find(c => command === c); + if (found) { + return; + } + this.cmds.push(command); + } + + if (isFN(GM.registerMenuCommand)) { + GM.registerMenuCommand(text, command); + } else if (isFN(GM_registerMenuCommand)) { + GM_registerMenuCommand(text, command); + } + } +}; +const Command = new jsCommand(); /** * @type { import("../typings/UserJS.d.ts").Network } */ @@ -3192,6 +3219,12 @@ const init = async () => { } sleazyRedirect(); container.inject(primaryFN, doc); + Command.register('Inject Userscript+', () => { + container.inject(primaryFN, doc); + }); + Command.register('Close Userscript+', () => { + container.remove(); + }); } catch (ex) { err(ex); } diff --git a/package.json b/package.json index a24a90f..9efebe6 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "url": "https://github.com/magicoflolis/Userscript-Plus/issues" }, "userJS": { - "version": "6.7.1", + "version": "6.7.2", "name": "Magic Userscript+ : Show Site All UserJS", "description": "Finds available userscripts for the current webpage.", "bugs": "https://github.com/magicoflolis/Userscript-Plus/issues", @@ -62,12 +62,14 @@ "GM_getValue", "GM_openInTab", "GM_setValue", + "GM_registerMenuCommand", "GM_xmlhttpRequest", "GM.addElement", "GM.info", "GM.getValue", "GM.openInTab", "GM.setValue", + "GM.registerMenuCommand", "GM.xmlHttpRequest" ], "exclude": [], diff --git a/src/UserJS/main.js b/src/UserJS/main.js index ed5c8b1..2d640d6 100644 --- a/src/UserJS/main.js +++ b/src/UserJS/main.js @@ -651,6 +651,31 @@ const StorageSystem = { } } }; +class jsCommand { + constructor() { + this.cmds = []; + } + register(text, command) { + if (!isGM) { + return; + } + + if (isFN(command)) { + const found = this.cmds.find(c => command === c); + if (found) { + return; + } + this.cmds.push(command); + } + + if (isFN(GM.registerMenuCommand)) { + GM.registerMenuCommand(text, command); + } else if (isFN(GM_registerMenuCommand)) { + GM_registerMenuCommand(text, command); + } + } +}; +const Command = new jsCommand(); /** * @type { import("../typings/UserJS.d.ts").Network } */ @@ -3088,6 +3113,12 @@ const init = async () => { } sleazyRedirect(); container.inject(primaryFN, doc); + Command.register('Inject Userscript+', () => { + container.inject(primaryFN, doc); + }); + Command.register('Close Userscript+', () => { + container.remove(); + }); } catch (ex) { err(ex); }