Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(screenshotter): add setting to save as file & copy #227

Merged
merged 6 commits into from
Aug 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/screenshoter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ class Screenshoter extends Addon {
}
});

this.settings.add(`${this.settingsNamespace}.copyAndDownload`, {
default: false,
ui: {
path: 'Add-Ons > Screenshoter >> Behavior',
title: 'Copy to clipboard & Save as file',
description: 'Enable this if you wish to save a screenshot to the clipboard (if supported by your browser) and download it as a file.',
component: 'setting-check-box'
}
});

this.settings.add(`${this.settingsNamespace}.shortcut`, {
default: 'ctrl+alt+shift+q',
ui: {
Expand Down Expand Up @@ -242,6 +252,10 @@ class Screenshoter extends Addon {
context.drawImage(video, 0, 0, canvas.width, canvas.height)

canvas.toBlob((blob) => {
if (this.settings.get(`${this.settingsNamespace}.copyAndDownload`)) {
this.saveToClipboard(blob);
this.saveToFile(blob);
};
const clipboard = this.settings.get(`${this.settingsNamespace}.clipboard`)
clipboard ? this.saveToClipboard(blob) : this.saveToFile(blob)
})
Expand All @@ -250,4 +264,4 @@ class Screenshoter extends Addon {
}
}

Screenshoter.register()
Screenshoter.register()
Loading