向firefox添加覆盖文本

向firefox添加覆盖文本,firefox,firefox-addon,firefox-addon-sdk,Firefox,Firefox Addon,Firefox Addon Sdk,我正在为firefox编写一个字幕显示扩展,将自定义字幕覆盖到没有字幕的流视频上。这是我的第一次分机 如何在firefox上覆盖一行文本 如果不可能,如何创建一个可以打印字幕的窗格?您可以用html覆盖视频元素 但是,如果您想覆盖所有内容,则必须创建xul面板。以下是如何创建面板: var win = Services.wm.getMostRecentWindow('navigator:browser'); var panel = win.document.createElement('pane

我正在为firefox编写一个字幕显示扩展,将自定义字幕覆盖到没有字幕的流视频上。这是我的第一次分机

如何在firefox上覆盖一行文本


如果不可能,如何创建一个可以打印字幕的窗格?

您可以用html覆盖视频元素

但是,如果您想覆盖所有内容,则必须创建xul面板。以下是如何创建面板:

var win = Services.wm.getMostRecentWindow('navigator:browser');
var panel = win.document.createElement('panel');
var props = {
    type: 'arrow',
    style: 'width:300px;height:100px;'
}
for (var p in props) {
    panel.setAttribute(p, props[p]);
}

win.document.querySelector('#mainPopupSet').appendChild(panel);

panel.addEventListener('popuphiding', function (e) {
    e.preventDefault();
    e.stopPropagation();
    //panel.removeEventListener('popuphiding', arguments.callee, false); //if dont have this then cant do hidepopup after animation as hiding will be prevented
    panel.addEventListener('transitionend', function () {
        //panel.hidePopup(); //just hide it, if want this then comment out line 19 also uncomment line 16
        panel.parentNode.removeChild(panel); //remove it from dom //if want this then comment out line 18
    }, false);
    panel.ownerDocument.getAnonymousNodes(panel)[0].setAttribute('style', 'transform:translate(0,-50px);opacity:0.9;transition: transform 0.2s ease-in, opacity 0.15s ease-in');
}, false);

panel.openPopup(null, 'overlap', 100, 100);
发件人:

另见:


你试过什么?你读过吗?这里有一些非常明确的教程,告诉你如何做这两件事。我正在看Noitidart建议的覆盖图。这与我打算做的非常接近。例如,这里:但我相信它可能不支持我通常使用的流媒体网站,所以可能独立于内容的东西更好。我们将看到,docs示例似乎正是这样做的。如果您想使用更简单的addsdk,请按照该教程的说明进行操作@诺伊蒂达特的指示是为了