是否可以使用Firefox扩展创建OS浮动窗口?这样当浏览器失去焦点时窗口就会出现。谷歌搜索没有带来太多。只需要一些教程/写一下。
目标操作系统 - Mac OS X,如果重要的话。
如果你觉得这个问题很愚蠢,我道歉。起初我想知道是否可行和可行。 任何想法都表示赞赏。答案 0 :(得分:0)
来自Firebug工作组的像素完美扩展就是这样 - 请参阅此文件以获得完整实施:
https://github.com/firebug/pixel-perfect/blob/master/lib/pixel-perfect-popup.js
创建弹出窗口的核心代码是一个名为' createPanel'在line 149:
createPanel: function() {
let browser = getMostRecentBrowserWindow();
let doc = browser.document;
this.panel = doc.createElementNS(XUL_NS, "panel");
this.panel.setAttribute("id", "pixel-perfect-panel");
this.panel.setAttribute("noautohide", "true");
this.panel.setAttribute("titlebar", "normal");
this.panel.setAttribute("noautofocus", "true");
this.panel.setAttribute("label", Locale.$STR("pixelPerfect.title"));
this.panel.setAttribute("close", "true");
this.panel.style.border = "0";
this.panelFrame = doc.createElementNS(XUL_NS, "iframe");
this.panelFrame.setAttribute("type", "content");
this.panelFrame.setAttribute("border", "0");
this.panelFrame.setAttribute("flex", "1");
// xxxHonza: unregister listeners?
DomEvents.on(this.panel, "popuphidden", this.onPopupHidden);
DomEvents.on(this.panel, "popupshown", this.onPopupShown);
this.panelFrame.setAttribute("src", self.data.url("./popup.html"));
this.panel.appendChild(this.panelFrame);
let container = doc.getElementById("mainPopupSet");
container.appendChild(this.panel);
// Load content script and handle messages sent from it.
let { messageManager } = this.panelFrame.frameLoader;
if (messageManager) {
let url = self.data.url("popup-frame-script.js");
messageManager.loadFrameScript(url, false);
messageManager.addMessageListener("message", this.onMessage);
messageManager.addMessageListener("sdk/event/ready", this.onPanelReady);
}
return this.panel;
},