diff --git a/src/libpoketube/ptutils/ie-blocker.js b/src/libpoketube/ptutils/ie-blocker.js new file mode 100644 index 00000000..e98e9d89 --- /dev/null +++ b/src/libpoketube/ptutils/ie-blocker.js @@ -0,0 +1,52 @@ +// ie-blocker.js +function isIE(ua) { + if (!ua) return false; + // Matches old IE (MSIE) and IE 11 (Trident with rv) + return /MSIE \d|Trident\/.*rv:\d+/i.test(ua); +} + +function ieBlockHtml() { + return ( + '' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' Browser is not supported :p' + + ' ' + + '' + + '' + + '

Heyo :3

' + + '

hoi — poke does and will not work on Internet Explorer :p
' + + ' if u wanna use poke try using Firefox (firefox.com) or Chromium :3
' + + ' love u :3

' + + '' + + '' + ); +} + +// Global middleware that blocks IE everywhere. + +function ieBlockMiddleware(req, res, next) { + const ua = req.get('user-agent') || (req.useragent && req.useragent.source) || ''; + if (isIE(ua)) { + // Send ONLY the minimal page; no templates, no extras. + res + .status(200) + .type('html') + .set('Cache-Control', 'no-store, max-age=0') + .send(ieBlockHtml()); + return; + } + next(); +} + +module.exports = { isIE, ieBlockMiddleware, ieBlockHtml };