From db0bcf7da39102c3502eb9a206eab55a2fbffa02 Mon Sep 17 00:00:00 2001 From: Elvyra <88881326+EepyElvyra@users.noreply.github.com> Date: Thu, 5 Jun 2025 02:18:20 +0200 Subject: [PATCH] WebContextMenus: Fix copying and saving images (#3459) --- src/plugins/webContextMenus.web/index.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/plugins/webContextMenus.web/index.ts b/src/plugins/webContextMenus.web/index.ts index 45e6fa00..666e51be 100644 --- a/src/plugins/webContextMenus.web/index.ts +++ b/src/plugins/webContextMenus.web/index.ts @@ -122,10 +122,16 @@ export default definePlugin({ { find: "Copy image not supported", - replacement: { - match: /(?<=(?:canSaveImage|canCopyImage)\(\i?\)\{.{0,50})!\i\.isPlatformEmbedded/g, - replace: "false" - } + replacement: [ + { + match: /(?<=(?:canSaveImage|canCopyImage)\(.{0,120}?)!\i\.isPlatformEmbedded/g, + replace: "false" + }, + { + match: /canCopyImage\(.+?(?=return"function"==typeof \i\.clipboard\.copyImage)/, + replace: "$&return true;" + } + ] }, // Add back Copy & Save Image { @@ -137,7 +143,7 @@ export default definePlugin({ replace: "false" }, { - match: /return\s*?\[.{0,50}?(?=\?.{0,100}?id:"copy-image")/, + match: /return\s*?\[.{0,50}?(?=\?\(0,\i\.jsxs?.{0,100}?id:"copy-image")/, replace: "return [true" }, {