我正在尝试移植一个Chrome扩展,它可以使用Firefox45.0.1以编程方式创建文件并将其下载到Firefox WebExtension。
这是Javascript代码:
text = '{"greeting":"Hello, World!"}';
var a = document.createElement('a');
var file = new Blob([text], {type: 'text/json'});
a.href = URL.createObjectURL(file);
我在用打字本编写一个网络扩展程序。因为我想同时瞄准Chrome和Firefox,所以我需要这个。
导入它看起来如下所示:
import browser from "webextension-polyfill"
打字本抱怨could not find a declaration file for webextension-polyfill。但是有一个具有类型定义的npm模块:@types/firefox-webext-browser。我安装了这个模块。
我需要导入,因为我使用一个绑定程序来打包所有这些代码。如果我没有显式地导入这个多边形填充,绑定器将不会获取依赖项,并且在运行时,