gpt4 book ai didi

javascript - GM_registerMenuCommand()的 `accessKey`参数是什么,如何使用?

转载 作者:行者123 更新时间:2023-12-05 00:39:33 24 4
gpt4 key购买 nike

我在看 GM_registerMenuCommand Tampermonkey 中的函数,我注意到第三个参数称为 accessKey 并认为它是传递一个热键来触发这个命令。

传递的参数的格式是什么,我假设这是它的作用是不是错了?

我在任何地方都找不到有关该参数的文档。这里有人用过吗?

最佳答案

syntax for that function is :

GM_registerMenuCommand (menuName, callbackFunction, accessKey)

来自 Menu Design Guidelines (8号):

Dropdowns (both menus and boxes) should support not only mouse input, but keys as well. In dropdown menus, access keys should enable users to quickly select a visible option without using the mouse. In a dropdown box, users should be able to type a letter and quickly navigate to options starting with that letter.

(已添加重点。)

重要提示:Access keys are different from, and in addition to, any command shortcuts ("hotkeys") .


这是一个示例 Tampermonkey 工作脚本,说明了用法:

// ==UserScript==
// @name _GM_registerMenuCommand demo
// @match https://stackoverflow.com/questions/56024629/*
// @match *://YOUR_SERVER.COM/YOUR_PATH/*
// @grant GM_registerMenuCommand
// ==/UserScript==

/*-- GM_registerMenuCommand (menuName, callbackFunction, accessKey)
*/
GM_registerMenuCommand ("Say Hello", helloFunc, "H");

function helloFunc () {
console.log ("Say hello to my little script.");
}

如果你通过 Tampermonkey 安装并运行它,你会看到(点击查看大图):

Tampermonkey screenshot


注意事项:

  1. Violentmonkey ignores the accessKey parameter, for now.
  2. Greasemonkey 4+ has borked this feature . Per usual .
  3. 您可以set a keyboard command to activate the Tampermonkey icon/menu in Chrome .
  4. 目前在 Firefox 中似乎无法激活键盘图标,但 a workaround is scheduled for Firefox version 67 .

关于javascript - GM_registerMenuCommand()的 `accessKey`参数是什么,如何使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56024629/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com