简体   繁体   English

如何使 Chrome 扩展弹出窗口可拖动?

[英]How to make Chrome Extension popup draggable?

I noticed that the 1password chrome extension browser action popup is draggable.我注意到 1password chrome 扩展浏览器操作弹出窗口是可拖动的。 How can I make my own chrome extension do the same thing?我怎样才能让我自己的 chrome 扩展做同样的事情? I can't seem to find anything in the chrome extension docs.我似乎在 chrome 扩展文档中找不到任何内容。

A few other features the 1password chrome extension popup has that I also can't find in the docs. 1password chrome 扩展弹出窗口的其他一些功能我在文档中也找不到。

  • When the 1password popup appears, there's a little triangle at the top of the popup which appears where my cursor is.当 1password 弹出窗口出现时,弹出窗口顶部有一个小三角形,出现在我的 cursor 所在的位置。 How does this happen?这是怎么发生的? As far as I'm aware, then html document I associate with the popup is displayed as a rectangle without the triangle.据我所知,与弹出窗口关联的 html 文档显示为没有三角形的矩形。
  • I can't right-click on the body of the 1password popup to inspect javascript.我无法右键单击 1password 弹出窗口的主体来检查 javascript。 Could this be because they overrode the default contextMenu behavior?这可能是因为它们覆盖了默认的 contextMenu 行为吗?

The standard popup window cannot be dragged, neither you can add anything outside of its borders.标准弹出窗口 window 不能拖动,也不能在其边界之外添加任何内容。 It's a popup page declared via browser_action or page_action in manifest.json.它是通过 manifest.json 中的browser_actionpage_action声明的弹出页面。

The workarounds are:解决方法是:

To inspect pages that block the context menu you can open devtools from the browser menu, then "More tools", or focus the address bar first, then press the hotkey to open devtools ( Ctrl Shift i or F12 in Windows) or from the internal UI page chrome://inspect/#pages .要检查阻止上下文菜单的页面,您可以从浏览器菜单打开 devtools,然后是“更多工具”,或者首先关注地址栏,然后按热键打开 devtools(在 Windows 中为Ctrl Shift iF12 )或从内部UI 页面chrome://inspect/#pages

PS technically you can write an external utility and run it via nativeMessaging so it'll use a low-level OS API to move the standard popup window, but that's very fragile. PS 从技术上讲,您可以编写一个外部实用程序并通过nativeMessaging运行它,因此它将使用低级操作系统 API 来移动标准弹出窗口 window,但这非常脆弱。

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

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