これは addon-builder [builder.addons.mozilla.org/] で開発している私の最初の Firefox 拡張機能です。
私の質問は簡単ですが、多くのことを試した後、何日も結果が得られません。
知りたい:ファイルのダウンロードを Firefox ダウンローダに追加するには??
http:// example.com/file.zipのような URLと、 D:\myFolderのようなファイルの場所があります。Firefox 拡張機能を使用してこのダウンロードを追加したいと考えています。
私が検索したものは次のとおりです。
https://developer.mozilla.org/en-US/docs/Code_snippets/Downloading_Files
Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
const WebBrowserPersist = Components.Constructor("@mozilla.org/embedding/browser/nsWebBrowserPersist;1",
"nsIWebBrowserPersist");
var persist = WebBrowserPersist();
var targetFile = Services.dirsvc.get("Desk", Ci.nsIFile);
targetFile.append("file.bin");
// Obtain the privacy context of the browser window that the URL
// we are downloading comes from. If, and only if, the URL is not
// related to a window, null should be used instead.
var privacy = PrivateBrowsingUtils.privacyContextFromWindow(urlSourceWindow);
persist.persistFlags = persist.PERSIST_FLAGS_FROM_CACHE
| persist.PERSIST_FLAGS_REPLACE_EXISTING_FILES;
persist.saveURI(uriToSave, null, null, null, "", targetFile, privacy);
可能な限り簡単なダウンロード機能を利用できる場所から始めていただけますか。