How to use the webextension-polyfill.downloads function in webextension-polyfill

To help you get started, we’ve selected a few webextension-polyfill examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FirefoxBar / HeaderEditor / src / core / file.js View on Github external
return new Promise(function(resolve){
			const blob = new Blob([text]);
			const fileUrl = URL.createObjectURL(blob);
			const option = {filename: fileName, url: fileUrl};
			// Firefox supported saveAs since version 52
			if (utils.IS_CHROME || (!utils.IS_ANDROID && utils.FIREFOX_VERSION >= 52)) {
				option.saveAs = true;
			}
			browser.downloads.download(option).then(resolve);
		});
	},
github sienori / Tab-Session-Manager / src / background / export.js View on Github external
export default async function exportSessions(id = null) {
  log.log(logDir, "exportSessions()", id);
  let sessions = await getSessions(id);
  if (sessions == undefined) return;
  if (!Array.isArray(sessions)) sessions = [sessions];

  const downloadUrl = URL.createObjectURL(
    new Blob([JSON.stringify(sessions, null, "    ")], {
      type: "aplication/json"
    })
  );

  const fileName = generateFileName(sessions);

  await browser.downloads
    .download({
      url: downloadUrl,
      filename: `${fileName}.json`,
      conflictAction: "uniquify",
      saveAs: true
    })
    .catch(e => {
      log.warn(logDir, "exportSessions()", e);
    });
}
github sienori / Tab-Session-Manager / src / oldOptions / options.js View on Github external
export async function exportSessions(id = null) {
  let sessions = await getSessions(id);
  if (sessions == undefined) return;
  if (!Array.isArray(sessions)) sessions = [sessions];

  const downloadUrl = URL.createObjectURL(
    new Blob([JSON.stringify(sessions, null, "    ")], {
      type: "aplication/json"
    })
  );

  const fileName = returnFileName(sessions);

  await browser.downloads
    .download({
      url: downloadUrl,
      filename: `${fileName}.json`,
      conflictAction: "uniquify",
      saveAs: true
    })
    .catch(() => {});
}
github sienori / Tab-Session-Manager / src / oldOptions / ui.js View on Github external
export function openDownloadFolder() {
  browser.downloads.showDefaultFolder();
}
github SeleniumHQ / selenium-ide / packages / selenium-ide / src / neo / IO / filesystem.js View on Github external
}, (choseDownload) => {
        if (choseDownload) {
          browser.downloads.download({
            filename: project.name + "-logs.md",
            url: createBlob("text/markdown", markdown),
            saveAs: true,
            conflictAction: "overwrite"
          });
        }
      });
      return Promise.reject();
github SeleniumHQ / selenium-ide / packages / selenium-ide-extension / src / neo / IO / filesystem.js View on Github external
return exportProject(project).then(snapshot => {
    if (snapshot) {
      project.snapshot = snapshot
      Object.assign(project, Manager.emitDependencies())
    }
    return browser.downloads.download({
      filename: sanitizeProjectName(project.name) + '.side',
      url: createBlob(
        'application/json',
        beautify(JSON.stringify(project), { indent_size: 2 })
      ),
      saveAs: true,
      conflictAction: 'overwrite',
    })
  })
}
github sienori / Tab-Session-Manager / src / background / backup.js View on Github external
const sessions = await Sessions.getAll().catch(() => {});

  if (!getSettings("ifBackup")) return;
  if (sessions.length == 0) return;
  log.log(logDir, "backupSessions()");

  const downloadUrl = URL.createObjectURL(
    new Blob([JSON.stringify(sessions, null, "    ")], {
      type: "aplication/json"
    })
  );

  const backupFolder = replaceBackupFolderName(getSettings("backupFolder"));
  const fileName = returnFileName(sessions);

  await browser.downloads.download({
    url: downloadUrl,
    filename: `${backupFolder}${backupFolder == "" ? "" : "/"}${fileName}.json`,
    conflictAction: "uniquify",
    saveAs: false
  });
}