将弹出窗格添加到交叉滚动加载项图标并将闪烁图标添加到加载项图标

时间:2014-07-05 19:08:09

标签: crossrider

我想将我现有的firefox和chrome加载项迁移到crossrider,以便将它与safari和IE一起使用,但我有一些疑问,可能Schlomo(或任何Crossrider开发者)可以帮我解决它们。

问题:

  1. 当有人点击其中显示某种选项的附加按钮时,我可以添加一个弹出窗格吗?

  2. 我可以在实际图标上添加一个闪烁的图标,显示发生某种事件,例如来电聊天吗?

  3. 有没有办法添加红色文本框,就像在图标右下角显示某种文字的铬?

  4. 非常感谢!

1 个答案:

答案 0 :(得分:3)

当你提出这样的问题时,我只能希望以下答案能够减轻你的疑虑和启发:)

首先,我建议您一般熟悉How to add a browser button to your Crossrider extensionbutton popup feature

回答您的具体问题:

  1. 您可以使用按钮弹出功能并在其中构建所需的选项。请查看Button Popup Menu演示扩展程序,以帮助您入门。
  2. 虽然您无法使按钮闪烁,但您可以交替使用按钮图标使其看起来像闪烁(参见示例)。
  3. 简而言之,是的。只需使用appAPI.browserAction.setBadgeTextappAPI.browserAction.setBadgeBackgroundColor方法(参见示例)。
  4. 以下示例汇总了实现上述解决方案所需的background.js代码中的关键元素。查看Button Popup Menu中的popup.html文件,了解如何构建选项页面的示例。

    appAPI.ready(function() {
        var sid, // Blink interval id
            alt=0, // Blink alternation state
            icon = { // Blink icons
                0: 'icons/icon0.png',
                1: 'icons/icon1.png'
            };
    
        // Set the initial icon for the button
        appAPI.browserAction.setResourceIcon(icon[0]);
        // Sets the popup for the button
        appAPI.browserAction.setPopup({
            resourcePath:'html/popup.html',
            height: 300,
            width: 300
        });
    
        if (true) { // blink condition, set to true for this example
            // Blink icon
            sid = appAPI.setInterval(function() {
                alt = 1 - alt;
                appAPI.browserAction.setResourceIcon(icon[alt]);
            }, 1 * 1000);
        } else {
            appAPI.clearInterval(sid);
        }
    
        if (true) { // show button text condition, set to true for this example
            // Add red text box to icon
            appAPI.browserAction.setBadgeText('ext', [255,0,0,255]);
        }
    });
    

    [披露:我是一名交叉员工]

相关问题