简体   繁体   English

Chrome 扩展强制左键单击

[英]Chrome extension force left click

Hı I made a simple chrome extension.嗨,我做了一个简单的 chrome 扩展。 But what ı need is that when user left click the extension icon it will show right click menu.但是我需要的是,当用户左键单击扩展图标时,它将显示右键菜单。 I know some extension does that but ı dont know how to do.我知道一些扩展可以做到这一点,但我不知道该怎么做。

chrome.browserAction.onClicked.addListener(buttonClicked)
function buttonClicked(tab) {
//Force to right click

}

You need to disable the popup for the current tab.您需要禁用当前选项卡的弹出窗口。

  • If you use page_action the popup will be disabled by default unless you explicitly enable it on this tab.如果您使用page_action ,则默认情况下将禁用弹出窗口,除非您在此选项卡上明确启用它。

  • If you use browser_action , you can disable the popup explicitly:如果您使用browser_action ,则可以显式禁用弹出窗口:

     chrome.tabs.query({currentWindow: true, active: true}, tabs => chrome.browserAction.disable(tabs[0].id); });

This is currently not possible, but someone made a library that does a neat trick to make your own mouse that you can control and do stuff with.目前这是不可能的,但是有人制作了一个库,它做了一个巧妙的技巧来制作你自己的鼠标,你可以控制和做一些事情。 You can probably use that idea.您可能可以使用该想法。 I checked it by making an tag on the h2 header and it actually redirected me to the link.我通过在 h2 header 上制作标签来检查它,它实际上将我重定向到链接。 It does have some fullbacks.它确实有一些后卫。 For example, the user can press the sec key and stop it from working.例如,用户可以按下 sec 键并使其停止工作。 That can be fixed by automatically controlling the mouse again but then there are the popups that start appearing which is another fallback.这可以通过再次自动控制鼠标来解决,但随后会出现弹出窗口,这是另一个后备。 Still, it works.尽管如此,它仍然有效。 It might be a bit of hard work to set up.设置起来可能有点困难。 I created an issue in the Chromium Bug Tracker.我在 Chromium Bug Tracker 中创建了一个问题。 Here is the library: https://github.com/octalmage/mousecontrol .这是图书馆: https://github.com/octalmage/mousecontrol Happy hacking!快乐黑客!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM