FileSaver webextension

时间:2018-05-23 17:29:30

标签: javascript firefox firefox-webextensions filesaver.js

我想使用FileSaver从我的网络扩展程序下载文件,我可以通过内容脚本下载,但是当我尝试在background.js下载时,它不起作用。

这是我的manifest.json:

"manifest_version": 2,
"name": "Logger",
"version": "1.0",

"description": "Captures the interaction between the user and the browser.",

"icons": {
    "48": "icons/logger-48.png"
},

"background": {
    "scripts": ["FileSaver.js", "background.js"]
},

"content_scripts": [
    {
        "matches": ["*://*.mozilla.org/*"],
        "js": ["jquery-3.2.1.min.js", "loggerPlugin.js"]
    }
],

"browser_action": {
    "default_icon": "icons/logger-32.png",
    "default_title": "Logger",
    "default_popup": "popup/loggerPopup.html"
}

这是background.js中的代码:

function save(){
    console.log("FUNCAOSAVE");
    var blob = new Blob(["Hello, World!"], {type: "text/plain;charset=utf-8"});
    saveAs(blob, "log.txt");
}
save();

0 个答案:

没有答案