const fs = require('fs'); const path = require('path'); // Minimal valid 1x1 red PNG (base64) - scaled up to requested sizes via simple pixel repetition // For a real extension build, we just need valid PNG files. Chrome won't validate content during build. // We'll create minimal valid PNG files. function createSolidColorPNG(width, height, r, g, b) { // PNG signature const signature = Buffer.from([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]); // Helper: create PNG chunk function makeChunk(type, data) { const typeBuf = Buffer.from(type, 'ascii'); const lenBuf = Buffer.alloc(4); lenBuf.writeUInt32BE(data.length, 0); const crc = require('zlib').crc32(Buffer.concat([typeBuf, data])); const crcBuf = Buffer.alloc(4); crcBuf.writeUInt32BE(crc, 0); return Buffer.concat([lenBuf, typeBuf, data, crcBuf]); } // IHDR chunk const ihdr = Buffer.alloc(13); ihdr.writeUInt32BE(width, 0); ihdr.writeUInt32BE(height, 4); ihdr[8] = 8; // bit depth ihdr[9] = 2; // color type RGB ihdr[10] = 0; // compression ihdr[11] = 0; // filter method ihdr[12] = 0; // interlace // IDAT chunk - raw image data: filter byte + RGB pixels per row const rowSize = 1 + width * 3; const rawData = Buffer.alloc(height * rowSize); for (let y = 0; y < height; y++) { rawData[y * rowSize] = 0; // filter byte: none for (let x = 0; x < width; x++) { rawData[y * rowSize + 1 + x * 3] = r; rawData[y * rowSize + 1 + x * 3 + 1] = g; rawData[y * rowSize + 1 + x * 3 + 2] = b; } } const compressed = require('zlib').deflateSync(rawData); // IEND chunk const iend = makeChunk('IEND', Buffer.alloc(0)); return Buffer.concat([ signature, makeChunk('IHDR', ihdr), makeChunk('IDAT', compressed), iend ]); } const outDir = path.join(__dirname, 'icons'); fs.mkdirSync(outDir, { recursive: true }); fs.writeFileSync(path.join(outDir, 'icon16.png'), createSolidColorPNG(16, 16, 239, 68, 68)); fs.writeFileSync(path.join(outDir, 'icon48.png'), createSolidColorPNG(48, 48, 239, 68, 68)); fs.writeFileSync(path.join(outDir, 'icon128.png'), createSolidColorPNG(128, 128, 239, 68, 68)); console.log('Icons generated successfully');