diff --git a/main.meta.js b/main.meta.js index 0510780..3dc5300 100644 --- a/main.meta.js +++ b/main.meta.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PNGExtraEmbed // @namespace https://coom.tech/ -// @version 0.173 +// @version 0.174 // @description uhh // @author You // @match https://boards.4channel.org/* diff --git a/main.user.js b/main.user.js index 0b5f8ec..4c9ef81 100644 --- a/main.user.js +++ b/main.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PNGExtraEmbed // @namespace https://coom.tech/ -// @version 0.173 +// @version 0.174 // @description uhh // @author You // @match https://boards.4channel.org/* @@ -81,7 +81,7 @@ var define_BUILD_VERSION_default; var init_define_BUILD_VERSION = __esm({ ""() { - define_BUILD_VERSION_default = [0, 173]; + define_BUILD_VERSION_default = [0, 174]; } }); @@ -14002,6 +14002,7 @@ var extract = async (png) => { const reader = BufferReadStream(png).getReader(); const sneed = new PNGDecoder(reader); + const ret = []; try { for await (const [name, chunk, crc, offset] of sneed.chunks()) { let buff; @@ -14009,12 +14010,13 @@ case "tEXt": buff = await chunk(); if (buff.slice(4, 4 + CUM3.length).equals(CUM3)) { - return await decodeCoom3Payload(buff.slice(4 + CUM3.length)); + const k = await decodeCoom3Payload(buff.slice(4 + CUM3.length)); + ret.push(...k.filter((e) => e).map((e) => e)); } break; case "IDAT": case "IEND": - return; + return ret; default: break; } diff --git a/src/pngv3.ts b/src/pngv3.ts index 8c48523..6548fae 100644 --- a/src/pngv3.ts +++ b/src/pngv3.ts @@ -1,5 +1,5 @@ import { Buffer } from "buffer"; -import type { ImageProcessor } from "./main"; +import type { EmbeddedFile, ImageProcessor } from "./main"; import { PNGDecoder, PNGEncoder } from "./png"; import { buildPeeFile, decodeCoom3Payload, fireNotification, uploadFiles } from "./utils"; @@ -18,6 +18,8 @@ const BufferReadStream = (b: Buffer) => { const extract = async (png: Buffer) => { const reader = BufferReadStream(png).getReader(); const sneed = new PNGDecoder(reader); + const ret: EmbeddedFile[] = []; + try { for await (const [name, chunk, crc, offset] of sneed.chunks()) { let buff: Buffer; @@ -26,13 +28,14 @@ const extract = async (png: Buffer) => { case 'tEXt': buff = await chunk(); if (buff.slice(4, 4 + CUM3.length).equals(CUM3)) { - return await decodeCoom3Payload(buff.slice(4 + CUM3.length)); + const k = await decodeCoom3Payload(buff.slice(4 + CUM3.length)); + ret.push(...k.filter(e => e).map(e => e as EmbeddedFile)); } break; case 'IDAT': // eslint-disable-next-line no-fallthrough case 'IEND': - return; + return ret; // eslint-disable-next-line no-fallthrough default: break;