-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.js
More file actions
103 lines (87 loc) · 3.08 KB
/
setup.js
File metadata and controls
103 lines (87 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env node
// Setup script to generate extension icons
const fs = require('fs');
const path = require('path');
// Minimal PNG generator for solid color icons
function createPNG(width, height, r, g, b) {
const signature = Buffer.from([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]);
function crc32(data) {
let crc = 0xFFFFFFFF;
const table = [];
for (let i = 0; i < 256; i++) {
let c = i;
for (let j = 0; j < 8; j++) {
c = (c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1);
}
table[i] = c;
}
for (let i = 0; i < data.length; i++) {
crc = table[(crc ^ data[i]) & 0xFF] ^ (crc >>> 8);
}
return (crc ^ 0xFFFFFFFF) >>> 0;
}
function chunk(type, data) {
const typeBytes = Buffer.from(type);
const length = Buffer.alloc(4);
length.writeUInt32BE(data.length);
const combined = Buffer.concat([typeBytes, data]);
const crc = Buffer.alloc(4);
crc.writeUInt32BE(crc32(combined));
return Buffer.concat([length, combined, crc]);
}
// 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
ihdr[12] = 0; // interlace
// Raw image data (uncompressed for simplicity using zlib)
const rawData = [];
for (let y = 0; y < height; y++) {
rawData.push(0); // filter byte
for (let x = 0; x < width; x++) {
// Create a simple gradient/explosion effect
const dx = x - width / 2;
const dy = y - height / 2;
const dist = Math.sqrt(dx * dx + dy * dy);
const maxDist = Math.sqrt((width/2) * (width/2) + (height/2) * (height/2));
const factor = 1 - (dist / maxDist);
// Center is bright yellow/white, edges are orange/red
const pr = Math.min(255, Math.floor(r + (255 - r) * factor * 0.5));
const pg = Math.min(255, Math.floor(g * factor + 100 * (1 - factor)));
const pb = Math.min(255, Math.floor(b * factor));
rawData.push(pr, pg, pb);
}
}
// Compress with zlib
const zlib = require('zlib');
const compressed = zlib.deflateSync(Buffer.from(rawData));
// IDAT chunk
const idat = chunk('IDAT', compressed);
// IEND chunk
const iend = chunk('IEND', Buffer.alloc(0));
return Buffer.concat([signature, chunk('IHDR', ihdr), idat, iend]);
}
// Create assets directory
const assetsDir = path.join(__dirname, 'assets');
if (!fs.existsSync(assetsDir)) {
fs.mkdirSync(assetsDir);
}
// Generate icons (orange/red explosion color)
const sizes = [16, 48, 128];
const r = 255, g = 69, b = 0; // #ff4500
sizes.forEach(size => {
const png = createPNG(size, size, r, g, b);
const filename = path.join(assetsDir, `icon${size}.png`);
fs.writeFileSync(filename, png);
console.log(`Created ${filename}`);
});
console.log('\nIcons generated successfully!');
console.log('\nTo install the extension:');
console.log('1. Open chrome://extensions');
console.log('2. Enable "Developer mode"');
console.log('3. Click "Load unpacked"');
console.log('4. Select this folder: ' + __dirname);