From 71328d98aef709ba7b80a656ebbad7eac6c22e5e Mon Sep 17 00:00:00 2001 From: Connor Date: Fri, 30 Aug 2024 17:42:28 +0200 Subject: [PATCH] Screenshotter 1.2.2 * Fixed: Screenshotter not working on production. --- pnpm-lock.yaml | 2 +- src/screenshotter/index.js | 23 +++++++++++++++++------ src/screenshotter/manifest.json | 7 ++++--- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ab4f9f4c..b8fdc3f9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5457,4 +5457,4 @@ packages: /yocto-queue@0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} - dev: true + dev: true \ No newline at end of file diff --git a/src/screenshotter/index.js b/src/screenshotter/index.js index ff078ce8..5f156b3b 100644 --- a/src/screenshotter/index.js +++ b/src/screenshotter/index.js @@ -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) @@ -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() diff --git a/src/screenshotter/manifest.json b/src/screenshotter/manifest.json index 5592efd3..e9a6557e 100644 --- a/src/screenshotter/manifest.json +++ b/src/screenshotter/manifest.json @@ -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" }