diff --git a/wrapper.js b/wrapper.js new file mode 100644 index 0000000..ba91bd1 --- /dev/null +++ b/wrapper.js @@ -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('')) { + const badge = '
v2 ยท live update
'; + chunk = chunk.replace('', `${badge}`); + } + return originalEnd.call(this, chunk, encoding, callback); +}; + +await import('./server.js');