14 lines
595 B
JavaScript

import http from 'node:http';
const originalEnd = http.ServerResponse.prototype.end;
http.ServerResponse.prototype.end = function (chunk, encoding, callback) {
if (typeof chunk === 'string' && chunk.includes('</body>')) {
const badge = '<div style="position:fixed;right:16px;bottom:16px;background:#1f6feb;color:#fff;padding:8px 12px;border-radius:999px;font:600 12px system-ui;box-shadow:0 8px 24px #0006">v2 · live update</div>';
chunk = chunk.replace('</body>', `${badge}</body>`);
}
return originalEnd.call(this, chunk, encoding, callback);
};
await import('./server.js');