chrome扩展下载API响应缓慢,并且不会更改文件名

时间:2017-09-11 16:28:58

标签: google-chrome google-chrome-extension

我使用Chrome消息功能发送文件名并链接到后台页面

  chrome.runtime.sendMessage({link: thelink, name:filename}, function(response) {});

background.js

   chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
        console.log(message.name);
            chrome.downloads.download({
                                url: message.link,
                                filename: message.name,
                                conflictAction: 'prompt'
                            });

        });

我的manifest.json

{
    "manifest_version": 2,
    "name": "4ch",
    "description": "This extension shows a Google Image search result for the current page",
    "version": "1.0",
    "icons": {
        "16": "4ch-icon-16.png", "48": "4ch-icon-48.png", "128": "4ch-icon-48.png"
    }
    ,
    "permissions": ["downloads",
    "<all_urls>",
    "contextMenus"],
    "content_scripts": [{

      "js": ["script/jquery.js", "script/reddit.js"],
       "matches": ["*://*.reddit.com/*"]  
    }


    ],
    "background": {
        "scripts": ["script/jquery.js","script/eventpage.js"], "persistent": false
    }
}

下载仅在几秒钟后开始,并且不会更改文件名

1 个答案:

答案 0 :(得分:0)

我已经解决了问题。 'download master'扩展名与我自己的扩展名相冲突,因此它不会替换原始文件名。我已禁用它