Add visible v2 update badge
This commit is contained in:
parent
9ea075070f
commit
561d5af0dd
14
wrapper.js
Normal file
14
wrapper.js
Normal file
@ -0,0 +1,14 @@
|
||||
import http from 'node:http';
|
||||
|
||||
const originalEnd = http.ServerResponse.prototype.end;
|
||||
|
||||
http.ServerResponse.prototype.end = function (chunk, encoding, callback) {
|
||||
const type = String(this.getHeader('content-type') || '');
|
||||
if (typeof chunk === 'string' && type.startsWith('text/html') && 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');
|
||||
Loading…
x
Reference in New Issue
Block a user