小编Pet*_*yan的帖子

除了调试时,Chrome pageAction图标不会显示

我正在尝试显示Chrome pageAction图标,但它只会在页面加载后短暂闪烁然后消失.

然而,让我感到困惑的是,当我使用Dev Tools调试器并在chrome.pageAction.show()调用上粘贴断点时,它完美无缺!这是我的manifest.json:

{
    "manifest_version": 2,
    "name": "20130409-test",
    "description": "Page action icons don't work!",
    "version": "0.1",
    "icons": {"16": "icon16.png", "48": "icon48.png", "128": "icon128.png"},
    "background": {
        "scripts": ["background.js"],
        "persistent": true
    },
    "permissions": [
        "<all_urls>",
        "webRequest",
        "webRequestBlocking"
    ],
    "page_action": {
        "default_icon": {
            "19": "icon19.png",
            "38": "icon38.png"
        },
        "default_title": "Page action title here!"
    }
}
Run Code Online (Sandbox Code Playgroud)

我的background.js页面是:

chrome.webRequest.onSendHeaders.addListener(
    function(details) {
        chrome.pageAction.show(details.tabId);
        chrome.pageAction.setTitle({
            "tabId": details.tabId,
            "title": "url=" + details.url
        });
    },
    {urls: ["<all_urls>"], types: ["main_frame"]},
    ["requestHeaders"]
);
Run Code Online (Sandbox Code Playgroud)

google-chrome-extension

3
推荐指数
1
解决办法
2287
查看次数

标签 统计

google-chrome-extension ×1