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

last PR for screenshotter #236

Merged
merged 8 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 17 additions & 6 deletions src/screenshotter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Screenshotter extends Addon {
this.inject('site.fine')
this.inject('site.player')
this.inject('site.web_munch')
this.inject('settings') // Who knows bro

this.onShortcut = this.onShortcut.bind(this)

Expand Down Expand Up @@ -252,17 +253,27 @@ class Screenshotter extends Addon {
context.drawImage(video, 0, 0, canvas.width, canvas.height)

canvas.toBlob((blob) => {
if (!this.settings.get(`${this.settingsNamespace}.download`) || !this.settings.get(`${this.settingsNamespace}.copy`)) return this.saveToClipboard(blob); // Default to clipboard if both settings r turned off for some reason
if (this.settings.get(`${this.settingsNamespace}.download`)) {
const shouldDownload = this.settings.get(`${this.settingsNamespace}.download`);
const shouldCopy = this.settings.get(`${this.settingsNamespace}.copy`);

if (!shouldDownload && !shouldCopy) return this.saveToClipboard(blob);

if (shouldDownload) {
this.saveToFile(blob);
}
if (this.settings.get(`${this.settingsNamespace}.copy`)) {
this.saveToClipboard(blob);

if (shouldCopy) {
if (shouldDownload) {
// use a timeout or some mechanism to delay clipboard copy after download
setTimeout(() => this.saveToClipboard(blob), 100);
} else {
this.saveToClipboard(blob);
}
}
})
});

canvas.remove()
}
}

screenshotter.register()
Screenshotter.register()
7 changes: 4 additions & 3 deletions src/screenshotter/manifest.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"enabled": true,
"requires": [],
"version": "1.2.1",
"version": "1.2.2",
"short_name": "screenshotter",
"name": "Screenshotter",
"author": "c0nnorgg",
"author": "CJMAXiK",
"maintainer": "c0nnorgg",
"description": "Allows you to take screenshots of the player using a button/shortcut.",
"settings": "add_ons.screenshotter",
"created": "2023-08-21T05:00:35.637Z",
"updated": "2023-08-12T22:26:38.618Z"
"updated": "2024-08-13T13:03:22.618Z"
}
Loading