Skip to content

Commit

Permalink
Screenshotter 1.2.2
Browse files Browse the repository at this point in the history
* Fixed: Screenshotter not working on production.
  • Loading branch information
ConnorDoesDev authored Aug 30, 2024
1 parent ebd1f45 commit 71328d9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
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"
}

0 comments on commit 71328d9

Please sign in to comment.